Skip to content

Test: Fuzz untrusted input, fix surrogate crashes - #206

Merged
ModeSevenIndustrialSolutions merged 4 commits into
lfreleng-actions:mainfrom
lfreleng-bot-forks:code-monkey/issue-205
Nov 19, 2026
Merged

ModeSevenIndustrialSolutions merged 4 commits into
lfreleng-actions:mainfrom
lfreleng-bot-forks:code-monkey/issue-205

Conversation

@lf-releng-code-monkey-bot

@lf-releng-code-monkey-bot lf-releng-code-monkey-bot Bot commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

Closes #205

Authored by an AI agent; human review required
Command Exit
uv run python -B -m unittest discover -s tests 0
AISLOP_NO_TELEMETRY=1 prek run --files fuzz/fuzz_review_classifier.py 0
git commit -s --amend -F msg.txt (gitlint commit-msg hook) 0
git log --raw --format=%h af18f713e4cf73e0aad08da35c38340bd05ffac0..HEAD 0

The github-code-monkey-bot workflow 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 in tests/test_fuzz_harnesses.py and feeds each oracle a deliberately wrong result. Fixes two lone-surrogate crashes the harnesses found: log_safe output not encodable as UTF-8, and review_verdict.bounded raising UnicodeEncodeError.

This round

fenced() measured backtick runs on the raw body, but review_verdict.bounded drops 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 into Fix: 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, OK
  • prek run --files fuzz/fuzz_review_classifier.py: all hooks pass, aislop included
  • gitlint on the amended commit: pass

For 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.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 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_safe regression 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

Comment thread fuzz/fuzz_review_classifier.py Resolved
@lf-releng-code-monkey-bot lf-releng-code-monkey-bot Bot changed the title Test: Fuzz untrusted input and fix log_safe Test: Fuzz untrusted input, fix surrogate crashes Nov 19, 2026

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The manifest oracle can miss incorrect returned values, and missing negative controls leave three oracles untested for rejecting deliberately wrong results.

2 open issues

Review effort: Balanced

Comment thread fuzz/fuzz_proposal_rules.py Resolved
Comment thread tests/test_fuzz_harnesses.py Resolved

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The fuzz oracle accepts arbitrary green or blue headings as valid assessments, allowing fabricated approvals and classifier regressions to pass undetected.

1 open issue

Review effort: Balanced

Comment thread fuzz/fuzz_review_classifier.py Resolved

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues block the added fuzz coverage and lone-surrogate handling fixes.

No open issues 🎉

Review effort: Balanced

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤖 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.

Comment thread fuzz/fuzz_review_classifier.py Resolved

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The fuzz oracle can miss silently suppressed findings because it accepts unsafe entry spans as preserved and allows an empty problem set, requiring stricter checks and negative-control tests.

1 open issue

Review effort: Balanced

Comment thread fuzz/fuzz_review_classifier.py Resolved

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The fuzz oracle accepts fabricated clean verdicts despite positive-count finding sections or an earlier changes heading, leaving dropped findings and heading-order regressions undetected.

2 open issues

Review effort: Balanced

Comment thread fuzz/fuzz_review_classifier.py Resolved
Comment thread fuzz/fuzz_review_classifier.py Resolved

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The fuzz harness lacks an independent fenced-input check, allowing a classifier regression that treats fenced approval headings as clean to pass without a targeted seed and negative-control test.

1 open issue

Review effort: Balanced

Comment thread fuzz/fuzz_review_classifier.py Resolved

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues are recorded for the fuzz-coverage additions and surrogate-handling fixes.

No open issues 🎉

Review effort: Balanced

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤖 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.

Comment thread fuzz/fuzz_review_classifier.py Resolved
lf-releng-code-monkey-bot Bot and others added 4 commits November 19, 2026 19:44
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>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues remain for the fuzz-coverage additions and lone-surrogate handling fixes.

No open issues 🎉

Review effort: Balanced

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤖 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 zxiiro left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤖 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.

@ModeSevenIndustrialSolutions
ModeSevenIndustrialSolutions merged commit ae28d1a into lfreleng-actions:main Nov 19, 2026
32 checks passed
@ModeSevenIndustrialSolutions
ModeSevenIndustrialSolutions deleted the code-monkey/issue-205 branch November 19, 2026 20:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

code-quality Updates to code-quality

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Test: Fuzz the proposal and review readers

3 participants