Repository navigation
Fix: Keep kept-link schemes and tighten oracles - #125
ModeSevenIndustrialSolutions merged 4 commits into
Conversation
There was a problem hiding this comment.
🟡 Changes recommended
A critical containment bypass leaves a trailing external autolink live, and fuzz oracles miss that regression while also accepting altered queries and invalid exact-limit truncation.
3 open issues
What changed in this PR
This PR addresses #123 by preserving schemes embedded in allowed organisation URLs and tightening the fuzz checks that validate sanitisation and comment rendering.
Changes:
- Preserve embedded schemes within kept organisation links and document the rule.
- Tighten checks for truncation, colon-pair spacing, link preservation, and code-block retention.
- Add regression cases, wrong-result tests, and fuzz seeds for the reported failures.
| File | Description |
|---|---|
tests/test_review_policy.py |
Tests embedded schemes and standalone URL containment. |
tests/test_fuzz_harnesses.py |
Adds negative controls and boundary cases for the oracles. |
tests/test_comment_review.py |
Updates expectations for truncating a kept URL run. |
scripts/review_policy.py |
Preserves later schemes within a kept URL run. |
fuzz/sanitised_text.py |
Tightens colon-spacing and truncation checks. |
fuzz/github_markdown.py |
Models embedded schemes and detects altered kept links. |
fuzz/fuzz_verdict.py |
Adds link-preservation checks and stricter length validation. |
fuzz/fuzz_comment.py |
Refines code-retention bounds and checks kept links. |
docs/DESIGN.md |
Documents preservation of schemes inside allowed URLs. |
Review effort: Balanced
95e32ee to
78d5920
Compare
78d5920 to
ade1d0c
Compare
ade1d0c to
ee703cf
Compare
Add tests for six wrong results the issue reports: a scheme inside a kept organisation link broken by contain_links, and fuzz oracles that accept a colon mark outside a "::" pair, an uncut text over the limit, a cut text that fits it, "&" growth beside code and outer whitespace counted against the comment limit. Each is marked as an expected failure until the fix that makes it pass. Two existing tests change: one relied on the loose cut oracle accepting a cut that sanitise never makes, and one asserted that a scheme inside a single run of organisation URLs breaks. Both pass before and after the fixes. Review round: Copilot reported three more wrong results, now tested here too. The kept-link test adds a scheme after a backtick and after an ASCII letter, which GitHub links on its own; the contained oracle test adds those and a scheme left whole behind two ZWSPs; the cut test adds an exact-limit text whose cut eats its last mark. Round two: Copilot found the oracle blind to a kept link that loses its own scheme, as it then links nowhere in the result. The contained oracle test now breaks the outer scheme of a kept link, alone and with the inner one, through both harnesses, and checks that links containment may break (a dot segment, no slash after the organisation, a letter before the scheme) still pass. Round three: Copilot found a cut one short of the limit accepted when the source's space came right after a "@" or "<", though sanitise keeps the zero-width space due there. The cut test now checks that boundary and the inputs either side of it. Round four: Copilot found the oracle blind to a mark between two characters of a scheme inside a kept link, and to two links containment keeps that the source-side check skipped: one after a dot segment earlier in the run, and a bare organisation root. The contained oracle test now breaks each, through both harnesses, and checks that a dot segment after the scheme, or a quote or a backtick after the root, still lets containment break the link. 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>
contain_links broke every scheme in a run, so a scheme inside an organisation URL it keeps, as in search?q=ftp://server, gained a zero-width space and the link no longer read as written. GitHub links the whole run to the next whitespace, so once a scheme stays, every later scheme in the same run is part of that link and stays too. Both fuzz harnesses now check that each link contain_links keeps reads as the source wrote it, and seed the reported input. DESIGN.md records the rule. Review round, two Copilot findings on this change: - contain_run kept every later scheme in a run once a kept link began, so a scheme after a backtick, which may close a code span, or after an ASCII letter, which GitHub links on its own, stayed live. A kept link now reaches only to the next backtick, and only when no ASCII letter precedes it (LINKED_RE). The autolinks oracle gives each kept link the same reach, and altered_links checks the schemes inside it against the written text, so the oracle no longer hides such a scheme. - SCHEME_MARK removed one ZWSP only, so a scheme behind two ZWSPs in the result passed as unaltered. It now removes a run of them. Round two, one Copilot finding: altered_links read kept links from the result alone, so breaking a kept link's own scheme, with or without the scheme inside it, left no link to check and both harnesses passed. It now also reads them from the source: a link there naming https://github.com/<org>/ in a run with no dot segment, which contain_links always keeps, must read as written in the result. Round four, two Copilot findings: - SCHEME_MARK kept a mark only after a scheme's colon, so one between "f" and "tp" in a kept link's query passed. It now keeps marks between any two characters of a scheme, "://" included. - The source-side check skipped a whole run holding a dot segment, though containment ignores one before a URL's scheme, and wanted a slash after the organisation, though containment keeps a root with only trailing punctuation after it. always_kept now looks for a dot segment from the scheme on, and accepts that root. 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>
The verdict harness accepted three wrong results from sanitise. A colon mark passed wherever a colon came next, not only inside a "::" pair the source wrote. A match uncut passed at any length, even past the limit. A prefix one short of the limit passed as a cut even where rstrip had taken no space. one_line also let any text run three characters past the limit, cut or not. The oracle now allows a colon mark only inside a source "::" pair, holds an uncut text to the limit, and takes a short cut only where rstrip took the source's space or a mark's. one_line allows the extra three characters only to a cut ending in "...". A seed carries the reported run of colons. Review round, one Copilot finding on this change: at the exact limit verify_text asked zwsp_due whether a mark was still owed, but a cut whose kept text already ends on that mark owes none, so a whole 600-character text with "..." appended passed. mark_left now asks whether the kept text still lacks the mark. Round three, one Copilot finding: a cut one short of the limit took the source's next space as the character rstrip removed, even where a zero-width space came first. For "a" * 598 + "@ b" it accepted "a" * 598 + "@..." though sanitise keeps "@" and the mark. space_cut now refuses the cut while mark_left finds that mark still owed. 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>
verify_code_kept skipped bodies it should have checked. Its growth bound let "&" grow by four characters, but disarm_html leaves an "&" as written. It also counted outer whitespace against the limit, though comment_text strips that whitespace before it fits the body. Either way, a body sure to keep its code went unchecked. The ENTITY pattern now skips "&", and the bound measures the stripped body. The code blocks are still read from the body before the strip, as the scanner reads them. Seeds carry both reported inputs. Review round three, one Copilot finding: the stripped-length bound admits a long blank suffix, which written_code then rescanned for every unclosed opener. Round four, one more: a long closing line, spaces then a U+3000, was rescanned the same way. written_code now reads each line once, from the last back, keeping the nearest closer for each fence character and width, so no opener rescans the lines after it. A closer still allows only blanks and tabs after its run, so a U+3000 there leaves the line prose, as comment_text reads it; Copilot's round-three suggestion of text.rstrip() would have made it a closer. A test times both shapes; being a timing test, it lands with the fix rather than as an expected failure. 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>
ee703cf to
b82f190
Compare
There was a problem hiding this comment.
🔵 Needs a closer look
Human validation is needed because the revised Markdown containment boundary and offline oracles share assumptions about GitHub autolink and code-span behavior without independently testing GitHub rendering.
No open issues 🎉
Review effort: Balanced
There was a problem hiding this comment.
🤖 Antagonistic review by agent: no line-level findings; the summary below is the verdict.
The containment change and tightened fuzz oracles appear sound on static review. No actionable defects found in the diff or its dependent call sites.
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.
6123df8
into
lfreleng-actions:main


Closes #123
Authored by an AI agent; human review required
claude-opus-5.5via GitHub Copilot CLI3c9f13f41f1731c08e89d57533fbe219a0458d1auv run python -B -m unittest discover -s tests (at 16908dd, c79e4c6, f00d848, db26ee4)uv pip install atherisuv run --no-sync python fuzz/fuzz_verdict.py -max_total_time=60uv run --no-sync python fuzz/fuzz_comment.py -max_total_time=60uv run python -B -m unittest discover -s testsuvx --from gitlint-core gitlint --commits 3c9f13f..HEADprek run --files docs/DESIGN.md fuzz/fuzz_comment.py fuzz/fuzz_verdict.py fuzz/github_markdown.py fuzz/sanitised_text.py scripts/review_policy.py tests/test_comment_review.py tests/test_fuzz_harnessesThe
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 4 of revision, on its base.
Fixes #123: the six findings Copilot left on #112, plus the review rounds on this pull request.
What it does
contain_links(scripts/review_policy.py) no longer breaks a scheme inside an organisation URL it keeps. A kept link reaches to the next backtick, and only when no ASCII letter comes before it. A standaloneftp://,http://orhttps://URL is still broken.docs/DESIGN.mdrecords the rule.fuzz/github_markdown.py) check that each kept link reads as the source wrote it. They look at links kept in the result and links containment always keeps in the source. A zero-width space anywhere inside a scheme counts as an alteration.fuzz/sanitised_text.pynow accepts colon marks only inside source::pairs. An uncut text must fit the limit, and a short cut is allowed only whererstriptook a space.fuzz/fuzz_comment.pydoes not count&or outer whitespace as growth.written_codereads each line once, so it stays linear.This round (4)
SCHEME_MARKkeeps marks between any characters of a scheme, softp://inside a kept link is caught.always_keptchecks a source link after an earlier dot segment, and the bare roothttps://github.com/<org>followed only by trailing punctuation.written_codefinds each opener's closer from a single backward pass. A long closing line is no longer rescanned for every opener.Every new negative control fails against the previous oracle, and each nearby input that containment breaks still passes.
What I ran
uv run python -B -m unittest discover -s testsat every commit: exit 0.prek run --files <changed files>(aislop included): exit 0.gitlint --commits 3c9f13f..HEAD: exit 0.fuzz_verdict.pyran 71,942 inputs andfuzz_comment.pyran 9,219, with no failures.altered_linksagainstcontain_linksfound no false alarms. 300k inputs compared the newwritten_codewith the old scan and found no difference.For the reviewer
always_keptmirrorscontain_run's rule, using the oracle's looser dot-segment pattern. When the two disagree, the oracle skips a link rather than flagging it. Nothing under.github/workflows/changes.