Repository navigation
Test: Fuzz untrusted input, fix surrogate crashes - #206
ModeSevenIndustrialSolutions merged 4 commits into
Conversation
There was a problem hiding this comment.
🟡 Changes recommended
The new fuzz harness has a reproducible, unfixed lone-surrogate input that raises UnicodeEncodeError and can halt subsequent fuzz runs.
1 open issue
What changed in this PR
This PR adds fuzz coverage for the bot’s untrusted-input readers, addressing issue #205, and fixes lone-surrogate handling in log_safe so rendered text remains UTF-8 encodable.
Changes:
- Adds three Atheris harnesses for proposal rules, review classification, and operator input.
- Replays seeds and checks oracle failures in the normal unit suite without requiring Atheris.
- Adds the
log_saferegression test and documents local fuzzing and crash replay.
| File | Description |
|---|---|
tests/test_proposal_policy.py |
Adds a lone-surrogate regression test for log_safe. |
tests/test_fuzz_harnesses.py |
Tests seed replay, oracle failures, and seed-directory arguments. |
scripts/proposal_policy.py |
Replaces surrogate characters before rendering log text. |
README.md |
Documents harness targets and fuzzing commands. |
fuzz/harness_support.py |
Shares seed setup, text decoding, and UTF-8 checks. |
fuzz/fuzz_review_classifier.py |
Fuzzes review verdicts, text handling, and section counts. |
fuzz/fuzz_proposal_rules.py |
Fuzzes proposal validation, text sanitizers, and manifest parsing. |
fuzz/fuzz_operator_input.py |
Fuzzes issue references and author allow-list parsing. |
Review effort: Balanced
6777a96 to
0fb2a27
Compare
0fb2a27 to
19ada16
Compare
19ada16 to
bf09638
Compare
There was a problem hiding this comment.
🤖 Antagonistic review by agent: 1 finding(s) for the human reviewer.
The surrogate fixes look sound. The new masking oracle misses violations of its stated contract, weakening the fuzz coverage.
Antagonistic round 1 of 3. Revision requested from Code Monkey.
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.
bf09638 to
bea5eae
Compare
bea5eae to
d81161f
Compare
d81161f to
6186f15
Compare
6186f15 to
0312bc5
Compare
There was a problem hiding this comment.
🤖 Antagonistic review by agent: 1 finding(s) for the human reviewer.
The surrogate fixes are narrowly scoped, but the new fenced-body oracle can report a false failure when oversized input contains lone surrogates.
Antagonistic round 2 of 3. Revision requested from Code Monkey.
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.
A manifest reason is JSON, which can carry a lone surrogate such as "\ud800". The publisher writes every reason through log_safe to the job summary with a strict UTF-8 write, so such a reason raises UnicodeEncodeError and stops the publisher instead of rejecting the proposal. The fuzz harness for the proposal rules found it. Mark the test as an expected failure until the fix lands. 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>
Replace each lone surrogate with U+FFFD after flattening, so a manifest reason that JSON decoded to one no longer raises when the publisher writes it to the job summary or log. Drop the expected failure marker from the regression test. Review: the aislop gate flagged proposal_policy.py as too large once this fix added lines past its budget; the fix now replaces lines in place and the file keeps its length. 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 three Atheris harnesses under fuzz/, one per area the pipeline
reads from outside: the proposal rules and manifest reader, the
Copilot review classifier, and the operator's issue and author
lists. Each fuzzes a plain check(data) function whose oracles derive
the expected answer from the raw input and the contract the code or
docs/DESIGN.md states, and ships its seeds as Python literals.
tests/test_fuzz_harnesses.py replays every seed in the normal suite
without Atheris, and shows each oracle catches a wrong result. The
README says how to run a harness and replay a crash input.
Review round 2:
- The manifest oracle compared only the returned keys, so a result
with the file's keys but another repository, issue or schema
passed. It now compares the whole returned object with the file's
own JSON, serialised so a NaN still equals itself.
- oracle_message, oracle_manifest and oracle_twin had no negative
control. The suite now feeds each a deliberately wrong result,
including the corrupted manifest above.
Review round 3:
- oracle_verdict accepted any green or blue h3 as a clean
assessment, so a classifier that approved "### 🟢 This is not a
recognized assessment" passed. It now checks, without the module's
patterns, for an h3 stating one of the three phrases review_verdict
documents, and that the recorded assessment is that heading's
label. The fabricated heading, a wrong colour, a phrase run on and
a mismatched label join the negative controls.
Review round 4 (antagonistic review):
- oracle_mask let a change through wherever some backtick stood on
either side, and never required a span to be blanked, so a mask
that changed nothing and one that blanked the prose between two
spans both passed. It now pairs backtick runs itself, as
mask_spans documents ("two runs of equal length bound a span"),
and requires the exact line: each closed span blanked by "x" or,
a path and line number, kept; everything outside spans as
written; and left_open set just when a run has no partner. Five
negative controls, the two above among them, fail against the old
oracle.
Review round 5:
- oracle_mask never checked the third value mask_spans returns, so a
span that reads as an entry but cannot be kept, such as
**`src/x.py:12 `**, passed blanked with unkept False; and
oracle_line accepted an empty problem set, so a read_line that hid
a suppressed finding passed. The oracle now derives the unkept flag
from the raw spans, and oracle_line requires the masked line and
the code span reason exactly when a span is left open or unkept or
a backtick is escaped. Six negative controls, all passing the old
oracle, and a seed for these lines are added.
Review round 6:
- oracle_verdict read clean headings as a set, so a classifier that
approved "### 🟡 Changes recommended" followed by an approval h3
passed, and it never forced a count, so a clean verdict with zero
counts on "### Suppressed comments (1)" passed. check_classify now
puts sections it writes itself before each body: a changes h3,
which must read as changes, and a suppressed heading and a
previously missed summary stating 1 to 9 findings, which must
count at least that. Each must give findings. Four negative
controls and two seeds are added; classifiers that pick the latest
heading or count zero now fail on the seeds.
Review round 7:
- oracle_verdict looks for clean headings without reading fences, so
a classifier that stopped dropping fenced code and approved a body
holding only a fenced approval h3 passed. check_classify now also
classifies each body inside a backtick fence longer than any run
in it, which no line can close, and requires no assessment, no
count and findings. Three negative controls and a fenced-approval
seed are added; with fence detection disabled, 16 seeds now fail.
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>
A review body arrives as JSON, which can carry a lone surrogate such as "\ud800". review_verdict.bounded measured the body with a strict UTF-8 encode, so classify raised UnicodeEncodeError on it instead of returning a verdict, breaking its contract to classify any body. The review classifier harness found it on b"\x00\x00\xed\xa0\x80". Count the body with surrogatepass, so a lone surrogate weighs the three bytes it decoded from and the 64 KiB bound still holds. Add a regression test, and the reproducing input to the harness's seeds. Review: Copilot thread on fuzz/fuzz_review_classifier.py (lone surrogate raises UnicodeEncodeError) is fixed here. Review (antagonistic round 2): the fenced variant in check_classify measured backtick runs before bounded drops a lone surrogate from an oversized body, so two runs could join and close the fence early; a body with "`\ud800`\ud800`" over 64 KiB then stopped the fuzzer on a false failure. fenced now measures runs without surrogates, and that input joins the seeds. 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>
0312bc5 to
517052f
Compare
There was a problem hiding this comment.
🤖 Antagonistic review by agent: no line-level findings; the summary below is the verdict.
The surrogate fixes are narrowly scoped, and the fuzz harnesses look consistent with the contracts they exercise. No actionable defects found in this diff.
Antagonistic round 3 of 3. That is the last one: a maintainer takes it from here.
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. log_safe replaces lone surrogates with U+FFFD and review_verdict counts a body's bytes with surrogatepass, so untrusted text with lone surrogates no longer crashes logging or classification; the rest is fuzz harnesses and tests, with no workflow changes.
ae28d1a
into
lfreleng-actions:main

Closes #205
Authored by an AI agent; human review required
claude-opus-5.5via GitHub Copilot CLIaf18f713e4cf73e0aad08da35c38340bd05ffac0uv run python -B -m unittest discover -s testsAISLOP_NO_TELEMETRY=1 prek run --files fuzz/fuzz_review_classifier.pygit commit -s --amend -F msg.txt (gitlint commit-msg hook)git log --raw --format=%h af18f713e4cf73e0aad08da35c38340bd05ffac0..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 8 of revision, on its base. It answers antagonistic review round 2: #206 (review).
Adds three Atheris fuzz harnesses under
fuzz/(proposal rules and manifest reader, Copilot review classifier, operator issue and author lists). The normal suite replays each harness's seeds intests/test_fuzz_harnesses.pyand feeds each oracle a deliberately wrong result. Fixes two lone-surrogate crashes the harnesses found:log_safeoutput not encodable as UTF-8, andreview_verdict.boundedraisingUnicodeEncodeError.This round
fenced()measured backtick runs on the raw body, butreview_verdict.boundeddrops lone surrogates when it cuts an oversized body, which can join two runs and close the wrapper's fence early.fenced()now measures runs with surrogates removed, so the fence outlasts every run the classifier can see. The reviewer's reproducer (`\ud800`\ud800`then an approval h3, over 64 KiB) is added as a seed. It fails against the old oracle. Amended intoFix: Classify review bodies with lone surrogates.Antagonistic review
Round 2 had one finding, the inline thread above, and it is fixed. The summary held no other finding.
Checks run
uv run python -B -m unittest discover -s tests: 1598 tests, OKprek run --files fuzz/fuzz_review_classifier.py: all hooks pass, aislop includedFor the reviewer
Atheris was not available in this round's session. The changed oracle was checked by seed replay only. Earlier rounds fuzzed each harness for 60 to 90 s with no findings.