Repository navigation
Secrets check flags keys in Rust let, const and static bindings and stops flagging Rust type annotations (GST-3474) - #4675
Merged
Conversation
…s and flags Rust type annotations (GST-3474) Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
…tops flagging Rust type annotations (GST-3474) Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
|
😎 This pull request was merged. |
The Rust type-annotation exemption now needs a type-shaped value (a primitive or keyword, a path, or a CamelCase name) and a closing comma, so a credential line inside a Rust string or comment, a struct literal's value, or a comma-less line reports as it does on main. Docs name the known limit and the pre-push hook's no-path Dart scan. Review-Finding: p1/specialist-batched#1 reader=specialist-batched Review-Finding: p1/red-team#1 reader=red-team Review-Finding: p1/red-team#2 reader=red-team Review-Finding: p1/red-team#3 reader=red-team 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.
The secrets check now catches a key written as
let token = "<key>";(orlet mut,const,static) in a Rust file, and no longer flags Rust type annotations liketoken: Option<&str>,or match arms likeToken::Char(c) =>.Why: a real key in that Rust form passed the check, while every Rust change needed allowlist entries for type annotations (seen on garrytan/gbrain#10028).
Nothing to do: files in other languages are checked as before.
What changed
A Rust project hit two problems with the secrets check. A real key written as
let token = "<key>";passed it, and ordinary struct fields such astoken: Option<&str>,failed it, so every Rust change needed allowlist entries. Now the key reports and the field passes.env.kv.rust(MEDIUM, secret, so it blocks likeenv.kv): alet,let mut,const,staticorstatic mutbinding, optionallypub/pub(..)and typed, whose value is a string, raw or byte literal, directly or as the first argument ofSome,String::from,Box::neworCow::Borrowed/Cow::Owned. It uses the same name, placeholder and entropy checks asenv.kv, and it also reads after//,///,//!and/*.let/const/static NAME = "<key>") asenv.kv.rust. With a file path the rule reports only in.rsfiles. The pre-push hook scans Dart and Python files without a path, so a Dartconst token = "<key>";now gets anenv.kv.rustwarning there.env.kvchecks. It applies only in a.rsfile, to a line-startname:whose value is type-shaped (a primitive such asu32orstr, a path, or a CamelCase name) and ends in a closing comma; a match arm needs no comma. A literal, an=, a second field, a random-looking name, a lowercase or all-caps word, or a line with no comma still reports. That keeps atoken: <value>line inside a Rust string or comment reporting, because the check sees a.rsfile's added lines without the string around them.Why
"Every Rust landing needs allowlist entries, and
let token = \"...\"sails through" (garrytan/gbrain#10028). Rust keys in bindings now fail the check, and struct fields and match arms pass it, without hiding anything the check flags today outside Rust type annotations.Blast radius
Only the secrets scanner's pattern list changes. Every line the new exemption skips was also skipped at the first review's head, and each extra condition only adds a reason to report. Checked by a base-vs-head replay of every tracked file, by scanner probes at main, the first head and this head (script ran), and by CI's full free test run at this head.
Pre-Landing Review
The first full review found that the type-annotation exemption also skipped credential lines inside Rust strings and comments and struct-literal values, which main reports. The exemption was tightened to need a type-shaped value and a closing comma, with tests for each case. The second review of the fix found no blockers. The second-model review raised three lines that now report as they do on main (a comma-less last field,
std::ffi::c_char, a match-arm body that uses its binding); none lets a secret through, and the maintainer ruled them disclosed notes. A missing test-fixture-label exemption for the new rule in Rust test files was left as is.Review notes
Below the blocking floor (advisory, informational, test-gap or wording items); recorded here and not fixed in this PR.
lib/redact-patterns.ts:1172No test pins the new depth-0;rejection in isRustTypeAnnotation.sf-543d8477ef9fsecurity finding, details recorded privatelyExploratory QA
Scanner probes through
scan()(functional surface, 7 captures): a Rust binding reports and a type annotation passes; a credential line inside a raw string and inside a normal multi-line string reported nothing at the first head (reproduced and replayed) and reportsenv.kvafter the fix. Verdict: pass on current inputs.Scope Drift
Scope Check: CLEAN. Intent: report Rust binding keys and stop flagging Rust type annotations. Delivered: the same, plus the tightening that keeps the change additive.
Verification Results
No plan file (bug fix); no plan obligations. Automatic QA above.
TODOS
No TODO items completed in this PR.
Documentation
Scope: branch secrets-check-reads-rust against c2b4f0d2 (6 files changed: lib/redact-patterns.ts, three tests, docs/pregate.md, changelog.d/secrets-check-reads-rust.md). Nothing is staged, unstaged or untracked.
Result: current. docs/pregate.md already has a Rust bullet in the secrets-exemption list. It covers type annotations, match arms, the env.kv.rust binding rule, how path-less scans behave and the string/comment known limit. The changelog fragment describes the same change for users. No other doc lists secrets rule ids.
Debt: none found. I checked how the docs describe the behavior against the diff but did not test each claim by running the code.
Tests
bun test test/redact-*.test.tsand the push-time secrets check, allowlist, Dart and CSO taxonomy tests: green except one case (redact-kv-after-slash"link target, history-only link"), which fails the same way on main on that machine and passes in CIbun run typecheck: exit 0Issues
Refs p1/specialist-batched#1
reference p1/specialist-batched#1 ← commit 2b76daa: Review-Finding: p1/specialist-batched#1 reader=specialist-batched
reference p1/red-team#1 ← commit 2b76daa: Review-Finding: p1/red-team#1 reader=red-team
reference p1/red-team#2 ← commit 2b76daa: Review-Finding: p1/red-team#2 reader=red-team
reference p1/red-team#3 ← commit 2b76daa: Review-Finding: p1/red-team#3 reader=red-team
Agent notes
Thread GSTA-800 for GST-3474. Source: Vorflux (session Ember) via FOUN-32 on garrytan/gbrain#10028. lib/pregate/index.ts is not touched.
Approvals
Approved: yes (record r-4989a062ee1c). The full approval record stays private.
Plan: exempt: bug fix with a failing-first test (R65); GStack Minder (GSTA-36): security gap fix, no plan needed
Plan check: exempt bug fix
REVIEW_LOOP: passes=2 blocking_found=7 deferred=0 noted=3 fixed=4 scope=frozen open=4 ledgers_read=4 dispatches=4
Gate edits: none detected (3 listed, 0 read; patterns: RH-1,RH-3,RH-4,RH-12,RH-13,RH-14,RH-15,RH-16; unlisted idioms: none)
Ruled note: lib/redact-patterns.ts:1176:outside-voice at 2b76daa ruled by GSTA-36 (relayed from GSTA-800:01M80Y09S1CCSH7CR6PJT9B6PJ) at 2026-11-22T06:10:45.732Z: comma-less Rust field line reports as it does on main; exempting it would reopen the multi-line string gap (approval a-e8141da102de)
Ruled note: lib/redact-patterns.ts:1167:outside-voice at 2b76daa ruled by GSTA-36 (relayed from GSTA-800:01M80Y09S1CCSH7CR6PJT9B6PJ) at 2026-11-22T06:10:46.060Z: lowercase last path segment (std::ffi::c_char) reports as it does on main; no secret passes (approval a-61e030f8cc9d)
Ruled note: lib/redact-patterns.ts:1167:outside-voice-arm at 2b76daa ruled by GSTA-36 (relayed from GSTA-800:01M80Y09S1CCSH7CR6PJT9B6PJ) at 2026-11-22T06:10:46.421Z: match-arm body using its binding reports as it does on main; no secret passes (approval a-2b8b0ba2069d)
Ruled note: lib/redact-patterns.ts:1174:adversarial at 2b76daa ruled by GSTA-36 (relayed from GSTA-800:01M80Y09S1CCSH7CR6PJT9B6PJ) at 2026-11-22T06:10:53.662Z: the native reader FIXABLE over-catch (comma-less line, arm body binding) reports as it does on main; no secret passes (approval a-4525343b5bf9)
Outside review: openai/gpt-6.2-sol (host subagent), completed; native adversarial: completed.
🤖 Generated with Claude Code