feat(secrets): git leak guard — pre-push scan blocks pushes containing secret values (#106) #119
No reviewers
Labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Cloonar/coding-lab!119
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "afk/106"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
The second layer of the secrets harness (#104 → #106 → #105/#107/#108): lab's pre-push hook now guards every ready repo and gains a server-side secret leak scan. A push whose outgoing diff carries a repo secret value — plain or base64/hex/urlencoded — is blocked, naming the secret and file, never the value.
How it works
POST /agent/v1/secrets/scan(run-token scoped, so an instance can only scan against its own repo): streams the uploaded patch through the #104 matcher built from the repo's freshly decrypted values. Added lines only — blocking a removal would strand the fix behind the fail-closed guard. Bounded memory on arbitrarily long lines, matcher reset at file headers (no cross-file false positives), 256 MiB cap on every path, zero-secret repos pass without decrypting. Values appear in no response, error, or log.secret scan <rev-arg>...collects the outgoing range with onegit log --format= -p -mand streams it up. Fail closed: findings, git failure, server unreachable, non-2xx → exit 1; clean pass → silent 0.LAB_TOKENpresent → scan mandatory, any failure refuses the push; absent (a human pushing by hand) → loud one-line warning, push proceeds — the human needs neither token nor labctl. Incogni checks render only when patterns exist and keep working alongside.installGuardHookat clone completion, incogni toggles (toggle-off re-renders without patterns instead of removing), and startup reconcile for every ready repo;core.hooksPathstays pinned permanently. Startup reconcile is also how hook-content changes roll out. Seeded context files now warn agents that pushes are scanned and that recovery is rewriting the offending commits.Acceptance criteria
TestSecretScanEndToEnd(real git repo → real labctl → real agentapi handler → matcher), plus per-form handler testsTestSecretScanCleanPass,TestSecretScanZeroSecretsTestSecretScanServerUnreachable,TestPrePushHook_secretScanFailsClosedWithoutLabctlTestPrePushHook_secretScanSkippedWithoutToken(realgit push, stub labctl proves it's the token check that skips)TestPrePushHookScript_claudeGolden,TestPrePushHook_incogniStillBlocksAlongsideSecretSkipNotes
run_title(merged second) moves to 0009. Every store-backed test failed before this.++-prefixed added lines misparsed as+++headers and skipped) and an unbounded body drain on the zero-secret path.internal/tmuxxintegration tests fail in this sandbox on pristine main too (tmux sessions cannot start here) — unrelated and untouched.Closes #106
🤖 Generated with Claude Code
https://claude.ai/code/session_014gdntmghZvF58U7uxzghgr