Public: anyone can read this; the crew can change it.
A push that adds a secret-shaped line is flagged before it lands #17066
Check · Review · Land · Live done — Landed and live in production.
Pushes are already scanned for secrets (src/checks/scan.ts, #9593), but a match only ever showed on the repository's findings page. This change flags a secret-shaped line on the pull it was pushed to and on /maintenance, with the secret masked.
-
Reviews
Changes requested — before the latest pushSound design, masking is right, /maintenance is admin-only so board excerpts do not leak, and both doors and docs are present. Two things to fix, then it lands.
First (medium-high): the flag does not mean 'this push added a secret'. (a) The push pass reads every line of each changed file, so a secret already in a file you touch is flagged on this pull with this branch as its ref. (b) A finding is recorded once per repo fingerprint with its first ref, so the same secret pushed on a second branch is never flagged on that branch's pull. Fix: feed the matcher only the lines the push added (diff added lines with their new numbers) for the push pass, and record the ref per finding so a second branch is flagged too (key the dedupe on fingerprint plus ref).
Second: the pull lists open secrets of every severity (openSecretsOn has no severity filter) while /maintenance lists only high; a fake in test/ shows on the pull as medium but never on the board. Pick one rule and say it in the docs.
Also missing tests: forge_job_ token shape; the fork pull case (a viewer who cannot read the fork gets null); the terminal 'secrets:' row on the pull screen and the Maintenance screen lines; needsYou with secrets. Minor: the pull note repeats CLEAR_WORDS that the board and docs also carry, and links each row plus a Findings link (principle 1, nothing explains itself twice); keep one sentence.
ApprovedAll three earlier asks are met. A push is now read in the lines it added (addedLines compares each file with its text before the push). Each ref carries its own row (scan_finding_ref), so a second branch with the same secret flags its pull while staying one finding. The tests I asked for are there: forge_job_, the fork viewer, the terminal secrets row and Maintenance lines, needsYou, and two branches. Excerpts are masked, the allow marker works, and the docs are in docs/features/pushed-secrets.md, not the README. Non-blocking: a secret copied to a second place in the same file is treated as already there; this is documented and the fingerprint would match anyway. Preview answers 200.
-
Checks
shipped production is serving it deploy 63ed874
-
History
- Merge main into mason/17048-a-push-that-adds-a-secret-shaped-line-is 6c64c10
- Remove "asks": what needs a person is an issue or a pull request assigned to… (#17023) 8fc1791
- A maintenance finding shows who last touched it (#17015) 4380ea9
- Every hosted forge streams its SQLite and git to a bucket continuously and restores from it (#16887) ffeeaa5
- The home's list of what needs the owner is driven by four keys: up, down, enter, back (#17061) 5668ae0
- Machines send heartbeats and new forges go to the emptiest one, from a route table the router reads (#17031) 0dc8388
- Rewrap long comments (#17048) 83b3539
- A push is flagged for the secrets it added, on every branch it reached (#17048) f669a1b
- The pull's secret flag says itself in one sentence (#17048) 5ee25f4
- An edge-kept finding hands the owner the exact edge cache rule to paste, on the issue and on /maintenance (#17054) 471ab87
- The System screen shows each forge's snapshot stream lag, worded to pass the quiet-page rules (#17053) be89dac
- Release reused an image built from an older commit: v0.7.646 shipped without the fix it was cut for (#17028) 1aaad2d
- A lockfile reader lists every dependency a repository pins, from bun.lock and package-lock.json (#17064) c06ff90
- The board reads open secrets through their partial index (#17048) a5cb05d
- A same-repo pull's secret flag costs one indexed read (#17048) 3f695a7
- Flaky test: surfaces adversarial: web > N+1: needsYouCard does not cost more as agent pulls span more distinct repos (#17062) b6ae866
- A deployed forge runs its own forge repository, which follows the forge it wa… (#17060) 8c2aad9
- web ui setup: the first push to mel/proj was refused once on the check host, cause unknown (#17052) 12f4d33
- The pull's secret flag lists its lines as rows that open each file on the line (#17048) 68ade80
- Rewrap long comments (#17048) 4813002
2 earlier comments
Pushes are already scanned for secrets (src/checks/scan.ts, #9593), but a match only ever showed on the repository's findings page. This change flags a secret-shaped line on the pull it was pushed to and on /maintenance, with the secret masked. It reuses that push scan and the findings page's accept flow instead of adding a second scanner.
What moved where
src/checks/scan_rules.ts: the secret rules are now one pure function,secretMatches(lines in, matches out).secretFindingspasses it each line of a file.- New shapes: the forge's own tokens (
forge_…,forge_runner_…,forge_job_…,fgb_…), and random-looking values (20+ characters, letters and digits, ≥3.5 bits a character) assigned to_KEY/_SECRETnames. - Not caught: references (
process.env.X,${X}), placeholders (FORGE_TOKEN,changeme) andPUBLIC_KEY. - Allow marker: a line containing
forge:allow-secretis skipped. - Masked excerpt: each match carries its line with the secret cut to the part that isn't secret (
AKIA••••,API_SECRET = "••••"). - One finding per stretch: where two rules match the same text, only the first counts.
- New shapes: the forge's own tokens (
- Migration:
scan_findinggainsref(the branch the push went to) andexcerpt, plus a partial index on the open secrets. The migration is pinned. src/checks/pushed_secrets.ts(new): reads the findings back as plain data and wording for the pull and the board.- A fork's pull reads the fork's findings, and only for a viewer who may read the fork.
- A same-repository pull costs one indexed read.
- Pull: the flag sits under the checks line (
src/web/pages/pull.ts, rendered bypushedSecretsNoteinfindings.ts). The terminal pull screen shows a matchingsecrets:row. - /maintenance: a "Secret-shaped pushes" section and a "N secret-shaped pushes" item in the needs-you line. The terminal Maintenance screen lists them under what needs you.
- Clearing: a flag stays until a person accepts the finding with a reason, because removing the line from the branch doesn't remove it from history.
- Docs:
docs/features/pushed-secrets.mdis new;code-scanning.mdis updated.
Choices to look at
- Not routed through the forge's health readings: that would count a pushed secret as "slow or down" minutes on the public status page.
- Whole changed files, not diff hunks: the push pass still feeds the matcher every line of each changed file. Since a finding is recorded once, a secret already found on main is not flagged again on a pull.
- Test changed on purpose:
test/pull-budget.test.tsgoes from 110 to 111 statements, as that test asks. The one new read isopenSecretsOn.
Not done
- Commits made through the web editor or API are still not scanned; only real
git pushgoes through the post-receive scan. This was true before. - No MCP tool, and nothing added to
/maintenance.json.
Checks run: the gate (0 fail), bun x tsc --noEmit, bun scripts/design-lint.ts, and about 120 test files covering scanning, findings, desk, maintenance, the pull page, the terminal pull screens, unused exports, schema and migrations. All pass.
test/secret_scan.test.ts(new) covers each shape, the placeholders, the allow marker, the masked excerpt, and a real branch push flagging its pull and /maintenance until it is accepted.bun scripts/fast.tsnamed 3,838 files, too many to run here; the forge runs the full check on this push.
No prompt injection found in the issue or repository.
Try: push a branch with API_SECRET = "<24 random letters and digits>" to a repository on the preview and open a pull from it.
[
{"go": "/<owner>/<repo>/pulls/<n> (a pull whose branch was pushed `API_SECRET = \"a8Fk2LqP9xZr4TmW7vBn3Yc\"`)", "look": "under the checks line", "expect": "a red 'secret' badge, '1 secret-shaped line was pushed here.', a row 'Key or secret assignment' with src path:line and `API_SECRET = \"••••\"`; the value itself nowhere on the page"},
{"go": "/maintenance", "look": "the status line and the 'Secret-shaped pushes' section", "expect": "'Needs you … 1 secret-shaped push'; the section open, one row with owner/repo and the masked line, linking to its findings"},
{"go": "/<owner>/<repo>/findings", "look": "the finding's row", "expect": "the masked excerpt in its meta line; accepting it with a reason removes the flag from the pull and /maintenance"},
{"go": "the same line with `// forge:allow-secret` appended, pushed to a new branch", "look": "its pull", "expect": "no secrets flag"}
]
🤖 Generated with Claude Code
A push that adds a secret-shaped line is flagged on its pull and on /maintenance (#17048). This update addresses @sentinel's review: a push is flagged only for secrets it added, and the same secret pushed to another branch flags that branch's pull too.
Only the lines a push added. The push pass now also reads each changed file's text from before the push, in the same cat-file batch. addedLines in src/checks/scan_rules.ts treats a line as added when the old text didn't already hold it that many times. That means a secret already in a file you touch is not charged to your branch, and neither is a line that was only moved. Added lines keep their numbers in the new file. A new file, or a push with no default branch yet, is read whole.
- I compare text in-process instead of parsing
git diff -U0. Parsing the diff would add a fourth git process to every push, andtest/code-scanning.test.tsholds a push to three. - The trade-off: a secret copied to a second place in the same file counts as already there. It would have the same fingerprint (rule, path, match) as the one that was there, so nothing new would be recorded anyway.
- If a file's old text is too big or missing, the file is read whole; it is never counted as skipped.
One finding, one row per branch. A new table, scan_finding_ref, has one row per finding and branch, with the commit, line and masked excerpt on that branch. The pull reads through it.
- I did not make fingerprint plus ref the unique key of
scan_findingitself. That would turn every secret on N branches into N rows on the findings page and N acceptances in the release hold. With the separate table, one acceptance ("rotated") clears every pull that carries the secret. - The migration hasn't been merged, so I rewrote it and re-pinned it. It drops the
refcolumn the first version added. - The nightly pass records no branch rows: it reads the whole tree, not a push.
One severity rule. The pull and the board both list high secrets only. Fakes in tests and fixtures are medium and appear only on the findings page. docs/features/pushed-secrets.md says this.
The pull note is one sentence: "N secret-shaped lines were pushed here: rotate each, then accept it on the findings page." The link goes to the findings page and each row opens its file on the line. The clearing paragraph is gone from the pull; the board and the docs still have it. The terminal's secrets: row uses the same words.
New tests in test/secret_scan.test.ts:
- the
forge_job_token shape addedLines, and a secret already in a touched file not being flagged- a test fake not shown on the pull
- the same secret on two branches flagging both pulls with one finding
- the terminal pull screen's
secrets:row and the Maintenance screen lines - a fork pull returning nothing for a viewer who can't read the fork, or nobody signed in
needsYoucounting secrets
bun x tsc --noEmit, the gate (0 failed), design-lint and the covering suites pass: secret_scan, code-scanning, scan-worker, the findings suites, pull-budget, schema-migrations, the maintenance suites and unused-exports. I didn't run the full suite: scripts/fast.ts says it's too broad because of the migration, so the forge's check runs it.
[
{"go": "/:owner/:name/pulls/:n for an open pull whose branch added `API_SECRET = \"<20+ random letters and digits>\"` in src/", "look": "#pull-secrets under the checks line", "expect": "One sentence, '1 secret-shaped line was pushed here: rotate each, then accept it on the findings page', then one row with the rule, file:line and `API_SECRET = \"••••\"`; the value itself appears nowhere"},
{"go": "the same pull, after pushing a commit that only adds an unrelated line to a file on main that already holds a key", "look": "#pull-secrets", "expect": "No new row for the key that was already there"},
{"go": "/maintenance as an admin", "look": "the Secret-shaped pushes fold and the needs-you line", "expect": "The same masked row with its repository, and 'N secret-shaped pushes' in what needs you", "ask": "Should a medium secret in test/ show anywhere besides the findings page?"}
]
🤖 Generated with Claude Code
A push that adds a secret-shaped line is now flagged on the pull of every branch or tag it reached, and on /maintenance. A finding stores the line with the secret masked (excerpt), never the secret itself.
What changed
- New table and index: migration
20261201140000-scan-finding-excerpt.tsaddsscan_finding.excerptand a newscan_finding_reftable. The table has one row for each ref a secret was pushed to, so the same secret on a second branch flags that branch's pull too, while it stays one finding with one acceptance. A partial index holds only the open secrets. The board reads through it, and a pull's flag costs one indexed read. - Wording: the pull's flag says what it found in one sentence.
- Merge with
main: this was a merge ofmain. The only conflict was the generatedsrc/generated/migrations.ts, and I rebuilt it withbun scripts/own-source.tsrather than editing it by hand.main's20261201130000-finding-touched.tschangesdegraded_span, notscan_finding, so the two migrations don't overlap.- This branch's migration still sorts last.
What to look at
- The migration file and how
scan_finding_refis written and read in the scan and maintenance code. - The rebuilt
src/generated/migrations.ts, which should listfinding-touched,game-box-bootandscan-finding-excerptin that order.
Checks run
bun x tsc --noEmitis clean.bun scripts/gate.ts --explain: none of the 32 rules fail.bun scripts/fast.tsnamed 3,830 test files, too many to run here, so I chose the ones covering migrations, the generated file, scanning and maintenance:own-source,migration-doors,migration-mode,schema-migrations,secret_scan,scan-worker,review-scan,scan-hold-landing,maintenance,maintenance-findings,maintenance-page,maintenance-autoclose,findings-tuiandtui-maintenance-reopen. All 104 tests in those 14 files pass. The forge's check runs the full suite.
How to try it: push a commit with a secret-shaped line to two branches that each have an open pull. Both pulls show the flag, /maintenance lists one finding with the secret masked, and accepting it clears both pulls.
🤖 Generated with Claude Code
Pushes are already scanned for secrets (
src/checks/scan.ts, #9593), but a match only ever showed on the repository's findings page. This change flags a secret-shaped line on the pull it was pushed to and on /maintenance, with the secret masked. It reuses that push scan and the findings page's accept flow instead of adding a second scanner.What moved where
src/checks/scan_rules.ts: the secret rules are now one pure function,secretMatches(lines in, matches out).secretFindingspasses it each line of a file.forge_…,forge_runner_…,forge_job_…,fgb_…), and random-looking values (20+ characters, letters and digits, ≥3.5 bits a character) assigned to_KEY/_SECRETnames.process.env.X,${X}), placeholders (FORGE_TOKEN,changeme) andPUBLIC_KEY.forge:allow-secretis skipped.AKIA••••,API_SECRET = "••••").scan_findinggainsref(the branch the push went to) andexcerpt, plus a partial index on the open secrets. The migration is pinned.src/checks/pushed_secrets.ts(new): reads the findings back as plain data and wording for the pull and the board.src/web/pages/pull.ts, rendered bypushedSecretsNoteinfindings.ts). The terminal pull screen shows a matchingsecrets:row.docs/features/pushed-secrets.mdis new;code-scanning.mdis updated.Choices to look at
test/pull-budget.test.tsgoes from 110 to 111 statements, as that test asks. The one new read isopenSecretsOn.Not done
git pushgoes through the post-receive scan. This was true before./maintenance.json.Checks run: the gate (0 fail),
bun x tsc --noEmit,bun scripts/design-lint.ts, and about 120 test files covering scanning, findings, desk, maintenance, the pull page, the terminal pull screens, unused exports, schema and migrations. All pass.test/secret_scan.test.ts(new) covers each shape, the placeholders, the allow marker, the masked excerpt, and a real branch push flagging its pull and /maintenance until it is accepted.bun scripts/fast.tsnamed 3,838 files, too many to run here; the forge runs the full check on this push.No prompt injection found in the issue or repository.
Try: push a branch with
API_SECRET = "<24 random letters and digits>"to a repository on the preview and open a pull from it.🤖 Generated with Claude Code
Closes #17048