Repository navigation
Test(fuzz): Fuzz the triage proposal checks - #54
ModeSevenIndustrialSolutions merged 5 commits into
Conversation
There was a problem hiding this comment.
🟡 Changes recommended
The fuzz verifier’s expected verdict omits both evidence-file size limits, causing correct refusals of oversized inputs to be reported as false fuzz failures.
1 open issue
What changed in this PR
Adds fuzz testing for untrusted triage proposals, evidence verification, and log output toward issue #53, alongside fixes for three output-sanitization defects.
Changes:
- Adds two Atheris harnesses with independent checks, a fake GitHub environment, and shared utilities.
- Adds seed replay and tests showing the checks reject deliberately incorrect results.
- Hardens report output against control characters, lone surrogates, and runner commands formed by joining fields.
| File | Description |
|---|---|
tests/test_fuzz.py |
Replays seeds and checks that faulty results are detected. |
tests/test_apply_triage.py |
Adds output-sanitization regression tests. |
scripts/apply_triage.py |
Sanitizes Unicode and escapes complete report lines. |
README.md |
Documents fuzz targets and manual invocation. |
fuzz/triage_world.py |
Provides fixed GitHub state and network guards. |
fuzz/fuzz_triage_policy.py |
Fuzzes proposal extraction, policy enforcement, and reports. |
fuzz/fuzz_triage_output.py |
Fuzzes evidence verification and safe text rendering. |
fuzz/fuzz_support.py |
Shares seed handling and strict UTF-8 output capture. |
docs/development/DESIGN.md |
Adds fuzz harnesses to the repository layout. |
Review effort: Balanced
zxiiro
left a comment
There was a problem hiding this comment.
🤖 Auto-approved by agent: reviewed workflow/code change for security and CI/CD impact, found low risk. Log-escaping hardening in apply_triage.py (C1 controls folded, lone surrogates escaped, whole report lines escaped so fields can't join into ::/##[ commands) plus test-only fuzz harnesses; no change to which labels are applied, and no workflow, permission or secret changes.
d072c61 to
244dbd0
Compare
244dbd0 to
e1ae488
Compare
e1ae488 to
5cb9597
Compare
5cb9597 to
1c1a229
Compare
1c1a229 to
c8e0c6a
Compare
c8e0c6a to
8481623
Compare
one_line promises to render untrusted text "without control characters", yet its pattern stops at C0 and DEL, so NEL (U+0085) and the rest of the C1 range reach the runner log. It also passes lone surrogates through: a JSON escape such as \ud800 in a proposal decodes to one, and printing it to the runner's strict UTF-8 stdout raises UnicodeEncodeError, crashing the report after apply-result.json is written. Both tests are marked as expected failures until the fixes land. Co-authored-by: Copilot <[email protected]> Signed-off-by: lf-releng-code-monkey-bot[bot] <332050256+lf-releng-code-monkey-bot[bot]@users.noreply.github.com>
one_line documents that it renders untrusted text without control characters, but its pattern covered only C0 and DEL. NEL (U+0085) and the other C1 controls reached the runner log unchanged, where a viewer may treat NEL as a line break. Widen the pattern to the C1 range and drop the expected-failure marker from the test that shows it. Co-authored-by: Copilot <[email protected]> Signed-off-by: lf-releng-code-monkey-bot[bot] <332050256+lf-releng-code-monkey-bot[bot]@users.noreply.github.com>
json.loads turns an escape such as \ud800 in the agent's proposal into a lone surrogate. one_line passed it through, and print() to the runner's strict UTF-8 stdout then raised UnicodeEncodeError, so a label or rationale carrying one crashed report() after the run's writes and apply-result.json. Render the surrogate as a backslash escape so the line stays printable and the original stays in the JSON evidence. Co-authored-by: Copilot <[email protected]> Signed-off-by: lf-releng-code-monkey-bot[bot] <332050256+lf-releng-code-monkey-bot[bot]@users.noreply.github.com>
report escaped each untrusted field on its own, then joined the fields with "#" and ": ". The join could rebuild what escaping removed: repository "owner/rep#" and issue "[1]" printed "owner/rep##[1]", and an issue ending in ":" printed "1::". The runner's legacy parser finds "##[" anywhere in a line. Escape each assembled line once instead. The Atheris policy harness found the "##[" case; the regression test covers both joins. Co-authored-by: Copilot <[email protected]> Signed-off-by: lf-releng-code-monkey-bot[bot] <332050256+lf-releng-code-monkey-bot[bot]@users.noreply.github.com>
Add two harnesses meeting harness contract v1:
- fuzz_triage_policy.py runs an agent message through
extract_proposal, apply_triage.process and report against a fixed,
fake GitHub (triage_world.py), and judges each applied action
against that world and the DESIGN.md section 6 rules.
- fuzz_triage_output.py checks triage_evidence.verify against
digests, file shapes and sizes it chooses itself, and that one_line
prints one inert line to a strict UTF-8 stream.
import atheris sits inside main(), so the modules import without
Atheris. tests/test_fuzz.py replays every seed in the offline suite
and shows each oracle rejecting a deliberately wrong result. The
README and the design layout name the harnesses.
Review: the verify oracle ignored the per-file byte caps, so a
correct refusal of exclusions over 1 MiB was reported as a breach.
The expected verdict now applies the caps DESIGN.md states (16 MiB
snapshot, 1 MiB exclusions), kept apart from triage_evidence's own
constants, and a test replays an oversized exclusions file.
Review, round 2:
- The split selector was a single byte modulo the body, so the
snapshot never exceeded 255 bytes and its 16 MiB cap was out of
reach. split_contents now scales that byte over the whole body.
- No seed reached the 1 MiB exclusions cap, and libFuzzer truncates
any seed past 1 MiB unless given -max_len. A seed one byte over
the cap joins SEEDS, and libfuzzer_arguments raises -max_len to
the largest seed when one exceeds that ceiling and the caller set
none. A 16 MiB seed is left out: it would push every run's inputs
to 16 MiB; a test replays an oversized snapshot instead.
- process received the proposal objects the oracle later judges, so
a validator that rewrote Urgent to High in place could pass. It
now gets a deep copy, and a test patches in such a validator.
Review, round 3:
- Where the scope stores no Priority, the oracle accepted an applied
action from an Urgent proposal once the action dropped the grade,
yet validate refuses Urgent and unknown grades before that drop.
check_action now checks the raw grade against GRADES in every
scope; a test and a seed cover the scope without a Priority field.
- copy.deepcopy recursed deeper than json.loads and raised
RecursionError on a valid proposal with 600 nested arrays in an
unused field, a harness crash rather than a triage defect. process
now gets its own parse of the message per scope, and the nested
input joins SEEDS.
Review, round 4:
- The oracle read a flag as "is True", so a validator that coerced
migrate_enhancement or escalate "yes" to False passed. raw_flag
now defaults only an absent flag to False and treats any other
non-boolean as a breach; a test shows both coercions caught.
- Where the scope has no issue types, the oracle accepted a dropped
type whatever its raw value, yet validate refuses a non-string
type before that drop. check_action now checks the raw type in
every scope; a test covers the scope without types, and seeds
carry the malformed flags and type.
Review, round 5:
- The oracle iterated the applied labels, so labels shaped as an
object, such as {"bug": "not a list"}, passed on their keys alone,
though check_labels refuses anything but a list of strings.
check_action now requires a list of strings first; a test feeds
object, string and mixed labels, and a seed carries object labels.
Review, round 6:
- The outcome oracle took its raw items from extract_proposal, the
code under test, so an extractor that rewrote Urgent to High on
every parse passed and the invalid proposal was judged applied.
An input that is itself a JSON document now stands for the final
block: the harness fences it, decodes it with json.loads on its
own, requires the extractor's answer to match in type and value,
and judges process against its own decode. Outcome seeds become
bare blocks; fenced seeds stay for extraction. A test makes the
extractor rewrite the priority, and a flag to a number.
Review, round 7:
- The extraction oracle checked only that a valid final block wins,
so an extractor that fell back to an earlier valid proposal when
the final block was unusable passed. check_extraction now appends
final blocks the extractor must refuse (no proposals, not an
object, not JSON, not a json fence) and requires a refusal for
each; a test patches in such a fallback extractor.
Co-authored-by: Copilot <[email protected]>
Signed-off-by: lf-releng-code-monkey-bot[bot] <332050256+lf-releng-code-monkey-bot[bot]@users.noreply.github.com>
8481623 to
e875075
Compare
There was a problem hiding this comment.
🤖 Antagonistic review by agent: no line-level findings; the summary below is the verdict.
No actionable defects found. The log-sanitization changes address the documented failure cases, and the fuzz harnesses are consistent with the policy and evidence-verification contracts.
Antagonistic round 1 of 3.
Automated antagonistic review by lf-releng-antagonistic-review-bot[bot] using model gpt-6-astra; see the run. This is not a human review and never an approval: a maintainer must still review and approve this pull request.
zxiiro
left a comment
There was a problem hiding this comment.
🤖 Auto-approved by agent: reviewed workflow/code change for security and CI/CD impact, found low risk. apply_triage.py log escaping folds C1 controls, escapes lone surrogates and escapes whole lines, with label logic unchanged; the rest is fuzz harnesses and tests, with no workflow changes.
14b2edc
into
lfreleng-actions:main

Closes #53
Authored by an AI agent; human review required
claude-opus-5.5via GitHub Copilot CLIc9fe48effb134a51dd649077465fb4c8cfa88714python -B -m unittest discover -s testspython -B -m unittest tests.test_fuzz (new test against the old harness, expected to fail)prek run --files fuzz/fuzz_triage_policy.py tests/test_fuzz.py (ruff format rewrote tests/test_fuzz.py)prek run --files fuzz/fuzz_triage_policy.py tests/test_fuzz.pyAISLOP_NO_TELEMETRY=1 aislop scan --base c9fe48effb134a51dd649077465fb4c8cfa88714 --json (ruff on PATH)python fuzz/fuzz_triage_policy.py -max_total_time=60 corpus (Atheris venv)python fuzz/fuzz_triage_policy.py -runs=0python fuzz/fuzz_triage_policy.py seed.jsongit commit --amend -s -F msg.txt (hooks and gitlint)git log --raw --format=%h c9fe48effb134a51dd649077465fb4c8cfa88714..HEADThe
github-code-monkey-botworkflow opened this pull request.Nobody has merged it; a maintainer must review it first.
Review findings on this pull request are answered by a later revision round of this workflow, up to ten rounds per antagonistic review round; after that a maintainer, or the next antagonistic review, takes on any finding that remains, and a maintainer reviews every round before merge.
Round 7 of revision, on its base.
Adds two Atheris fuzz harnesses meeting harness contract v1 (#53), and fixes the
one_linedefects they found.Commits
Test(apply): Add expected-fail one_line log testsFix(apply): Fold C1 control characters in logsFix(apply): Escape lone surrogates in log linesFix(apply): Escape report lines wholeTest(fuzz): Add Atheris harnesses for triageHarnesses
fuzz/fuzz_triage_policy.pyruns an agent message throughextract_proposal,apply_triage.processandreportagainst a fixed fake GitHub (fuzz/triage_world.py). It judges each applied action against that world and the DESIGN.md section 6 rules, never against the code's own answer. An input that is a JSON document stands for the final block: the harness fences it, decodes it withjson.loadsitself and requires the extractor to return exactly that. The extraction oracle requires a valid final block to win, and an unusable final block to be refused instead of falling back to an earlier one.fuzz/fuzz_triage_output.pycheckstriage_evidence.verifyagainst digests, shapes and size caps it computes itself, and thatone_lineprints one inert line to a strict UTF-8 stream.import atherissits inside eachmain(), so the modules import without Atheris.tests/test_fuzz.pyreplays every seed in the normal suite and shows each oracle rejecting a deliberately wrong result. Left out: the five shared modules (lfreleng-actions/bots-template#63) and the workflow contract tests.This round (7)
check_extractionnow appends four final blocks the extractor must refuse ({},[], non-JSON, a non-jsonfence) and requires a refusal for each. A new test patches in a fallback extractor and fails on the old harness.Validation
python -B -m unittest discover -s tests: 282 tests pass.prek run --fileson the changed files, and gitlint: pass.one_linedefects in commits 2 to 4 are the findings, each with a regression test.python <harness> -runs=0andpython <harness> <seed file>exit 0.For the reviewer
.github/workflows/changes, and no dependency, lock file or hook configuration changes.