Skip to content

Secrets check flags keys in Rust let, const and static bindings and stops flagging Rust type annotations (GST-3474) - #4675

Merged
capy-ai[bot] merged 3 commits into
mainfrom
secrets-check-reads-rust
Nov 22, 2026
Merged

capy-ai[bot] merged 3 commits into
mainfrom
secrets-check-reads-rust

Conversation

@garrytan

@garrytan garrytan commented Nov 22, 2026 •

Copy link
Copy Markdown
Owner

The secrets check now catches a key written as let token = "<key>"; (or let mut, const, static) in a Rust file, and no longer flags Rust type annotations like token: Option<&str>, or match arms like Token::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 as token: Option<&str>, failed it, so every Rust change needed allowlist entries. Now the key reports and the field passes.

  • New rule env.kv.rust (MEDIUM, secret, so it blocks like env.kv): a let, let mut, const, static or static mut binding, optionally pub/pub(..) and typed, whose value is a string, raw or byte literal, directly or as the first argument of Some, String::from, Box::new or Cow::Borrowed/Cow::Owned. It uses the same name, placeholder and entropy checks as env.kv, and it also reads after //, ///, //! and /*.
  • A scan with no file path now also reports the declaration form (let/const/static NAME = "<key>") as env.kv.rust. With a file path the rule reports only in .rs files. The pre-push hook scans Dart and Python files without a path, so a Dart const token = "<key>"; now gets an env.kv.rust warning there.
  • Rust type annotations stop reporting, through an exemption added on top of the existing env.kv checks. It applies only in a .rs file, to a line-start name: whose value is type-shaped (a primitive such as u32 or str, 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 a token: <value> line inside a Rust string or comment reporting, because the check sees a .rs file's added lines without the string around them.
  • Docs: the secrets check's code-shapes section names the known limit (a line inside a string that reads exactly like a field annotation passes) and the pre-push behavior.
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.

  • INFORMATIONAL lib/redact-patterns.ts:1172 No test pins the new depth-0 ; rejection in isRustTypeAnnotation.
  • INFORMATIONAL sf-543d8477ef9f security finding, details recorded privately
Exploratory 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 reports env.kv after 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
  • CI free test run 44995067568 at 2b76daa: green (38823 tests)
  • bun test test/redact-*.test.ts and 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 CI
  • bun run typecheck: exit 0
Issues

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

{
  "schema_version": 1,
  "pr": 4675,
  "head": "2b76daa7a577c5d9fa78449fc55d207f2d880427",
  "version": "1.102.2.0",
  "base": "main",
  "gate": {
    "test": {
      "pass": 38823,
      "fail": 0,
      "skip": 0
    }
  },
  "ci_carried": [
    {
      "lane": "test",
      "run": 44995067568,
      "attempt": 1,
      "tree": "c5784eb027e18195c6be4318d391c744ce678d4f"
    }
  ],
  "calls": 39,
  "session_kind": "unattended",
  "run": "ship-4675",
  "head_tree": "c5784eb027e18195c6be4318d391c744ce678d4f",
  "product_patch_id": "faf3cdec7a353e1a58f62358cfa8ebb9ba9c098d",
  "gstack_version": "1.102.2.0",
  "review_depth": {
    "depth": "full",
    "class": "gate",
    "runtime_lines": 105,
    "rules": "630fd3101899e28e",
    "base": "c2b4f0d2adfa66e11143b95d9a42023a09380212",
    "registry": "c2b4f0d2adfa66e11143b95d9a42023a09380212",
    "gate_scan": {
      "tagged": 0,
      "head": "2b76daa7a577c5d9fa78449fc55d207f2d880427"
    },
    "reasons": [
      "gate-class",
      "risk:security",
      "runtime=105"
    ],
    "risk": [
      "security"
    ],
    "mode": "panel"
  },
  "pregate": "requires-remote cleared @c5784eb027e1 (8 checks, current for 2b76daa7a577)",
  "requires_remote": [
    "free-tests.yml/cso-macos-launcher: https://github.com/garrytan/gstack/actions/runs/44995067568/attempts/1",
    "free-tests.yml/macos-named-regressions: https://github.com/garrytan/gstack/actions/runs/44995067568/attempts/1",
    "free-tests.yml/cso-windows-launcher: https://github.com/garrytan/gstack/actions/runs/44995067568/attempts/1",
    "windows-smoke.yml/windows-smoke: https://github.com/garrytan/gstack/actions/runs/44992408498/attempts/1",
    "pregate.json/remote_gate: remote-gate tree=c5784eb027e1 tests=38823 skipped=92 runs=44995067568/1 profiles=ci-reuse/free-tests heads=2b76daa7a577 verified=2026-11-22T07:23:04.629Z"
  ],
  "issues": {
    "fixes": [],
    "refs": [],
    "flakes": []
  },
  "docs": {
    "status": "current",
    "scope": "docs/ and README.md against c2b4f0d (docs/pregate.md, changelog.d fragment reviewed)"
  },
  "review_loop": {
    "passes": 2,
    "blocking_found": 7,
    "deferred": 0,
    "noted": 3,
    "fixed": 4,
    "scope": "frozen",
    "rounds": 2,
    "ledgers_read": 4,
    "dispatches": {
      "specialist": 2,
      "red-team": 2
    }
  },
  "ruled_notes": [
    {
      "finding": "lib/redact-patterns.ts:1176:outside-voice",
      "head": "2b76daa7a577c5d9fa78449fc55d207f2d880427",
      "by": "GSTA-36",
      "reason": "comma-less Rust field line reports as it does on main; exempting it would reopen the multi-line string gap",
      "at": "2026-11-22T06:10:45.732Z",
      "approval": "a-e8141da102de",
      "relayed": "GSTA-800:01M80Y09S1CCSH7CR6PJT9B6PJ"
    },
    {
      "finding": "lib/redact-patterns.ts:1167:outside-voice",
      "head": "2b76daa7a577c5d9fa78449fc55d207f2d880427",
      "by": "GSTA-36",
      "reason": "lowercase last path segment (std::ffi::c_char) reports as it does on main; no secret passes",
      "at": "2026-11-22T06:10:46.060Z",
      "approval": "a-61e030f8cc9d",
      "relayed": "GSTA-800:01M80Y09S1CCSH7CR6PJT9B6PJ"
    },
    {
      "finding": "lib/redact-patterns.ts:1167:outside-voice-arm",
      "head": "2b76daa7a577c5d9fa78449fc55d207f2d880427",
      "by": "GSTA-36",
      "reason": "match-arm body using its binding reports as it does on main; no secret passes",
      "at": "2026-11-22T06:10:46.421Z",
      "approval": "a-2b8b0ba2069d",
      "relayed": "GSTA-800:01M80Y09S1CCSH7CR6PJT9B6PJ"
    },
    {
      "finding": "lib/redact-patterns.ts:1174:adversarial",
      "head": "2b76daa7a577c5d9fa78449fc55d207f2d880427",
      "by": "GSTA-36",
      "reason": "the native reader FIXABLE over-catch (comma-less line, arm body binding) reports as it does on main; no secret passes",
      "at": "2026-11-22T06:10:53.662Z",
      "approval": "a-4525343b5bf9",
      "relayed": "GSTA-800:01M80Y09S1CCSH7CR6PJT9B6PJ"
    }
  ],
  "gate_dispositions": []
}
{"head":"2b76daa7a577c5d9fa78449fc55d207f2d880427","run":"ship-4675","mark":"stop","tree":"c5784eb027e18195c6be4318d391c744ce678d4f"}

garrytan and others added 2 commits November 22, 2026 05:27
…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>
@trunk-io

trunk-io Bot commented Nov 22, 2026 •

Copy link
Copy Markdown

😎 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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant