Repository navigation
Keep quoted file names with secrets in review (GST-1451) - #4203
Merged
Merged
Conversation
The review collector now decodes git's C-quoted patch headers, so the secret-line keep rule reads the added lines of a file whose name holds a quote, backslash or control byte. reviewExclude also keeps a matched file the collector holds no lines for, as unread. Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
|
😎 This pull request was merged. |
Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
3 tasks done
Review-Finding: p1/outside-voice#1 reader=outside-voice Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
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.
A data file whose name git quotes in patch headers no longer slips past the secret-line keep rule in
review_exclude_paths, so a credential value in such a file reaches every reviewer like any other.What changed
Before: on a base policy of
{"review_exclude_paths":["r/**"]}, a branch addingr/q"x.jsonwith a credential value had that file excluded from every reader's diff. The same content atr/s.jsonwas kept.After: both are kept as
secret-line. A quoted or UTF-8 name with no secret is still excluded.core.quotePath=falseonly stops git escaping bytes of 0x80 and above. git still C-quotes a---/+++header when the name holds a", a backslash, a tab or another control byte, and-zdoesn't change patch output, so the -U0 parser stored added lines under the quoted header text.lib/review-collect.tsnow decodes those headers byte by byte (octal escapes,\",\\,\tand the rest, then UTF-8). It also pins--src-prefix=a/ --dst-prefix=b/so a user'sdiff.noprefixordiff.mnemonicPrefixcan't shift the slice, and records an empty added-lines entry for every file section it parsed.reviewExclude, a matched file that no rule keeps but that the collector has no record of (no per-path entry, or a text file with changed lines and no added-lines entry) is kept asconsumer-scan-unavailableinstead of being excluded.Why
Credential values in excluded data files would never reach any reviewer, and only the file name decided whether they did.
Blast radius
The change is limited to
readDiffinlib/review-collect.tsand the reason loop inreviewExclude. EveryreviewExcludecaller (gstack-review-plan,ship-receipt-depth) passes collector output, so the fail-closed check only fires when collector keys and git's listing disagree; two reviewers read every consumer of the added-lines map and found that the new empty entries change none of them (file:line read). The kept-reason set and the receipt schema are unchanged, and names without special characters parse exactly as before.Tests
test/review-exclude-secret-value.test.ts: the collector keys added lines by the real path for five quoted names and a UTF-8 name. Quoted and UTF-8 names with a value line are kept, while quoted and UTF-8 names without one are excluded, and so are a deletion-only edit and a whole-file deletion, both throughcollectCommit+reviewExcludeand throughgstack-review-plan --jsonon the live tree. A matched file with no collector entry is kept as unread.core.quotePath=falsecovers it, and it stays as a guard.bun run typecheckis clean.Agent notes
-z/core.quotePath=falsebecause neither changes how patch headers are quoted, so decoding is required for patch output. Mapping sections to numstat order would also work but couples two outputs.curl -H $OPENAI_API_KEYalone) only names a variable, and GST-1967 deliberately doesn't keep files for that, so the tests use a line that carries a value.Test Coverage
All new code paths have test coverage: each of the 3 changed runtime files has a changed test naming it (deterministic coverage map, no audit reader).
test/review-exclude-secret-value.test.tsfailed; the UTF-8-only case already passed there and stays as a guard.Pre-Landing Review
Pre-Landing Review: 1 issue, 1 fixed after the outside voice, 0 deferred, 2 noted.
windows-scoped-shardfailed with ENOENT onreceipts/q"plain.json(run 42587806615). Fixed in 84447ed by skipping that describe block on win32.Review notes
Below the blocking floor; recorded here and not fixed in this PR.
lib/review-exclude.ts:370: the newp in text.addedcheck also matches inherited object keys, so a root-level path namedconstructorortoStringwould read as seen. It can't be reached in practice, because such an extensionless name counts as code and is never excludable.Object.hasOwnwould close it.lib/review-collect.ts:127(pre-existing at the base): a root-level file named__proto__makes the collector throw. It fails loudly, so nothing is excluded silently. Building the maps withObject.create(null)would close it.Exploratory QA
Functional smoke on
gstack-review-plan --jsonin an owned fixture repo (3 probes, pass):receipts/**is excluded (capture 001).receipts/q"x.jsonwith a credential value is kept assecret-line, andreceipts/tab<TAB>plain.jsonwith no secret is excluded (capture 002).Octal-escaped and control-byte names are covered by the unit tests, not probed.
Design Review
No frontend files changed — design review skipped.
Eval Results
No prompt-related files changed — evals skipped. The eval selector lists dependents of
lib/review-collect.tsandlib/review-exclude.tsas scheduled and release coverage, not PR passes.Review bot comments
No review bot comments.
Scope Drift
Scope Check: CLEAN
Plan Completion
Plan completion audit: not run (no plan is bound to this branch and no docs/designs/ file matches). This is a bug fix, exempt from plan review.
TODOS
No TODO items completed in this PR.
Documentation
Status: current. The docs already match the change, so no edits were made.
Scope: committed diff 350d419..84447ed on capy/keep-quoted-file-names: lib/review-collect.ts (decodes C-quoted patch-header paths and pins the a/ and b/ prefixes), lib/review-exclude.ts (keeps a matched text file whose changed lines the collector holds no lines for, as consumer-scan-unavailable), a new test, docs/ship-policy.md and a changelog.d fragment. Nothing is staged, unstaged or untracked.
Documentation health:
consumer-scan-unavailablerow of the kept-reasons table for the new fail-closed case.Coverage debt: none. The change is internal collector behavior, and its only public surface, the kept reason, is covered by the reference table in ship-policy.md.
Diagram drift: none. No diagrams reference the collector or the exclusion.
Test plan
bun run test(free lane): carried from CI run 42595036747/1 at tree 58140858799f, 1652 files, 36767 tests, greenbun --no-env-file test --timeout=30000 test/review-exclude-secret-value.test.ts: 8 pass, 0 failbun run typecheck:test: 812 known diagnostics, none newAgent notes
Approvals
No approvals recorded for branch capy/keep-quoted-file-names.
Plan: exempt: bug fix (R65)