Repository navigation
Secrets check flags keys in JavaScript and TypeScript const, let, var and class fields (GST-3500) - #4697
Closed
garrytan wants to merge 5 commits into
Closed
Secrets check flags keys in JavaScript and TypeScript const, let, var and class fields (GST-3500)#4697garrytan wants to merge 5 commits into
garrytan wants to merge 5 commits into
Conversation
…, let, var and class fields (GST-3500) Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
…lds (GST-3500) Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
|
Merging to
After your PR is submitted to the merge queue, this comment will be automatically updated with its status. If the PR fails, failure details will also be posted here |
Review-Finding: p1/red-team#1 reader=red-team Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
Review-Finding: p2v/outside-voice#3 reader=outside-voice Review-Finding: p2v/adversarial-native#1 reader=adversarial-native Review-Finding: p2v/adversarial-native#4 reader=adversarial-native Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
…ames as names
A type annotation no longer crosses ";", so "let session: string; const
mode = ..." stops reporting the next declaration's literal, and an
uppercase underscore-joined value ("MY_SERVICE_API_KEY") reads as an
environment-variable name. The docs list three more known limits.
Review-Finding: p3v/outside-voice#4 reader=outside-voice
Review-Finding: p3v/outside-voice#5 reader=outside-voice
Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
Contributor
|
Closing this PR. A narrower redesign will replace it: a JavaScript or TypeScript declaration will be flagged only when its value looks like a secret (a known key prefix or a high-entropy string), never just because its name looks like a key. Built this way, the rule flags ordinary environment-variable names used as lookup keys ( |
2 tasks done
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
const token = "<key>";(orlet,var,export const, a typed declaration, or a class field likeprivate apiKey = "<key>";) in JavaScript and TypeScript files.Why: before this, a real key in that form passed the check, and JavaScript and TypeScript are the most common languages in projects that use gstack.
Nothing to do, but a test that builds a fake key from pieces (
const token = 'ghp_' + '…') now fails the check when that line is edited; build it with[...].join('')instead.What changed
env.kv.js(MEDIUM, blocks likeenv.kv). It reads a declaration with one to four ofdeclare,public,private,protected,static,readonly,override,accessor,const,letorvar(optionally afterexport), then a secret-named name, an optional?/!and type, and a quoted or template literal. It also reads after//and/*..js,.jsx,.ts,.tsx,.mjs,.cjs,.mtsand.ctsfiles. A scan with no file path is unchanged, because the Rust rule already readsletandconstthere.env.kvmatch is unchanged and no line reports twice. A name with no keyword, including a bare#secret = "<key>"line, is stillenv.kv's.env.kv's checks: a credential-shaped name, no placeholder, 3.0 bits of entropy and the test-file fixture-label exemption. A key split across a+chain of quoted pieces reports.'agent_model','terminalFontSize'), lowercase paths or ids ('test/skill-e2e-bws.test.ts'), environment-variable names (const API_KEY = "MY_SERVICE_API_KEY"), and a template whose text beside its${…}slots holds no secret. A type stops at;, solet session: string; const mode = "BILLING_DASHBOARD";gives nothing. UUIDs, hex, digit segments and mixed-case random text still report..vueand.sveltefiles, letters-only passphrases, a space inside a${ }slot, and a+chain whose first piece is a template.Why
A real key bound by a JavaScript or TypeScript declaration passed the check that runs before every push. The tests were written first and failed on main; the negative controls (types, destructuring, imports, calls, environment reads, placeholders, other file types) passed there and still pass.
Blast radius
Only added lines in JavaScript and TypeScript files are read by the new rule, so nothing that passed before fails unless it is edited. A replay over every tracked file, comparing main 75410da with this branch at a0763dc, lost 0 findings and added 41, all secret-shaped literals in test files (fake
sk-keys, UUID tokens, random strings).Documentation
Status: current. The documentation already matches this change; no edits were needed.
Scope: 6 committed files from 75410da to a0763dc (the secrets check reads JS/TS declarations as
env.kv.js):changelog.d/secrets-check-reads-js-declarations.md,docs/pregate.md,lib/redact-patterns.tsand three tests. There were no staged, unstaged or new files. Cross-doc reads covered the redaction sections of CLAUDE.md, docs/CONTRIBUTOR_REFERENCE.md and spec/sections/gate-and-file.md.tmpl.Coverage:
env.kv.jshas reference coverage (docs/pregate.md secrets section), how-to coverage (allowlisting by finding id in the same doc) and explanation coverage (why each shape is or is not read, with known limits). No critical or common gaps.Diagram drift: none; no diagrams name the redaction patterns.
Debt: spec/sections/gate-and-file.md.tmpl's "~30 patterns" count predates this branch (51 at base, 52 now). The env.kv.js source comment in lib/redact-patterns.ts lists a bare
#secret = "<key>"as matched, while the rule and the docs leave that line toenv.kv.Approvals
Approved: yes (record r-676a35a605b3). The full approval record stays private.
Plan: exempt: bug fix with failing-first tests (R4)
Plan check: exempt bug fix
Agent notes
Thread GSTA-800 for GST-3500, a follow-up to #4675. lib/pregate/index.ts is not touched. End-to-end case: test/pregate-secrets-source-context.test.ts.
Review. Full panel on 454db3e (specialists 0 findings; red-team 1 informational, fixed). Second-model review on 454db3e marked 3 blocking: one fixed in 885bca1 (template static text), two ruled as notes by the owner. A fresh second-model review on 885bca1 marked 5 blocking: #4 (a type crossing
;) and #5 (env-var names) were new false positives, fixed in a0763dc under the owner's second granted fix-check; #1-#3 ruled as notes. The fix-check reader on 885bca1..a0763dc found no blocker and 2 informational notes: an uppercase underscore-joined random value now passes as an env-var name, andlet token: string; token = "<key>";on one line no longer reports (885bca1 caught it only through the cross-statement match the fix removed; main never did).Ruled note: lib/redact-patterns.ts:1894:outside-voice at 454db3e ruled by GSTA-36 (relayed from GSTA-800:01M81F1M4AKC4PXEQQAX861Z8S) at 2026-11-22T11:26:28.241Z: pre-existing pregate path parsing drops git-quoted paths; filed as GST-3528 (approval a-5023c3c6f937)
Ruled note: lib/redact-patterns.ts:1892:outside-voice at 454db3e ruled by GSTA-36 (relayed from GSTA-800:01M81F1M4AKC4PXEQQAX861Z8S) at 2026-11-22T11:26:28.409Z: value on the next line is the documented added-lines limit; main misses it too (approval a-fa368e659e5f)
Ruled note: lib/redact-patterns.ts:1897:outside-voice at 885bca1 ruled by GSTA-36 (relayed from GSTA-800:01M81FMHS19V5KYRV17TK00SEW) at 2026-11-22T11:26:28.569Z: git-quoted paths skip path-scoped rules on main too; filed as GST-3528 (approval a-538105c826d0)
Ruled note: lib/redact-patterns.ts:1895:outside-voice at 885bca1 ruled by GSTA-36 (relayed from GSTA-800:01M81FMHS19V5KYRV17TK00SEW) at 2026-11-22T11:26:28.706Z: value capture stops at whitespace or escapes, as env.kv does on main (approval a-1e8e4bdf7c14)
Ruled note: lib/redact-patterns.ts:1899:outside-voice at 885bca1 ruled by GSTA-36 (relayed from GSTA-800:01M81FMHS19V5KYRV17TK00SEW) at 2026-11-22T11:26:28.841Z: + chain finding spans the first operand, as env.kv does on main (approval a-fa33c5c6d9c5)
Ship notes. The p2v and p3v native adversarial rows were logged after the bound outside-voice rows, so
gstack-ship-receipt stopreturned STOP_UNBOUND and neither fix-check grant could bind a stop record; the grants are relayed from GSTA-800 messages 01M81F1M4AKC4PXEQQAX861Z8S and 01M81FMHS19V5KYRV17TK00SEW. The env.kv.js source comment still lists a bare#secretas matched; the docs and tests are correct.Fix-check bookkeeping. fix_checks=3 counts one reader run twice plus one log row: I first ran the granted fix-check reader by hand (2 informational notes), then gstack's plan ran it again with the targeted reader on a0763dc (3 informational notes, targeted 0), and a third review-log row on the same unchanged tree records p3v/outside-voice#4 and #5 as fixed by this range and p2v/outside-voice#3 as fixed in 885bca1 (verified by its tests and the p3v second-model pass). No reader found a blocker.
REVIEW_LOOP: passes=1 blocking_found=8 deferred=0 noted=12 fixed=4 scope=frozen open=5 unbound=4 ledgers_read=4 fix_checks=3 dispatches=2