Secret scanner for staged git diffs — short, detached, on the beat.
In music, staccato means each note is played short and separate. Before a commit lands, STACCATO looks at every note you are about to play — the staged changes — and stops you if one of them is a key.
STACCATO scans only what you are about to stage — the added lines of the staged diff — and tells you, to the exact source line, which secret you were about to commit. Local, offline, zero dependencies, and small enough to run as a git pre-commit hook or a CI gate.
staccato pre-commitIf it finds something: exit 1, the commit stops.
git clone https://github.com/BeethovenDev/staccato.git
cd staccato
python -m pip install -e .Wire it as a pre-commit hook:
printf '#!/bin/sh\npython -m staccato pre-commit || exit 1\n' > .git/hooks/pre-commit
chmod +x .git/hooks/pre-commit| Command | Description |
|---|---|
staccato pre-commit |
Scan the staged diff (git diff --cached), additions only |
staccato scan PATH... |
Scan files/directories (whole tree); --entropy for bare high-entropy tokens |
staccato allow SECRET |
Add a secret's fingerprint to .staccato-allow |
staccato list-allowed |
Print allowlist fingerprints |
Every command accepts --json. Exit codes: 0 clean · 1 findings ·
2 cannot scan.
- A named pattern catalogue: AWS, GitHub, Slack, Google, Stripe, JWTs,
private-key blocks, bearer headers, and generic assignments
(
api_key = …,token = …, …). - Values captured by generic patterns must clear a Shannon-entropy bar and
must not look like placeholders (
changeme,<your-…>,test, …) — so a scanner that screams about every constant stays quiet. --entropyadditionally flags bare tokens that simply look random — opt in, because that one is noisy by design.
Decide once, then every time:
# initial sweep: mark every current secret as known
staccato --learn scan legacy/ --allowlist .staccato-allow
# from then on: only new secrets block
staccato pre-commit --allowlist .staccato-allowOr skip a single line deliberately:
password = "TotallyARealSecret" # staccato:allowgit diff --cached staged changes only
│
parsed + additions → (+path, source line, body)
│
patterns + entropy checks │ allowlist of sha256 fingerprints
│ │ inline "staccato:allow" markers
▼
findings → FILE:LINE:COL [rule] → exit 0 | 1 | 2
History is deliberately not scanned — STACCATO guards the door you are about to walk through, not the room you already left. If a secret was already committed, rotate it; a scanner cannot un-commit a key.
- Additions only. A removed line is not a risk you are about to introduce.
- No false confidence. Clean means "no known pattern matched here" — the README of your threat model says exactly that.
- Fingerprints, not plaintext. The allowlist stores only SHA-256.
MIT