Add secret tripwire: sp scan + ls marker + promote guard (#9) - #22
Merged
Conversation
5 tasks
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.
Closes #9
Adds the secret tripwire: scratchpatch now warns when a scratch looks like it holds a credential and refuses to
promoteit into a repo without an explicit override.What's in it
internal/secretpackage — a pure, dependency-free heuristic detector with fixture-driven unit tests. Catches:AKIA…/ASIA…+ fixed-length tail)-----BEGIN … PRIVATE KEY-----)API_KEY=,TOKEN=,SECRET=,PASSWORD=, …) with a non-placeholder valuechangeme,<your-token>,${VAR}), prose, long numbers, and URLs stay quiet.sp scan <id>— reports findings by line number with values masked (never echoes a full secret). Non-zero exit when secrets are found, so it slots into pre-commit hooks / CI.--jsonand--no-colorsupported.sp promoteblock — refuses a tripped scratch unless--allow-secretsis passed. Checked before any move, so a blocked promote changes nothing.sp lsmarker — a 🔑 next to any scratch that trips;sp ls --jsonsets"secret": true.sp scansection,sp promote--allow-secrets).Acceptance criteria
*_API_KEY=, private-key headers, high-entropy tokens)sp lsflags scratches that tripped the detector (🔑 marker)sp promoteblocks on a tripped scratch unless--allow-secretssp scan <id>reports findings with line numbers (no secret values echoed in full)Notes
Finding.internal/secretreturns plain data,renderowns presentation/color, the marker rides as a side map so the store/index stay unaware of the tripwire.go build/go vet/gofmt/go test ./...all green.What's left for a follow-up:
--jsonon the detector is per-scratch viasp scan; a bulksp scan --allcould be a nice future addition.