feat(secrets): git leak guard — pre-push scan blocks pushes containing secret values #106
Labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Cloonar/coding-lab#106
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
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?
What to build
Extend the bare reference repo's pre-push hook (the incogni guard site, seeder-installed, fires for pushes from every linked worktree) with a secrets leak check: the hook shells out to a new
labctl secret scan <range>, which sends the outgoing diff to the lab server; the server scans it against the repo's decrypted secret values via the matcher from #104 (exact + base64/hex/urlencoded). A hit blocks the push with a message naming the matching secret and offending file — name only, never the value — so the agent can fix and re-push.Secret values never appear in the hook script or on disk outside the vault.
Failure split (grill decision):
LAB_TOKENpresent but scan fails (server down, 5xx): fail closed — an agent push must never skip the guard.LAB_TOKENin env (a human pushing by hand from a parked worktree): skip the scan with a loud one-line warning — the threat model is the sloppy agent, not the operator.Respect the existing hook rules: lab's marker identifies its own hook, a foreign pre-push hook is never overwritten, and the incogni checks in the same hook keep working.
Acceptance criteria
Blocked by
Agent Brief
Category: enhancement
Summary: Extend the seeder-installed pre-push hook in the bare reference repo with a secrets leak check: a new
labctl secret scan <range>sends the outgoing diff to the lab server, which scans it against the repo's decrypted secret values; a hit blocks the push, naming the secret and file but never the value.Current behavior:
The seeder installs a lab-marked pre-push hook in the bare reference repo (the incogni guard site); it fires for pushes from every linked worktree, never overwrites a foreign hook, and is covered by a golden-file test in the seeder package. It performs no secrets check.
labctlhassecret listandsecret exec(#104) but noscansubcommand, and the server has no diff-scanning endpoint.Desired behavior:
The hook shells out to
labctl secret scan <range>for the outgoing range. The server scans the diff against the repo's decrypted secret values using the shared streaming matcher (exact + base64/hex/URL-encoded forms). On a hit the push is blocked with a message naming the matching secret and offending file — name only, never the value. Secret values never appear in the hook script, on disk outside the vault, or in any error/log/response.Failure split (grill decision):
LAB_TOKENpresent but the scan fails (server down, 5xx): fail closed — an agent push must never skip the guard.LAB_TOKENin env (a human pushing by hand from a parked worktree): skip with a loud one-line warning — the threat model is the sloppy agent, not the operator.Key interfaces:
labctl secret scan <range>subcommand — collects the outgoing diff and submits it viaLAB_TOKENsecrets.NewMatcher/Feedover the submitted diff; response carries secret names + file paths onlyAcceptance criteria:
LAB_TOKENset and the server unreachable, the push is blocked with a clear errorLAB_TOKEN, the push proceeds with a warning lineOut of scope: