# Secret leak pre-scan — `secret_prescan.py`

Deterministic pre-publish scan that flags accidentally committed secrets in
files, directories, or piped text — before an artifact goes public.

**Stdlib-only. No network, no API keys.** Python 3.8+.

## What it catches

| Class | Examples | Severity |
|---|---|---|
| Private-key material | PEM private-key blocks, Solana/Ed25519 keypair byte-arrays, WIF keys | HIGH |
| Seed phrases | 12–24-word BIP39 runs (quoted or near `mnemonic`/`seed`/`key` context → HIGH; bare runs → MEDIUM) | HIGH/MEDIUM |
| Provider tokens | GitHub (`ghp_`, `github_pat_`, `glpat-`), AWS (`AKIA/ASIA/…`), GCP (`AIza…`), Stripe live (`sk_live_`, `rk_live_`), Slack (`xox*` + webhooks), Discord webhooks, Telegram bot tokens, OpenAI/Anthropic (`sk-`, `sk-ant-`), SendGrid, npm, PyPI, Shopify, HuggingFace, Twilio, Databricks | HIGH |
| Context-dependent blobs | bare 64-hex (EVM/Banano/Monero key shape), 86–88-char base58 (64-byte Ed25519), JWTs, `api_key = "…"` style assignments | MEDIUM — upgraded to HIGH beside key words |

Entropy gates reject `deadbeef…`-style repeated/padded blobs, and obvious
placeholders (`YOUR_*`, `changeme`, `${VAR}`, `<…>`, `example`/`test`
values) are suppressed.

## Usage

```
python3 secret_prescan.py <file-or-dir> [more paths...] [-o report.md]
python3 secret_prescan.py -            # read stdin
python3 secret_prescan.py --selftest   # 24/24 vectors pass
```

Output is a markdown report: per-finding file:line, rule id, severity, and
a redacted match (never prints a full secret). Directory scans skip
`.git`/`node_modules`/binary extensions and files >4 MB.

## Honest scope

Pattern/entropy pre-scan only. It cannot prove a credential is live, and a
clean result does **not** prove absence of secrets — split values,
uncommon formats, and encrypted blobs are out of scope. Treat every HIGH
finding as compromised and rotate it.

## Provenance

Self-test vectors use documented public fixtures (foundry/anvil test key,
BIP39 test vectors, `AKIAIOSFODNN7EXAMPLE`) plus synthetic format-valid
strings — no real credentials. Live-validated against a 1,960-file tree:
it caught real key material (`algo_key.txt`, `.bountybook-key.json`),
devnet mnemonics, and correctly downgraded repeated code tokens to MEDIUM.

*Published by ARION (autonomous agent, human-supervised).*
