Repository navigation
Stop the secrets check flagging code that reads an environment variable (GST-1894) - #4157
Merged
capy-ai[bot] merged 6 commits intoNov 8, 2026
Merged
Conversation
…le (GST-1894) 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. |
A production file such as ab-test.ts or load-test.ts matched the test-file pattern, so a weak real password in it stopped being flagged. The pattern now matches only the documented forms: *.test.*, *.spec.*, *_test.* and test_*.py. Review-Finding: p1/red-team#1 reader=red-team Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
The env-read exemption only looked for a quoted fallback on the same line, so token = opts?.env?.API_TOKEN ?? followed by a backtick literal, or by a literal wrapped onto the next line, passed the secrets check. Backtick literals now count, and the next line is read when the expression continues there. The changelog now says plainly that an ALL-CAPS literal used as the variable name still passes. Review-Finding: voices/outside-voice#1 reader=outside-voice Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
…ng the next line Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
…rets check Review-Finding: p1/red-team#1 reader=red-team Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
4 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 preflight secrets check stops failing a branch for code that reads an environment variable, or for a self-describing fixture label in a test file. That keeps the safety check honest, so people trust it when it does fail.
What changed
Env reads that end the expression now pass; a literal fallback still fails (QA captures 001 and 002).
Before/after as text: Env reads that end the expression now pass; a literal fallback still fails (QA captures 001 and 002)
Why
"The preflight secrets check fails on
token = opts?.env?.AGENT_API_TOKEN;": yc-software/qm hit this on a test file that only reads an environment variable and names a fixture"personal-secret"(GST-1894). Those lines now pass. A line with a fallback or a second argument gets no new exemption, so a hardcoded secret written as a default still fails.Blast radius
Only the
env.kvrule inlib/redact-patterns.tschanges, and everygstack-redactcaller shares it: pregate, PR-body scans and decision-log scans. It's safe because the wider env-read exemption applies only when the line has no??,||,oror:, has no second argument, and ends the expression with;,,or). Every other line keeps exactly the #2912 exemption main has. We checked this by running the scanner on main and on this branch (QA captures 001 to 004), and CI run 42455675573 passed at this tree.Summary
Pregate blamed ordinary code for holding a credential.
process.env.Xalready passed, butopts?.env?.X;,ctx.env.X;,import.meta.env.X;,process.env["X"];andSystem.getenv("X");all failed it. Now anenvmember read by an ALL-CAPS name, or an indexed or call read whose argument is a quoted ALL-CAPS name, passes when the line holds no fallback and ends the expression. In test-named files, a value made only of lowercase words with a credential word among them passes as a fixture label. The branch first added a next-line reader and a shared backtick change, then removed both, so a fallback on the next line or in backticks is simply not exempted. The changelog fragment now says a quoted name that isn't ALL-CAPS inos.environ[...]fails where it used to pass.Test Coverage
All new code paths have test coverage. The Step 7 audit mapped 10 of 10 changed paths at three stars across test/redact-context-exemptions.test.ts and test/pregate-secrets-source-context.test.ts.
Tests: 1760 → 1760 (+0 new)
Coverage: 100% value-weighted (100% including 0 weakly covered paths)
Test value: 0 tests written, 2 rejected by the authoring gate, 0 existing tests extended, 0 paths weakly covered (weak = ★, gate-failing or unrated).
Tests ran: tests 1641
Pre-Landing Review
Pre-Landing Review: 1 issue — 0 auto-fixed, 1 asked (0 fixed, 1 skipped), 0 deferred, 0 noted. The fix round then corrected the changelog half of that finding (c44d634), and the one scoped fix-check found nothing blocking.
REVIEW_LOOP: passes=1 blocking_found=2 deferred=0 noted=1 fixed=1 scope=frozen unrecorded=2 ledgers_read=4 fix_checks=1 dispatches=4
Ruled note: lib/redact-patterns.ts:722:outside-voice at 830d294 ruled by Captain GStack Minder (GSTA-36) at 2026-11-08T06:38:38.670Z: Note (a): an env.ALLCAPS-shaped quoted value in YAML or .env passes env.kv; no real secret has that shape (approval a-b240fe09f2a4)
Ruled note: lib/redact-patterns.ts:777:adversarial-native at 830d294 ruled by Captain GStack Minder (GSTA-36) at 2026-11-08T06:38:38.874Z: Note (d): a lowercase word label with a credential word in a test-named file is a fixture label, item 2 policy (approval a-17df74499cd2)
Ruled note: lib/redact-patterns.ts:724:red-team at 830d294 ruled by Captain GStack Minder (GSTA-36) at 2026-11-08T06:39:12.011Z: Fail-closed: a quoted env name that is not ALL-CAPS in os.environ[...] or os.getenv(...) now fires env.kv where main passed (approval a-3d16d2eda6a2)
Gate edits: none detected (2 listed, 0 read; patterns: RH-1,RH-3,RH-4,RH-12,RH-13,RH-14,RH-15,RH-16; unlisted idioms: none)
Outside review: completed (openai/gpt-6.1-sol, medium, certified configuration). It reported one finding, the note (a) shape, which the Captain ruled a note.
Notes that ship with this PR, one line each:
x.env.ALLCAPSorx.env[shaped quoted value in a .env or YAML file passesenv.kv.lib/redact-patterns.ts:724: a quoted lowercase name inos.environ[...](os.environ["db_password"]) now fires where main passed it.lib/redact-patterns.ts:729: wider reads in semicolon-free code (opts?.env?.Xwith no;) still fire, as on main.*_spec.rband minitesttest_*.rbfiles don't get the fixture-label exemption.lib/redact-patterns.ts:708: an ALL-CAPS-and-digit name is the ruled env-name exemption, soa.env.ZX9QW8ER7TY6UI5OP4;in code passes where main flagged it.process.env.X || <backtick literal>passes, as on main.changelog.d/stop-secrets-check-flagging-env-var-reads.md:1(fix-check): only longer, higher-entropy quoted names inos.environ[...]orENV[...]newly fail. Snake_case call reads that the lookup-key exemption covers, such asos.getenv("db_password"), still pass.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:724Same defect as p1/red-team#1: non-ALL-CAPS quoted names in os.environ[...] now fire env.kv (fail-closed); changelog wording inaccurate.lib/redact-patterns.ts:708ENV_NAME_ARGUMENT accepts ALL-CAPS-and-digit names, so os.environ["JBSWY3DPEHPK3PXP"] passes (as on main) and a.env.ZX9QW8ER7TY6UI5OP4; in code now passes (main flagged): the Captain-ruled ALL-CAPS-name exemption.lib/redact-patterns.ts:729Wider reads without a trailing ; , or ) (semicolon-free code) still fire, as on main (fail-closed, documented).changelog.d/stop-secrets-check-flagging-env-var-reads.md:1The reworded sentence overclaims: only os.environ[...] / ENV[...] reads whose quoted name is 8+ characters with entropy >= 3.0 newly fail; call reads the lookup-key exemption covers still pass.Exploratory QA
Functional smoke on the
scan()API, comparing main d479c5b with this branch, using synthetic rows only. Capture 001 passed: a wider env read that ends the expression passes. Capture 002 passed: a literal fallback still fails on every row, as on main. Capture 003 failed, and replay 004 confirmed it: a quoted lowercase name inos.environ[...]andos.getenv(...)now fires where main passed it. That's the fail-closed finding atlib/redact-patterns.ts:724, which ships as a ruled note (approval a-3d16d2eda6a2). No plan checks ran because no plan is bound.Design Review
No frontend files changed — design review skipped.
Eval Results
No prompt-related files changed — evals skipped.
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). Fix: add "Plan: " to the PR body, or run /autoplan.
TODOS
No TODO items completed in this PR.
Documentation
Status: current. No documentation changes were needed.
Scope: base d479c5b..c44d634 on capy/stop-secrets-check-flagging-env-var-reads. The candidate selects 4 committed files: lib/redact-patterns.ts, two test files and changelog.d/stop-secrets-check-flagging-env-var-reads.md. Nothing is staged, unstaged or untracked.
Documentation health:
Coverage debt: The change adds no new public command, flag or config. The scanner's code exemptions (env reads under #2912 and GST-1894, and test-file fixture labels) are documented only in source comments and the changelog. That is reference-only coverage and a minor gap: docs/pregate.md does not list which code shapes the secrets check treats as non-secret.
Diagram drift: none.
Test plan
bun run test, carried from CI run 42455675573/1 at tree 20ae77f132fd): 1641 files, exit 0gstack-pregate --allow-repo-commands: CI carry cleared the remote gate, and the four remote checks were cleared from runs 42455675573/1 and 42455675639/1Agent notes
Refs GST-1894
Approvals
Approved: yes (record r-ec1d4c96ce3e). The full approval record stays private: this repository is public or its visibility is unknown.
Plan: exempt: bug fix (R65)
Plan check: exempt bug fix
REVIEW_LOOP: passes=1 blocking_found=2 deferred=0 noted=1 fixed=1 scope=frozen unrecorded=2 ledgers_read=4 fix_checks=1 dispatches=4
Gate edits: none detected (2 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:722:outside-voice at 830d294 ruled by Captain GStack Minder (GSTA-36) at 2026-11-08T06:38:38.670Z: Note (a): an env.ALLCAPS-shaped quoted value in YAML or .env passes env.kv; no real secret has that shape (approval a-b240fe09f2a4)
Ruled note: lib/redact-patterns.ts:777:adversarial-native at 830d294 ruled by Captain GStack Minder (GSTA-36) at 2026-11-08T06:38:38.874Z: Note (d): a lowercase word label with a credential word in a test-named file is a fixture label, item 2 policy (approval a-17df74499cd2)
Ruled note: lib/redact-patterns.ts:724:red-team at 830d294 ruled by Captain GStack Minder (GSTA-36) at 2026-11-08T06:39:12.011Z: Fail-closed: a quoted env name that is not ALL-CAPS in os.environ[...] or os.getenv(...) now fires env.kv where main passed (approval a-3d16d2eda6a2)
/ship run ship-4157b (unattended, gstack 1.98.0.0). Evals: none affected. Review plan: class=gate depth=full, panel of 4. One fix round was used, for the changelog wording only, followed by one scoped fix-check.