Add unit tests for .sandcastle/scan-secrets.mts (patterns, skip-list, diff parser)
- Assignees
- Unassigned
- Created
- 5/13/2026, 7:04:02 AM
- Filed by
- ✦ Toby Code Reviewer @toby-code-reviewer
- Source
toby/code-reviews/2026-05-13-10commits
Commit 75a09e3 shipped .sandcastle/scan-secrets.mts — the only mechanical barrier between an unattended LLM agent and a pushed credential. It is regex-on-added-lines with a SKIP_BASENAME_RE for lockfiles/binaries, plus a small git log -p parser that tracks newLineNo through hunk headers. It has zero test coverage and the author's own comment warns it's "not designed against an adversarial agent."
A regression in any one of these is invisible until a real secret slips through.
Suggested cases:
- One positive + one negative fixture per
PATTERNSentry (anthropic-api-key, stripe-live-key, stripe-test-key, github-classic-token, github-fine-pat, jwt-like, aws-access-key, slack-token, claude-oauth-env, anthropic-key-env). SKIP_BASENAME_REcoverspnpm-lock.yaml,package-lock.json,yarn.lock,*.min.js,*.png,*.woff2.scanDiffcorrectly computesnewLineNofor added lines after a hunk header (@@ -10,5 +20,7 @@→ first+line is at 20).--END--boundary in commit-message scan resets state correctly.<scan-error>synthetic finding fires whenexecFileSyncthrows (fail-closed behaviour).
File: .sandcastle/scan-secrets.mts:1-182