48 Commits

Author SHA1 Message Date
Dan Guido 95875b4ec5 fix: apply shellcheck and shfmt fixes to all shell scripts
Apply automated fixes from shellcheck and shfmt to all shell scripts:
- Quote variables to prevent word splitting and globbing
- Use $(...) instead of backticks for command substitution
- Add proper shebang and set -euo pipefail where missing
- Fix array handling and iteration patterns
- Consistent indentation (4 spaces)
- Remove unnecessary curly braces and simplify expressions

Files fixed:
- deployment/*.sh
- scripts/*.sh
- orchestrator/scripts/*.sh
- fuzzer_runner/runner.sh
- protoc.sh

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-26 11:13:16 +01:00
Henrik Brodin 9575877a3e Use project specified in oss-fuzz (#415)
* Use project specified in oss-fuzz

This will use the contents of the oss-fuzz provided container as the
projects contents instead of a user supplied git url. This will allow to
run projects very similar to how oss-fuzz does it. It will enable
analysis of e.g. libmodbus who was previously not possible due to the
fuzzing harnesses being overwritten/shadowed by the mount of project
directory.
Use project_name for focusdir when in doubt
2026-01-23 14:55:19 +01:00
Riccardo Schirone 008bb9cd6a Use our modified oss-fuzz (#367)
libpng has changed the default branch to libpng18, but that doesn't
contain the oss-fuzz files. Let's use our own fork of oss-fuzz for now,
until https://github.com/google/oss-fuzz/pull/14080 is ready.
2025-10-03 10:36:30 -04:00
Dan Guido 42691e50b4 style: apply ruff auto-fixes and formatting across entire codebase (#309)
* style: apply ruff auto-fixes and formatting across entire codebase

Applied safe auto-fixes from ruff v0.12.9 with --select ALL to improve code quality:
- Reorder imports (stdlib → third-party → local)
- Use modern type hints (collections.abc.Generator instead of typing.Generator)
- Add trailing commas for better diffs
- Format multi-line function parameters for readability
- Add strict=False to zip() calls for explicit behavior
- Simplify redundant elif to if after return statements
- Consistent code formatting with ruff format

These are all mechanical, non-controversial changes that improve code consistency
without altering functionality. Changes affect 180 files across all modules:
common, fuzzer, orchestrator, patcher, program-model, and seed-gen.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>

* re-applt ruff after merge

---------

Co-authored-by: Claude <noreply@anthropic.com>
Co-authored-by: Michael D Brown <michael.brown@trailofbits.com>
2025-08-22 10:30:12 -04:00
Riccardo Schirone a533a28d47 Revert "refactor: standardize packaging across all components (#266)"
This reverts commit cc938e105f.
2025-08-09 13:13:28 -05:00
Dan Guido cc938e105f refactor: standardize packaging across all components (#266)
* refactor: standardize packaging across all components

- Standardize Python version to >=3.12,<3.13 for all components
- Migrate from [project.optional-dependencies] to modern [dependency-groups] (PEP 735)
- Standardize ruff line-length to 120 characters across all components
- Add consistent project metadata:
  - AGPL-3.0 license field
  - Repository and Issues URLs
  - Improved, descriptive description fields
  - Fix email addresses to include .com domain

This improves consistency, maintainability, and follows modern Python
packaging best practices with uv/pip standards.

* fix: address PR review comments

- Move requires-python field to standard position (after license) in seed-gen
- Update all components to use latest ruff version (>=0.12.8)
- Ensure consistent dependency ordering across all components

* refactor: standardize dependency pinning strategy

Apply consistent dependency versioning across all components:

- Use ~= (compatible release) for core dependencies:
  - Infrastructure: redis, pydantic, fastapi, uvicorn, sqlalchemy
  - AI/LLM: openai, langchain-community, langgraph-checkpoint
  - Parsing: tree-sitter, tree-sitter-language-pack
  - Web: requests, urllib3, pyyaml
  - Utils: python-dotenv, unidiff, argon2-cffi, pymongo, six

- Keep >= for stable dev tools:
  - pytest, mypy, ruff, flake8 (want latest versions)
  - types-* packages (want latest type definitions)
  - rich, beautifulsoup4 (stable, backwards compatible)

- Keep exact pins for known issues:
  - protobuf (narrow range for compatibility)
  - openlit==1.32.12 (documented issue with 1.33)
  - clusterfuzz==2.6.0 (complex, version-sensitive)

This provides predictable builds with automatic patch updates while
preventing unexpected breaking changes from major/minor version bumps.

* feat: add project metadata for discoverability

Add comprehensive metadata to all components:

Keywords:
- common: cybersecurity, crs, utilities, protobuf, redis, telemetry
- fuzzer: fuzzing, oss-fuzz, libfuzzer, vulnerability-discovery, coverage
- orchestrator: orchestration, task-management, scheduler, api, fastapi
- patcher: patching, vulnerability-repair, llm, ai, code-generation
- program-model: static-analysis, codequery, tree-sitter, semantic-analysis
- seed-gen: test-generation, input-generation, fuzzing, seed-corpus, llm

Classifiers:
- Development Status :: 4 - Beta (all components)
- License :: OSI Approved :: GNU Affero General Public License v3
- Programming Language :: Python :: 3.12
- Topic :: Security (all components)
- Component-specific topics (Testing, AI, Distributed Computing, etc.)
- Operating System :: POSIX :: Linux

URLs:
- Added Documentation URL pointing to README for all components

This improves package discoverability, provides clear metadata for tools,
and gives the project a more professional appearance.

* Standardize tool configurations across all components

- Add pytest.ini_options configuration to all components
- Add coverage configuration with consistent exclude patterns
- Standardize ruff configuration with target-version and lint rules
- Fix missing readme field in fuzzer/pyproject.toml
- Fix python-dotenv spacing inconsistency in seed-gen
- Standardize all dev dependencies to use ~= operator for consistency

* Fix trailing whitespace and line length issues

- Remove trailing whitespace from tree-sitter query strings
- Remove trailing whitespace from test output strings
- Fix line length issues in logger.info() calls by splitting format strings
- Fix line length in datetime formatting by extracting variables
- Split long Pydantic Field descriptions and docstrings
- Leave test data strings unchanged to avoid breaking tests

* Fix dependency resolution issues

- Update argon2-cffi from ~=21.0.0 to ~=21.3.0 (21.0.x doesn't exist on PyPI)
- Update langgraph-checkpoint from ~=2.0.25 to ~=2.1.0 to match langgraph requirements
- Standardize spacing around ~= operators in all dependency specifications
- All components now successfully resolve dependencies with uv

* Apply ruff auto-fixes across project

- Fix import sorting (I001) in fuzzer, orchestrator, and patcher
- Update to PEP 585 type annotations (List->list, Dict->dict, etc.)
- Update to PEP 604 union syntax (Optional[X] -> X | None)
- Remove unnecessary UTF-8 encoding declarations
- Remove redundant file open modes
- Modernize type annotations throughout the codebase

Remaining issues are primarily line length (E501) which require manual review

* Fix line length issues in program-model component

- Break up long Java code strings in test assertions using implicit concatenation
- Split long constructor and method definitions across multiple lines
- Add noqa: E501 comment for 10,977 character struct definition test data
- All program-model line length issues resolved

* fix: revert protobuf enum type annotations to Optional

Protobuf enums (EnumTypeWrapper) don't support the | operator for type unions.
The ruff UP035 rule converted Optional[ProtobufEnum] to ProtobufEnum | None,
but this causes TypeError at runtime. Reverted these specific changes while
keeping the modern type union syntax for regular Python types.

* chore: add ruff protection for protobuf enum type annotations

- Configure ruff to ignore UP045 rule in test_submissions.py
- Add inline noqa comments to document why Optional is needed
- Protobuf enums (EnumTypeWrapper) don't support the | operator
- This prevents future automated fixes from breaking the code

* fix: modernize Python syntax and fix formatting issues

- Convert printf-style formatting to f-strings (UP031)
- Remove trailing whitespace from blank lines (W293)
- Use PEP 695 generic class syntax for Python 3.12+ (UP046)
- Use PEP 695 type alias syntax with 'type' keyword (UP040)

These changes modernize the codebase to use Python 3.12+ features
and fix formatting inconsistencies detected by ruff.

* fix: resolve undefined MsgType reference after PEP 695 conversion

When converting to PEP 695 generic class syntax, the MsgType TypeVar
was removed but was still referenced in overloaded method signatures.
Changed the generic fallback overload to use Message directly.

* fix: resolve line length violations across entire codebase

Applied Black formatter and manual fixes to resolve E501 line length violations:
- Fixed 178 line length issues across common, fuzzer, orchestrator, patcher, and program-model components
- Used Black formatter for automatic reformatting where possible
- Manually split long strings, function calls, and complex expressions
- All files now comply with 120-character line limit

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>

* fix: revert PEP 695 type alias syntax in node_local.py

The PEP 695 syntax (type X = Y) creates TypeAliasType objects that cannot
be used as constructors at runtime. Since node_local.py uses NodeLocalPath
and RemotePath as constructors (e.g., NodeLocalPath(path)), we must use
the old TypeAlias syntax to maintain runtime functionality.

Added noqa comments to prevent ruff from attempting to modernize these
aliases in the future.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>

* chore: configure ruff to ignore UP040 for node_local.py

Added per-file configuration to prevent ruff from attempting to convert
TypeAlias annotations to PEP 695 syntax in node_local.py. This protects
the runtime functionality that relies on these type aliases being usable
as constructors.

Also removed redundant inline noqa comments since the ignore is now
configured at the project level.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>

* fix: correct MsgType reference in static method decorator

The _ensure_group_name static method decorator was incorrectly
referencing MsgType in the wrapper function signature. Since MsgType
is a class-level type parameter and not accessible in static method
scope, changed it to Message which is the appropriate bound type.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>

* docs: add explanatory comment for Message type in decorator

Added a comment explaining why we must use Message instead of MsgType
in the _ensure_group_name decorator's wrapper function. This prevents
future confusion and protects against accidental "fixes" that would
break the code.

The MsgType parameter is a class-level type variable that's not in
scope within the static method decorator context.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>

---------

Co-authored-by: Claude <noreply@anthropic.com>
2025-08-08 19:59:56 -07:00
Alessandro Gario cc1d57b2c0 scripts: Convert the challenge.sh script to Python (#216)
* scripts: Convert the challenge.sh script to Python

Latest macOS still relies on bash 3.2.57, which is not compatible
with the constructs used by the challenge.sh script.

* scripts: Replace the challenge.sh script with the Python version

* scripts: Print requests performed by challenge.py

* scripts: Remove type hints from global vars in challenge.py

* scripts: Refactor challenge.py to use kwargs for overrides

* scripts: Update challenge.py to use argparse

* scripts: Update the challenge.py help text

* scripts: Validate the challenge name in challenge.py
2025-08-04 10:23:56 +02:00
Riccardo Schirone 5cfa9bd26e Add support for ARM (#207)
* Fix integration-test run

* use the proper oss-fuzz-aixcc commit to run integration-test
* determine OSS_FUZZ_CONTAINER_ORG at runtime
* use `git diff` in the patcher to create the patch to fix a problem
  with patches affecting non-newline terminated files

* fix parsing

* fix program-model lint

* Modify CRS to work on MacOS/ARM

* Use LibUCL for testing

* use example-libpng

* fix linting

* common: fix tests
2025-07-31 09:55:36 -04:00
Riccardo Schirone a08cbf1050 Make CRS more flexible (#202)
* Fix integration-test run

* use the proper oss-fuzz-aixcc commit to run integration-test
* determine OSS_FUZZ_CONTAINER_ORG at runtime
* use `git diff` in the patcher to create the patch to fix a problem
  with patches affecting non-newline terminated files

* fix parsing

* fix program-model lint
2025-07-31 09:34:28 -04:00
Brad Swain c7fc0f7c9a remove refs to aixcc resources (#195)
* remove refs to aixcc resources

* remove aixcc.tech

* change aixcc-finals to tob-challenges
2025-07-30 09:34:58 -05:00
Michael D Brown 9c362f6508 retargeting integration test challenge script to correct repos (#186) 2025-07-25 13:30:39 -05:00
Evan Downing 0428c66377 Update challenge urls and docs (#162) 2025-07-22 11:01:47 -04:00
Riccardo Schirone 354ca31f8b buttercup-ui: basic interface to the CRS (#141)
* add ui to k8s
* ui: support for cloning private repos
2025-07-10 17:41:22 +02:00
Riccardo Schirone cdb67b0b60 Changes to allow non aixcc deployment (#147) 2025-07-09 12:22:54 +02:00
Riccardo Schirone 97a44cfcc7 orchestrator: adjust sim3 from round info (#917) 2025-06-23 10:52:45 +02:00
Ronald Eytchison 8df4bdbd3a Update sim3 to run Java and C/C++ challenges in separate batches (#902) 2025-06-20 11:55:37 -04:00
Riccardo Schirone 6d15047b32 orchestrator/scripts: mark unharnessed challenges (#888) 2025-06-19 10:03:44 +02:00
Riccardo Schirone d62adad4bc Update CRS/Competition API to v1.4.0 (-rc1 capi) (#880)
* Update competition-test-api to v1.4-rc1
* Update to competition/crs API v1.4.0
2025-06-18 16:51:52 +02:00
Evan Downing 474906f17f Fix updating duration (#858) 2025-06-16 12:08:26 -04:00
Evan Downing 1c1804baa0 Add unscored round 3 simulation (#843)
* Add unscored round 3 simulation

* Add testing routine
2025-06-13 12:29:56 -04:00
Evan Downing 4e2a65b167 Add instructions on evaluating challenges (#821) 2025-06-11 15:15:20 -04:00
Boyan MILANOV 360c5d1de2 Set timeout for reproducer (#789)
* Set timeout for reproducer

* Add testing updated version of oss-fuzz-aixcc

---------

Co-authored-by: Boyan MILANOV <boyanmilanov@coder-boyanmilanov-aixcc-boyan.c.production-1-405717.internal>
Co-authored-by: Evan Downing <2077950+evandowning@users.noreply.github.com>
2025-06-09 12:08:45 -04:00
Riccardo Schirone 995cac41fc doc: add a few extra steps in the RELEASE file (#796)
* doc: add a few extra steps in the RELEASE file

* add an extra integration test in full mode
2025-06-05 14:02:16 +02:00
Evan Downing a00334d45e Fix oss-fuzz branch (#790) 2025-06-04 11:52:52 -04:00
Henrik Brodin 2c07d47252 Competition API v1.2-rc5 (#784)
Enables an additional flag to send unharnessed challenges.
2025-06-04 14:52:01 +02:00
Riccardo Schirone 8da34c19e5 orchestrator: create script to simulate round-2 challenges (#704)
* orchestrator: create script to simulate round-2 challenges

* fix json data

* Add options to simulation script

---------

Co-authored-by: Evan Downing <2077950+evandowning@users.noreply.github.com>
2025-05-30 07:59:02 -04:00
Riccardo Schirone 60b0ae35e5 Update cAPI to v1.2-rc4 and API to v1.3.0 (#740)
* Update competition-test-api to v1.2-rc4

* orchestrator: update API to v1.3.0
2025-05-29 12:05:43 +02:00
Riccardo Schirone 81e5950c92 Patcher refactoring (#603)
* patcher: update langgraph dependencies

* patcher: remove 'messages' from State because not used

* patcher: change CodeSnippetKey to use lines instead of IDs

* patcher: improve ContextRetrieverAgent

- use RunnableConfig and PatcherConfig to pass configuration options
  more easily
- make the state serializable, so that we can use CheckPointer to save
  and restore an agent state and get code snippets more easily in case
  of failures
- add tests
- use prebuilt React agent for simplicity
- allow to track lines from a file

* patcher: move all agents to new CodeSnippetKey

* patcher: group patch attempts in a single class

* patcher: remove diff_analysis from state because unused

* patcher: make more use of PatcherConfig

* patcher: add patch description

* patcher: use renamed patch_attempts

* patcher: go back to identifier (random) for CodeSnippets

* patcher: parse stacktrace for initial context

* common: fix parse_stacktrace return type

* patcher: introduce reflection agenta and remove reviewer

* patcher: use structured rootcause analysis

* patcher: paralellize ctx requests

* patcher: have some best-effort json parser for rootcause

* tmp comit

* fix tests

* a few other fixes

* fix lint

* add libxml2 script

* patcher: remove some dead code

* ctx-retriever: use smaller models

* fix tests

* improve initial context

* add comment

* patcher: remove dead code

* fix none access

* other random fixes
2025-05-19 15:13:12 -04:00
Ronald Eytchison e6b6c94af9 Support full mode in vuln discovery task (#448)
* Refactor common vuln discovery functionality

* Add vuln discovery for full mode

---------

Co-authored-by: Michael D Brown <michael.brown.uc@gmail.com>
2025-04-24 14:29:38 -04:00
Riccardo Schirone caabb07dd5 ci: allow to customize workflow dispatch (#427) 2025-04-22 13:51:28 +02:00
Henrik Brodin 939819c6d4 Competition api v1.1-rc7 (#368)
- adds a script to send SARIF messages
- updated readme
2025-04-08 11:34:05 +02:00
Riccardo Schirone 42f010e913 deployment: create prod/staging environments (#256)
* update VM sizes to L16
2025-03-28 14:47:01 +01:00
Henrik Brodin ac9ad53a20 Update head according to the updated documentation (#270) 2025-03-26 19:29:44 +01:00
Henrik Brodin ff5e3d01d6 Update competition api to v1.1-rc4 (#240) 2025-03-25 13:38:32 +01:00
Riccardo Schirone 61a6200abe Update k8s deployment with competition-api v1.1 (#231) 2025-03-25 09:35:50 +01:00
Riccardo Schirone 99155d61b8 orchestrator: fix update to crs/competition api v1.1(.1) (#224)
* orchestrator: fix update to crs/competition api v1.1(.1)

* orchestrator: add tests for fastapi server

* orchestrator: remove task server patch
2025-03-21 00:04:30 +00:00
Henrik Brodin 42ed9402f0 Stop work on expired (#196)
* Implements task cancelation

- Cancel one or all tasks.
- delete_task.sh script for invoking
- refactored to keep deleted tasks in a separate set, update tasks as
  needed from registry instead of updating the stored tasks.

* Refactor cancellation, update use in vulnerabilities

* Cleanup cancellation

* Remove package_name from protomsg

* Fix test case

* fix tests

* PR feedback
2025-03-19 18:00:16 +01:00
Riccardo Schirone 290ae923bd Competition api v1.1 (#184)
* orchestrator: update competition_api_client to v0.4

* orchestrator: adapt to new competition_api_client v0.4

* Update API to v1.1

* remove shared-tmp volume

* fix tests

* fix lint
2025-03-18 18:54:17 +01:00
Henrik Brodin fd21d0020c Implements configurable authentication (#181)
* Implements configurable authentication

This removes the hardcoded auth and introduces a tool for generating the
required keys/tokens/tokenhash values.

buttercup-auth-tool --env

this will output all information needed to configure the server and
client side.

* lint

* Use new auth in ci
2025-03-10 09:51:29 +01:00
Riccardo Schirone 291bd034cf orchestrator: set project_name/focus in task-downloader process (#108) 2025-03-04 09:52:23 +01:00
Riccardo Schirone 9532aaf7ed orchestrator: update task_crs script with new format (#65) 2025-02-18 17:55:53 -05:00
Henrik Brodin 61959553ff Update to v 0.3 2025-02-18 16:41:40 +00:00
Riccardo Schirone 1936b726bb orchestrator: make task_crs.sh script executable 2025-02-07 15:17:01 +00:00
Riccardo Schirone 81c644f497 configure .env file 2025-02-07 15:17:01 +00:00
Henrik Brodin dec6f3bfc0 Integration of competition api server 2025-02-04 14:11:16 +00:00
Riccardo Schirone 9a05bc99a4 orchestrator: add swagger APIs in the doc folder 2025-01-23 12:07:58 +01:00
Riccardo Schirone 3b8409b2fe orchestrator: fix update_apis.sh script 2025-01-23 12:07:58 +01:00
Riccardo Schirone dee20dd7b6 Introduce Buttercup namespace for CRS components (#5)
* orchestrator: create pkg under 'buttercup' namespace

* fix compose file
2025-01-17 08:59:16 +01:00