security-guidance: resolve review paths against the repo root and harden the findings-array contract#76274
Open
ss251 wants to merge 2 commits into
Open
security-guidance: resolve review paths against the repo root and harden the findings-array contract#76274ss251 wants to merge 2 commits into
ss251 wants to merge 2 commits into
Conversation
… findings array Normalize changed-file paths in the security reviewer prompts: resolve relative paths against the active worktree root, recover root-anchored and foreign-checkout paths via existing repo suffix, exclude unresolved paths from the readable list, and state the absolute repo root in the prompt. Require the structured findings field to be a JSON array for zero, one, or many results. Fixes the first-Read-always-fails and foreign-path Read loops (anthropics#74200, anthropics#73271). AI-assisted (Codex gpt-5.6-terra worker, Claude-supervised). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01J8NGaAFCBE4HLGLojEwvvy
…ngleton findings Address cross-provider review: never map foreign paths on a bare basename match (wrong-file false confidence); normalize a singleton findings object to a one-item list at both consumption sites; make the empty-readable-paths prompt wording accurate. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01J8NGaAFCBE4HLGLojEwvvy
This was referenced Jul 10, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
/TaxEngine/Package.swift), and foreign absolute paths from other machines (/home/user/...,/Users/<other-dev>/...). The reviewer model then guesses absolute paths and burns a failedReadround-trip in nearly every run (Background security reviewer guesses wrong absolute paths (first Read always fails) and intermittently fails findings schema #74200), or loops onFile does not existfor foreign paths (security-guidance plugin: commit reviewer Reads foreign/non-local paths from diffs, looping on 'File does not exist' #73271).hooks/review_api.py: changed paths are resolved against the active worktree root, verified (realpath +os.path.commonpathcontainment +isfile) to remain inside it, and only verified absolute paths are emitted in the "you may Read these" list. Root-anchored and foreign-checkout paths are recovered via the longest existing repo suffix (minimum two path components — never a bare basename, so a same-named file elsewhere can't be silently substituted). Unresolvable paths are listed separately as not present in this checkout.llm.agentic_reviewuses the same public prompt builder as external callers, so the two prompt paths can't drift.findingsto be a JSON array for zero, one, or many results, and a tolerant client-side guard (_findings_list) normalizes a singleton findings object into a one-item list at both consumption sites — previously that shape iterated dict keys and silently produced zero findings.Root cause
The prompt builders passed through whatever paths diff parsing produced, with no worktree anchoring or containment guard, and the findings contract relied on the model always emitting an array.
Validation / Evidence
unittestcases (hooks/test_review_paths.py) exercising the real runtime functions: relative-path absolutization, foreign-path exclusion + labeling, root-anchored recovery, foreign-checkout suffix recovery, bare-basename collision NOT mapped, repo-root + guarded-path prompt rendering, findings-array prompt/schema requirements, singleton-findings coercion.python3 -m py_compileclean on all touched files; all 8 tests pass./repo-evil/secret.pyvs root/repo(excluded —commonpath, not string prefix),../outside.py(excluded), symlink-inside-repo-pointing-outside (excluded via realpath), absolute path with..resolving back inside (correctly readable).TaxEngine/Package.swiftand/home/user/App/missing.pyverbatim with no root; new prompt states the absolute repo root, one verified absolute path, and one labeled-absent path.Notes for reviewers
Closes #74200
Closes #73271
AI-assisted: implemented by a Codex (gpt-5.6-terra) worker agent and independently reviewed by a fresh-context Claude Opus verifier (including the adversarial containment probes above), both operating under human supervision. We run this plugin ourselves; happy to iterate.