Repository navigation
Conversation
…closed --scan-secrets ran gitleaks on the raw transcript .jsonl, then imported a page rendered from it. gitleaks' assignment rules don't match across a JSON-escaped quote (KEY=\"v\" on disk), so a secret the rendered page shows as KEY="v" was imported unflagged. And the gate skipped a file only on scanner "gitleaks" with findings, so a scan that errored (non-zero exit, 16MB maxBuffer overflow on a file with many findings, unparseable report) or could not run (gitleaks missing, slow-probe cooldown) imported the file unscanned. Scan the rendered page body, the exact bytes writeStaged() writes, via a new secretScanText() helper, and skip the file whenever the scan did not complete. Skipped files stay out of the state file, so the next run retries them. Reword the helper warnings and setup-gbrain/memory.md, which described the fail-open as intended. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
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 |
Contributor
Author
garrytan#2959 (v1.91.2.0) merged this branch's commit verbatim as the first item of its reliability wave, plus follow-up hardening (scan-mode-aware dedup, snapshot-bound scans at the import boundary). Every conflict resolves to main's side. git's clean text merge of lib/gstack-memory-helpers.ts had kept both copies of secretScanText (a duplicate export), so that file is main's too. The merged tree is identical to main. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Contributor
Author
|
Superseded by #2959, which merged this change (plus follow-up hardening) in v1.91.2.0. Thanks for folding it in! |
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.

Why (in your own words)
I ran
/setup-gbrainwith--scan-secretsexpecting nothing secret to reach the brain. It skipped 30 files, but gitleaks still flags 4 of the 159 pages it imported. The scan ran on the raw.jsonl, where JSON escapes the quotes around a value (KEY=\"value\"), and gitleaks' assignment rules don't match that. The page that actually gets imported has the unescapedKEY="value", which they do match. Separately, when gitleaks can't produce a result (non-zero exit, a 16 MBmaxBufferoverflow on a file with many findings, missing binary, slow-probe cooldown), the file was imported unscanned. This PR scans the exact bytes that get staged and, under--scan-secrets, skips any file it could not scan. Fixes #2944.Live evidence
Standalone: the escaping gap (gitleaks 8.30.1, random value):
End-to-end:
bin/gstack-memory-ingest.ts --bulk --scan-secretswith the real gitleaks 8.30.1, a throwawayHOME, one synthetic Codex rollout per scenario (random fake values), and agbrainshim that snapshots the staging dir. The last column is gitleaks run over that snapshot, i.e. what would have been imported.Before (
main, 636175d):After (this branch):
Tests.
bun test test/gstack-memory-ingest.test.ts test/gstack-memory-helpers.test.ts: 80 pass, 0 fail. Againstmain's source with these tests: the 3 new ingest tests fail, and the helpers file fails to load (nosecretScanTextexport).What changed
lib/gstack-memory-helpers.ts: newsecretScanText(text). It writes the text to a private temp file (mkdtemp0700, file0600), runs the unchangedsecretScanFile()on it, and removes it infinally. A temp-file failure returnsscanner: "error", never an empty "clean" result. The absent/slow-probe warnings no longer say files "go unscanned" / "secret scanning disabled", since the ingest now skips them.bin/gstack-memory-ingest.tspreparePages(): the scan moves from before parsing to afterrenderPageBody(), onrendered_body, the stringwriteStaged()writes verbatim (disambiguateSlugs()only renames). Under--scan-secretsa file is skipped on any finding or whenscanner !== "gitleaks". Skips are counted in the existingskipped (secret-scan)line, soBulkResultis unchanged. The stderr line says which:[secret-scan match]vs[secret-scan error|missing] … (gitleaks could not scan it). As before, skipped files aren't recorded in state, so the next run retries them.setup-gbrain/memory.md:--scan-secretsnow scans the rendered page, and without gitleaks files are skipped, not imported unscanned.installFakeGitleaks()whosedetectkeys off the content of the scanned file. The existing--scan-secretstest keyed off the source path containing "dirty", which no longer reaches gitleaks. New tests:errorandmissingsecretScanTextscans the exact text, cleans up its temp file, and reportsmissingrather than cleanDeliberate behavior change for review: the raw-file scan is replaced, not kept alongside. Every staged byte is in
rendered_body. Keeping both would double the per-file gitleaks cost (~256 ms/file) and keep skipping files whose only findings are in content the page never includes, e.g. tool results andfunction_call_output, whichparseTranscriptJsonl()drops. Happy to keep the source scan as an extra gate if you'd rather.Scope
lib/gstack-memory-helpers.ts,bin/gstack-memory-ingest.ts,setup-gbrain/memory.md,test/gstack-memory-helpers.test.ts,test/gstack-memory-ingest.test.tsbun run teston this branch and onmain, same machine and session: identical failing-test sets (389 each). All of those are in PTY/CSO/Codex/autoplan suites that need a less locked-down environment than mine; none are in memory-ingest, helpers or setup-gbrain.preparePages()before either staging branch, but I didn't exercise itGSTACK_INGEST_RESUME_DIRpath: a dir staged earlier without--scan-secretsis still imported as-is on resumeLiveness proof (required for external contributors)
To be attached by @brucek (screenshot with
GSTACK PRtyped live) before this PR leaves draft.Checklist
GSTACK PRtyped live into a real surface) or PR author is @garrytan (owner exemption)--scan-secretsmisses JSON-escaped secrets and fails open when gitleaks can't scan #2944🤖 Generated with Claude Code