Skip to content
BeethovenDevPublic

About

Staged-diff secret scanner with entropy gates and allowlists.

Topics

Resources

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

1 Commit

Folders and files

Repository files navigation

STACCATO

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.

License: MIT Python Dependencies


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-commit

If it finds something: exit 1, the commit stops.

Install

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

Commands

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.

Detection model

  • 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.
  • --entropy additionally flags bare tokens that simply look random — opt in, because that one is noisy by design.

Baseline sweeps

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-allow

Or skip a single line deliberately:

password = "TotallyARealSecret"  # staccato:allow

How it works

git 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.

Philosophy

  • 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.

License

MIT

About

Staged-diff secret scanner with entropy gates and allowlists.

Topics

Resources

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages