Skip to content

Test: Fuzz the proposal and review readers #205

Closed

Description

This was generated by AI during triage.

Summary

Add fuzz harnesses, written for Atheris, for the code in this repository that reads input it does not control. The publish job decides what an untrusted author session may publish. Its checks on that session's manifest and commits are the trust boundary docs/DESIGN.md describes, and it also classifies the review text Copilot writes.

Why

  • These functions stand between an agent session that an issue may have steered and a signed commit on a pull request.
  • The first harnesses in grype-scan-action led to two fixes in the code they exercised (Test: Fuzz the SBOM and bypass parsers in CI grype-scan-action#70).
  • OpenSSF Scorecard scores Fuzzing 0 here, and a harness is worth about 0.5 on the aggregate. Scorecard finds Python fuzzing by the text import atheris in a .py file. That is its detection rule, not the goal: a harness that cannot fail does not satisfy this issue.

How the harnesses will run

A daily job in lfreleng-actions/.github will run every harness in the organisation and publish failures to each repository's code scanning (lfreleng-actions/.github#373, tracked in lfreleng-actions/.github#372). Until it is live, the seeds replay in this repository's own test suite. So this change adds no workflow: it is being worked with workflow edits off, and nothing under .github/workflows/ may change.

Harness contract, version 1 (Python)

  1. Discovery. A harness is a tracked .py file with a line containing import atheris. OpenSSF Scorecard and the central job both find harnesses by that text, so it appears in harness files and in no other .py file, comments and strings included.

  2. Invocation. The central job runs a harness from the repository root, on Linux x86_64 with CPython 3.13:

    • python <harness> [libFuzzer options] [directory ...] fuzzes. libFuzzer writes the inputs it keeps to the first directory.
    • python <harness> [libFuzzer options] <file> [<file> ...] runs each named input once and exits.

    The harness puts whatever it imports on sys.path itself.

  3. Seeds. Unless an argument names an existing file, the harness appends a directory holding its seed inputs after any directories it was given. Run with no arguments, it fuzzes from its seeds.

  4. Verdict. An input that breaks the contract under test raises out of the fuzzed function, and the process exits non-zero. A run in which every input held exits 0. The verdict depends on the input alone: no clock, randomness, network, credential or environment variable, and no file outside a temporary directory.

  5. Limits. Each input finishes within 10 seconds and 2 GiB of memory. libFuzzer sizes the inputs it generates from the largest seed, so a target that needs long inputs carries a seed that long.

  6. Imports. The standard library, the repository's own code, the packages uv sync --frozen installs from the repository's uv.lock, and atheris. A repository without uv.lock gets the first two and atheris.

  7. Without Atheris. import atheris sits inside the function that starts fuzzing, so the module imports on any platform. The check being fuzzed is a plain function, and the repository's unit suite runs every seed through it.

  8. Nothing else. The repository carries no fuzz workflow, no Atheris pin and no Dependabot entry for one. The central job brings its own pinned Atheris.

Targets

Write one to three harnesses, one per area below, in the order given. The names come from the modules' own docstrings and signatures; read the code before settling the contract each harness checks, and say in the pull request which candidates you left out and why.

  1. Proposal rules. proposal_policy: safe_path, protected, check_change_mode, split_message, check_headline, check_body, comment_safe, defuse_mentions, log_safe, bounded_reasons; and proposal_check.read_manifest.

    Properties to consider, each to be confirmed against docs/DESIGN.md: a refusal is a Rejection or a PublishError and never another exception; no spelling of a protected path gets past protected; a path safe_path accepts stays inside the checkout; text that has been through comment_safe or defuse_mentions holds no live @mention; log_safe output cannot start a workflow command.

  2. Review classification. review_verdict.classify, review_text (read_line, mask_spans) and review_sections (suppressed_count, previously_missed_count, unknown_sections). A review body is external text. Property to consider: classify returns a verdict for any body and never raises.

    review_text, review_sections and review_verdict also exist in github-code-review-bot. If they are copies, say so in the pull request; plan no change to the other repository.

  3. Operator and issue input. explicit_issues.parse_issues and issue_authors.parse_listed.

Rules for the oracles

  • Check what the code documents, in its own words: quote the docstring, README or design text in the harness.
  • No broad except around the code under test. An exception the code documents is part of the contract and may be expected by name.
  • Drive each target at the level where its contract holds. Where a caller catches an exception by design, fuzz the caller.
  • The oracle must not share the code it checks. Derive the expected answer from the raw input independently, or check a property such as a round trip, idempotence or containment. In grype-scan-action, review found oracles that trusted the answer they were checking, and so passed wrong ones.
  • Capture output as production emits it. There, a buffer that accepts any text hid an encoding error that a strict UTF-8 stream raises.
  • Show each oracle can fail. The replay test swaps in a deliberately wrong result and checks the oracle rejects it.
  • When a harness shows the code breaking its documented contract, fix it in this pull request, in its own commit, with a regression test and the failing input added to the seeds. If the fixes would not fit, leave that target out and give the reproducing input in the pull request body.

Constraints

  • No dependency changes. Atheris is not a dependency of this repository: no pin, no lock entry, no Dependabot entry. Install it for your own runs only; pip install atheris works on Linux x86_64 with CPython 3.12 to 3.14.
  • Hooks as configured. The new files pass the repository's hooks unchanged, in an environment where Atheris is not installed. mypy and basedpyright run in strict mode, and the aislop gate holds at 100.
  • The normal suite runs the replay test. python -B -m unittest discover -s tests collects test*.py, in CI and in a hook.
  • REUSE. Every new file carries an SPDX header or a .license sidecar. Seeds can live as literals in a Python module.
  • Fuzz before you finish. Run each harness under Atheris for at least a minute and report what it did.
  • Bot-specific modules alone. The five modules shared with lfreleng-actions/bots-template (bot_github.py, bot_evidence.py, artifact_fetch.py, preflight.py, ledger.py) are covered by Test: Fuzz the shared bot modules bots-template#63. This repository's AGENTS.md forbids patching a copy alone.
  • Leave the workflow contract tests alone. They pin the trust boundary.

Acceptance criteria

  • One to three harness files, each meeting the contract above. python <harness> -runs=0 exits 0, and so does python <harness> <file> for a seed written to a file.
  • The text import atheris appears in the harness files and in no other .py file.
  • Each harness names the contract it checks, and none has a broad except around the code under test.
  • A test in the normal suite replays every seed through each check without Atheris installed, and shows each oracle rejecting a deliberately wrong result.
  • The repository's tests and hooks pass. Nothing under .github/workflows/ changes, and no dependency, lock file, coverage threshold or hook configuration changes.
  • The README, or the developer documentation the repository keeps, says in a few lines what is fuzzed and how to run a harness by hand.
  • The pull request body gives, for each harness, how long it fuzzed, how many inputs it ran and what it found. Each defect found is fixed with a regression test, or listed with its reproducing input.

Out of scope

  • A fuzz workflow or CI job, an Atheris pin and a Dependabot entry: the central job supplies all three.
  • Property-based testing libraries.
  • Behaviour changes beyond fixing a breach of a documented contract.
  • The five shared modules.

Activity

  1. lf-releng-code-monkey-bot commented on Nov 19, 2026

    @lf-releng-code-monkey-bot
    Contributor

    🐒 An AI agent has proposed a change for this issue: pull request #206 (head 6777a96). The Copilot review of it has findings (1 unresolved review thread; assessment: changes recommended). 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. Checks failed on its head: Audit changes.

  2. lf-releng-code-monkey-bot commented on Nov 19, 2026

    @lf-releng-code-monkey-bot
    Contributor

    🐒 Round 1: an AI agent revised pull request #206 (head 0fb2a27). Round 1 on #206. - Fixed Copilot's thread: review_verdict.bounded raised UnicodeEncodeError on a lone surrogate. New commit Fix: Classify review bodies with lone surrogates counts the body with surrogatepass, adds a regression test and the reproducer seed. - Fixed the failing Audit changes check (aislop file-too-large on scripts/proposal_policy.py): amended the log_safe fix commit to change lines in place, file stays at 440 lines; aislop scan of the change is clean. - No rebase: the branch stays on af18f71, which is the default branch head and the PR is mergeable. - Ran the full unit suite and prek on changed files (both pass) and fuzzed all three harnesses 60–90 s each with no findings. - Nothing disputed; nothing remains open from this round. It set out to fix the failing checks: Audit changes. The Copilot review of it has findings (2 unresolved review threads; assessment: changes recommended). 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.

  3. lf-releng-code-monkey-bot commented on Nov 19, 2026

    @lf-releng-code-monkey-bot
    Contributor

    🐒 Round 2: an AI agent revised pull request #206 (head 19ada16). Round 2 on #206. - Fixed both Copilot threads, amending Test: Add fuzz harnesses for untrusted input: - oracle_manifest compared only keys; it now compares the full returned object with the file's JSON. - Added negative controls for oracle_message, oracle_manifest (corrupted repository/issue/schema) and oracle_twin; the new manifest cases fail against the old oracle. - No rebase: the branch stays on af18f71, the default branch head; the PR is mergeable and nobody asked for one. - No failing checks on the head. Ran the full unit suite, prek on the changed files and gitlint (all pass), and fuzzed each harness 66–76 s with no findings. - Nothing disputed; nothing open from this round.. The Copilot review of it has findings (1 unresolved review thread; assessment: changes recommended). 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.

  4. lf-releng-code-monkey-bot commented on Nov 19, 2026

    @lf-releng-code-monkey-bot
    Contributor

    🐒 Round 3: an AI agent revised pull request #206 (head bf09638). Round 3 on #206. - Fixed Copilot's thread on fuzz/fuzz_review_classifier.py: oracle_verdict now accepts a clean verdict only when an h3 states one of the three assessment phrases review_verdict documents and the recorded label matches it. It checks this independently of the module's regexes. Four new negative controls, the fabricated ### 🟢 This is not a recognized assessment among them, fail against the old oracle. Amended into Test: Add fuzz harnesses for untrusted input. - No rebase: the branch stays on af18f71, the default branch head. The PR is mergeable and nobody asked for one. - No failing checks on the head. The full unit suite, prek on the changed files and gitlint all pass. The classifier harness ran 71 s (19,237 inputs) under Atheris and found nothing. - Note: the Atheris scratch venv and corpus are in the artefacts directory. Writes to /tmp were refused, apart from one scratch file and a venv I created there before the refusal. - Nothing disputed; nothing open from this round.. The Copilot review of it is clean. An antagonistic review was requested from the review bot.

  5. lf-releng-code-monkey-bot commented on Nov 19, 2026

    @lf-releng-code-monkey-bot
    Contributor

    🐒 Round 4: an AI agent revised pull request #206 (head bea5eae). Round 4 on #206, answering the antagonistic review. - Fixed the thread on fuzz/fuzz_review_classifier.py: oracle_mask passed a mask that changed nothing and one that blanked prose between spans. It now pairs backtick runs itself ("two runs of equal length bound a span") and requires the exact masked line, keeping path-and-line entry spans, plus the right left_open. Five new negative controls fail against the old oracle. Amended into Test: Add fuzz harnesses for untrusted input. - No rebase: the branch stays on af18f71, the default branch head; the PR is mergeable and nobody asked for one. - No failing checks. Unit suite, prek on changed files and gitlint pass; 300,000 random lines agree with mask_spans. Atheris was not run this round (no venv available). ## Antagonistic review The body holds no finding beyond its one inline thread (the oracle_mask weakness), fixed below. Its summary judged the surrogate fixes sound; nothing to change there. It answers antagonistic review round 1 (#206 (review)). The Copilot review of it has findings (1 unresolved review thread; assessment: changes recommended). 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.

  6. lf-releng-code-monkey-bot commented on Nov 19, 2026

    @lf-releng-code-monkey-bot
    Contributor

    🐒 Round 5: an AI agent revised pull request #206 (head d81161f). Round 5 on #206. - Fixed Copilot's thread on fuzz/fuzz_review_classifier.py. oracle_mask now derives the unkept flag from the raw spans. oracle_line now requires the expected masked line, plus the code span reason exactly when a span is left open or unkept or a backtick is escaped. Six new negative controls (**`src/x.py:12 `** among them) all pass the old oracle and fail the new one, and a new seed covers these lines. Amended into Test: Add fuzz harnesses for untrusted input. - No rebase: the branch stays on af18f71, which is the default branch head. The PR is mergeable and nobody asked for a rebase. - No failing checks. The full unit suite, prek on the changed files and gitlint pass. A 300,000-line random differential check agrees with mask_spans/read_line. - Atheris installed, but the session refused to run it. This round's change was not fuzzed under Atheris. - Nothing disputed; nothing open from this round.. The Copilot review of it has findings (2 unresolved review threads; assessment: changes recommended). 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.

  7. lf-releng-code-monkey-bot commented on Nov 19, 2026

    @lf-releng-code-monkey-bot
    Contributor

    🐒 Round 6: an AI agent revised pull request #206 (head 6186f15). Round 6 on #206. - Fixed both Copilot threads on fuzz/fuzz_review_classifier.py. oracle_verdict read clean headings as a set and never required a count, so a clean verdict passed for an approval h3 after a changes h3, or for a body with ### Suppressed comments (1). check_classify now prefixes each body with a section the harness writes itself: a 🟡 Changes recommended h3, which must read as changes, and a suppressed heading and a previously missed summary that state 1 to 9 findings, which must count at least that many. Each prefixed body must give findings. Four negative controls and two seeds are added. Amended into Test: Add fuzz harnesses for untrusted input. - No rebase: the branch stays on af18f71, which is the default branch head. The PR is mergeable and nobody asked for a rebase. - No failing checks. The full unit suite, prek on the changed files and gitlint all pass. - Atheris installed, but the session refused to run it. This round's change was not fuzzed under Atheris. - Nothing disputed; nothing from this round remains open.. The Copilot review of it has findings (1 unresolved review thread; assessment: changes recommended). 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.

  8. lf-releng-code-monkey-bot commented on Nov 19, 2026

    @lf-releng-code-monkey-bot
    Contributor

    🐒 Round 7: an AI agent revised pull request #206 (head 0312bc5). Round 7 on #206. - Fixed Copilot's thread on fuzz/fuzz_review_classifier.py. oracle_verdict finds 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. That must give no assessment, no counts and findings. Added a fenced-approval seed and three negative controls for oracle_fenced. With FENCE_OPEN disabled, 16 seeds now fail. Amended into Test: Add fuzz harnesses for untrusted input. - No rebase: the branch stays on af18f71, which is the default branch head. The PR is mergeable and nobody asked for a rebase. - No failing checks. The full unit suite, prek on the changed files and gitlint all pass. - Atheris was not run this round. The seeds and the mutation check ran without it. - Nothing disputed; nothing from this round remains open.. The Copilot review of it is clean. An antagonistic review was requested from the review bot.

  9. lf-releng-code-monkey-bot commented on Nov 19, 2026

    @lf-releng-code-monkey-bot
    Contributor

    🐒 Round 8: an AI agent revised pull request #206 (head 517052f). Round 8 on #206, answering antagonistic review round 2. - Fixed the thread on fuzz/fuzz_review_classifier.py: 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. Reproduced the false Breach first. The reviewer's input is now a seed: it fails against the old fenced() and passes now. Amended into the tip commit Fix: Classify review bodies with lone surrogates, which introduced the surrogate path. - No rebase: the branch stays on af18f71, the default branch head. The PR is mergeable and nobody asked for a rebase. - No failing checks. The full unit suite (1598 tests), prek on the changed file (aislop included) and gitlint pass. - Atheris was not available this round, so the harness was not fuzzed under it. The seeds ran without it. ## Antagonistic review The body holds no finding beyond its one inline thread (the false failure in the fenced oracle), fixed above. It answers antagonistic review round 2 (#206 (review)). The Copilot review of it is clean. An antagonistic review was requested from the review bot.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions