Repository navigation
v1.92.3.0 fix(redact): env.kv catches a credential on a diff line (GST-543) - #3726
Merged
Merged
Conversation
…ST-543) Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
…ation or export) Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
|
😎 This pull request was merged. |
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.
What changed
git diff | gstack-redactmissed a credential on a diff line. env.kv matched from the start of the line, so the+/-diff marker stopped the match. Now env.kv accepts a unified or combined diff marker before the name.Before (main 5ba425a): a hunk with
+API_TOKEN=<random value>piped togstack-redact --jsongives"findings": [], exit 0.After (this branch):
env.kvMEDIUM, exit 2.Why
This is a wrong security result (S1, GST-543), found while working on #3630. A
diffcode block in a PR body, or a diff piped into the CLI, could carry a live credential past the scanner. Pregate'ssecretscheck and the pre-push hook were not affected, because both strip the+before scanning.Proof:
test/redact-diff-prefix.test.tswas written first and failed on main (env.kv (+),env.kv (hunk),env.kv (indented hunk), and the CLI exit-2 test).Blast radius
lib/redact-patterns.ts: the env.kv regex,ENV_KV_NAMEandSCHEMA_FIELD_NAMEtake an optional marker,(?:[ +-]?\+|[ +-]?-(?! [^ \t]))?. A-followed by one space and text is still a Markdown bullet or YAML list item, not a marker.PATTERNSa sample. Each sample must report bare, behind every marker, and inside a real hunk. env.kv was the only rule with this blind spot.Pre-Landing Review
REVIEW_LOOP: passes=1 blocking_found=1 deferred=0 noted=3 fixed=4 scope=frozen fix_checks=3 dispatches=1
Gate edits: none
Review notes below the blocking floor, not fixed:
- API_TOKEN=…, reads as a bullet and stays unreported. The same is true for a two-parent--ccline removed against the first parent only. This is the cost of keeping Markdown bullets clean.+API_TOKEN=…, is still missed. Only one extra marker column is read.+bullets, and bullets indented by one space (+ x,- x), now read as diff markers. No tracked file has one.- token: …) never matched env.kv. That was true before this change too.Documentation
Docs audit (gst543-docs-1): current. Scope checked: docs/pregate.md, docs/CONTRIBUTOR_REFERENCE.md, CLAUDE.md and the changelog fragment.
Test plan
bun test test/redact-diff-prefix.test.tsfailed on main 5ba425a and passes here.