token-hunt 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- token_hunt-0.1.0/.claude-plugin/marketplace.json +18 -0
- token_hunt-0.1.0/.gitattributes +39 -0
- token_hunt-0.1.0/.github/FUNDING.yml +4 -0
- token_hunt-0.1.0/.github/ISSUE_TEMPLATE/bug-report.md +41 -0
- token_hunt-0.1.0/.github/ISSUE_TEMPLATE/feature-request.md +22 -0
- token_hunt-0.1.0/.github/PULL_REQUEST_TEMPLATE.md +20 -0
- token_hunt-0.1.0/.github/workflows/release.yml +26 -0
- token_hunt-0.1.0/.github/workflows/test.yml +27 -0
- token_hunt-0.1.0/.gitignore +18 -0
- token_hunt-0.1.0/.gitleaksignore +45 -0
- token_hunt-0.1.0/CHANGELOG.md +35 -0
- token_hunt-0.1.0/CONTRIBUTING.md +40 -0
- token_hunt-0.1.0/LICENSE +113 -0
- token_hunt-0.1.0/PKG-INFO +193 -0
- token_hunt-0.1.0/README.md +166 -0
- token_hunt-0.1.0/SECURITY.md +24 -0
- token_hunt-0.1.0/docs/make-demo-gif.py +281 -0
- token_hunt-0.1.0/docs/superpowers/plans/2026-07-27-token-hunt-pro-v0.2.md +1974 -0
- token_hunt-0.1.0/docs/superpowers/plans/2026-07-27-token-hunt-v0.1.md +3505 -0
- token_hunt-0.1.0/docs/superpowers/research/hook-rewrite-capability.md +102 -0
- token_hunt-0.1.0/docs/superpowers/specs/2026-07-27-token-hunt-design.md +353 -0
- token_hunt-0.1.0/docs/superpowers/specs/2026-07-27-token-hunt-pro-tier-design.md +174 -0
- token_hunt-0.1.0/plugin/.claude-plugin/plugin.json +15 -0
- token_hunt-0.1.0/plugin/hooks/post-bash.sh +53 -0
- token_hunt-0.1.0/plugin/hooks/post-read.sh +54 -0
- token_hunt-0.1.0/plugin/hooks/post-write.sh +47 -0
- token_hunt-0.1.0/plugin/hooks/pre-bash.sh +49 -0
- token_hunt-0.1.0/plugin/hooks/pre-write.sh +41 -0
- token_hunt-0.1.0/plugin/hooks/user-prompt-submit.sh +37 -0
- token_hunt-0.1.0/plugin/hooks.json +64 -0
- token_hunt-0.1.0/pyproject.toml +55 -0
- token_hunt-0.1.0/src/token_hunt/__init__.py +3 -0
- token_hunt-0.1.0/src/token_hunt/allowlist.py +68 -0
- token_hunt-0.1.0/src/token_hunt/cli.py +194 -0
- token_hunt-0.1.0/src/token_hunt/engine.py +52 -0
- token_hunt-0.1.0/src/token_hunt/entropy.py +52 -0
- token_hunt-0.1.0/src/token_hunt/escape.py +91 -0
- token_hunt-0.1.0/src/token_hunt/patterns/builtin.toml +371 -0
- token_hunt-0.1.0/src/token_hunt/patterns/rotate-urls.toml +204 -0
- token_hunt-0.1.0/src/token_hunt/patterns_loader.py +47 -0
- token_hunt-0.1.0/src/token_hunt/regex_scanner.py +49 -0
- token_hunt-0.1.0/src/token_hunt/store.py +98 -0
- token_hunt-0.1.0/src/token_hunt/types.py +34 -0
- token_hunt-0.1.0/tests/__init__.py +0 -0
- token_hunt-0.1.0/tests/conftest.py +11 -0
- token_hunt-0.1.0/tests/fixtures.py +29 -0
- token_hunt-0.1.0/tests/hooktest.py +42 -0
- token_hunt-0.1.0/tests/test_allowlist.py +69 -0
- token_hunt-0.1.0/tests/test_builtin_providers.py +157 -0
- token_hunt-0.1.0/tests/test_cli.py +155 -0
- token_hunt-0.1.0/tests/test_e2e_hooks.py +100 -0
- token_hunt-0.1.0/tests/test_engine.py +67 -0
- token_hunt-0.1.0/tests/test_entropy.py +42 -0
- token_hunt-0.1.0/tests/test_escape.py +68 -0
- token_hunt-0.1.0/tests/test_hook_optout.py +42 -0
- token_hunt-0.1.0/tests/test_hook_post_bash.py +22 -0
- token_hunt-0.1.0/tests/test_hook_post_read.py +22 -0
- token_hunt-0.1.0/tests/test_hook_pre_bash.py +30 -0
- token_hunt-0.1.0/tests/test_hook_pre_write.py +19 -0
- token_hunt-0.1.0/tests/test_hook_user_prompt_submit.py +25 -0
- token_hunt-0.1.0/tests/test_patterns_loader.py +31 -0
- token_hunt-0.1.0/tests/test_regex_scanner.py +81 -0
- token_hunt-0.1.0/tests/test_store.py +84 -0
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json.schemastore.org/claude-code-plugin-marketplace.json",
|
|
3
|
+
"name": "JordanNewell",
|
|
4
|
+
"owner": {
|
|
5
|
+
"name": "Jordan Newell",
|
|
6
|
+
"url": "https://jordannewell.com"
|
|
7
|
+
},
|
|
8
|
+
"plugins": [
|
|
9
|
+
{
|
|
10
|
+
"name": "token-hunt",
|
|
11
|
+
"source": "./plugin",
|
|
12
|
+
"description": "Catch secrets at chat time, not commit time. Hook-based scanner for Claude Code.",
|
|
13
|
+
"version": "0.1.0",
|
|
14
|
+
"category": "security",
|
|
15
|
+
"keywords": ["security", "secrets", "leak-prevention", "hooks"]
|
|
16
|
+
}
|
|
17
|
+
]
|
|
18
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
# Normalize line endings: LF in repo, LF in working copy.
|
|
2
|
+
# Ends the "LF will be replaced by CRLF" warnings.
|
|
3
|
+
* text=auto eol=lf
|
|
4
|
+
|
|
5
|
+
# Explicit text types
|
|
6
|
+
*.md text eol=lf
|
|
7
|
+
*.json text eol=lf
|
|
8
|
+
*.js text eol=lf
|
|
9
|
+
*.ts text eol=lf
|
|
10
|
+
*.tsx text eol=lf
|
|
11
|
+
*.jsx text eol=lf
|
|
12
|
+
*.css text eol=lf
|
|
13
|
+
*.html text eol=lf
|
|
14
|
+
*.yml text eol=lf
|
|
15
|
+
*.yaml text eol=lf
|
|
16
|
+
*.toml text eol=lf
|
|
17
|
+
*.sh text eol=lf
|
|
18
|
+
*.py text eol=lf
|
|
19
|
+
*.go text eol=lf
|
|
20
|
+
*.rs text eol=lf
|
|
21
|
+
*.txt text eol=lf
|
|
22
|
+
|
|
23
|
+
# Binaries — never touch
|
|
24
|
+
*.png binary
|
|
25
|
+
*.jpg binary
|
|
26
|
+
*.jpeg binary
|
|
27
|
+
*.gif binary
|
|
28
|
+
*.webp binary
|
|
29
|
+
*.svg text eol=lf
|
|
30
|
+
*.ico binary
|
|
31
|
+
*.pdf binary
|
|
32
|
+
*.mp4 binary
|
|
33
|
+
*.mov binary
|
|
34
|
+
*.mp3 binary
|
|
35
|
+
*.wav binary
|
|
36
|
+
*.zip binary
|
|
37
|
+
*.gz binary
|
|
38
|
+
*.7z binary
|
|
39
|
+
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: Bug Report
|
|
3
|
+
about: Report a false positive, false negative, or crash
|
|
4
|
+
title: "[BUG] "
|
|
5
|
+
labels: bug, triage
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
## Summary
|
|
9
|
+
|
|
10
|
+
[One sentence describing the problem]
|
|
11
|
+
|
|
12
|
+
## Repro
|
|
13
|
+
|
|
14
|
+
```bash
|
|
15
|
+
# Steps to reproduce
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
## Expected
|
|
19
|
+
|
|
20
|
+
[What should have happened]
|
|
21
|
+
|
|
22
|
+
## Actual
|
|
23
|
+
|
|
24
|
+
[What actually happened]
|
|
25
|
+
|
|
26
|
+
## Environment
|
|
27
|
+
|
|
28
|
+
- token-hunt version: `token-hunt --version`
|
|
29
|
+
- Python version:
|
|
30
|
+
- OS:
|
|
31
|
+
- Claude Code version (if plugin):
|
|
32
|
+
|
|
33
|
+
## Pattern that fired (or didn't)
|
|
34
|
+
|
|
35
|
+
[kind, e.g. `zai-api-key`]
|
|
36
|
+
|
|
37
|
+
## Output of `token-hunt list`
|
|
38
|
+
|
|
39
|
+
```
|
|
40
|
+
[paste here, redact fingerprints if real]
|
|
41
|
+
```
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: Feature Request
|
|
3
|
+
about: Suggest a new provider rule, detection class, or feature
|
|
4
|
+
title: "[FEAT] "
|
|
5
|
+
labels: enhancement, triage
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
## Summary
|
|
9
|
+
|
|
10
|
+
[One sentence describing the request]
|
|
11
|
+
|
|
12
|
+
## Use case
|
|
13
|
+
|
|
14
|
+
[What problem does this solve? When does it come up?]
|
|
15
|
+
|
|
16
|
+
## Proposed solution
|
|
17
|
+
|
|
18
|
+
[Describe the approach. Code samples welcome.]
|
|
19
|
+
|
|
20
|
+
## Alternatives considered
|
|
21
|
+
|
|
22
|
+
[Any other ways to solve this — and why they don't work]
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
## Summary
|
|
2
|
+
|
|
3
|
+
[One paragraph. What does this change do?]
|
|
4
|
+
|
|
5
|
+
## Why
|
|
6
|
+
|
|
7
|
+
[The motivation. Link any issues.]
|
|
8
|
+
|
|
9
|
+
## Testing
|
|
10
|
+
|
|
11
|
+
- [ ] Added tests for new behavior
|
|
12
|
+
- [ ] All tests pass: `pytest`
|
|
13
|
+
- [ ] Lint clean: `ruff check .`
|
|
14
|
+
- [ ] Manually verified the change works as described
|
|
15
|
+
|
|
16
|
+
## Checklist
|
|
17
|
+
|
|
18
|
+
- [ ] No AI-attribution trailers in commit messages
|
|
19
|
+
- [ ] No real secrets in test fixtures (use the fakes in `tests/fixtures.py`)
|
|
20
|
+
- [ ] CHANGELOG updated if user-facing
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
name: release
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
tags: ["v*"]
|
|
6
|
+
|
|
7
|
+
permissions:
|
|
8
|
+
contents: write
|
|
9
|
+
|
|
10
|
+
jobs:
|
|
11
|
+
release:
|
|
12
|
+
runs-on: ubuntu-latest
|
|
13
|
+
steps:
|
|
14
|
+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
|
|
15
|
+
- uses: actions/setup-python@a26af69be951a213d495a4c3e4e402052b7b6f6d # v5
|
|
16
|
+
with:
|
|
17
|
+
python-version: "3.12"
|
|
18
|
+
- run: pip install build twine
|
|
19
|
+
- run: python -m build
|
|
20
|
+
- uses: softprops/action-gh-release@da05d552573ad5aba039eaac05058a918a7bf631 # v2
|
|
21
|
+
with:
|
|
22
|
+
generate_release_notes: true
|
|
23
|
+
- run: twine upload dist/*
|
|
24
|
+
env:
|
|
25
|
+
TWINE_USERNAME: __token__
|
|
26
|
+
TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
name: test
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: [main]
|
|
6
|
+
pull_request:
|
|
7
|
+
branches: [main]
|
|
8
|
+
|
|
9
|
+
jobs:
|
|
10
|
+
test:
|
|
11
|
+
runs-on: ${{ matrix.os }}
|
|
12
|
+
strategy:
|
|
13
|
+
matrix:
|
|
14
|
+
os: [ubuntu-latest, macos-latest, windows-latest]
|
|
15
|
+
python-version: ["3.10", "3.11", "3.12"]
|
|
16
|
+
steps:
|
|
17
|
+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
|
|
18
|
+
- uses: actions/setup-python@a26af69be951a213d495a4c3e4e402052b7b6f6d # v5
|
|
19
|
+
with:
|
|
20
|
+
python-version: ${{ matrix.python-version }}
|
|
21
|
+
- run: pip install -e ".[dev]"
|
|
22
|
+
- run: ruff check .
|
|
23
|
+
- run: pytest --cov=token_hunt --cov-report=xml
|
|
24
|
+
- uses: codecov/codecov-action@b9fd7d96f2d891b39a3e3a623df4d0ed71ef3841 # v4
|
|
25
|
+
if: matrix.os == 'ubuntu-latest' && matrix.python-version == '3.12'
|
|
26
|
+
with:
|
|
27
|
+
file: ./coverage.xml
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
# token-hunt test fixtures: shape-correct FAKE keys generated for
|
|
2
|
+
# tests/test_builtin_providers.py — not real credentials. No real secrets
|
|
3
|
+
# ship in this repo. Fingerprints below verified 2026-10-15.
|
|
4
|
+
tests/__pycache__/test_builtin_providers.cpython-313-pytest-8.4.2.pyc:jwt:13
|
|
5
|
+
tests/test_builtin_providers.py:generic-api-key:100
|
|
6
|
+
tests/test_builtin_providers.py:generic-api-key:101
|
|
7
|
+
tests/test_builtin_providers.py:generic-api-key:103
|
|
8
|
+
tests/test_builtin_providers.py:generic-api-key:104
|
|
9
|
+
tests/test_builtin_providers.py:generic-api-key:106
|
|
10
|
+
tests/test_builtin_providers.py:generic-api-key:107
|
|
11
|
+
tests/test_builtin_providers.py:generic-api-key:109
|
|
12
|
+
tests/test_builtin_providers.py:generic-api-key:110
|
|
13
|
+
tests/test_builtin_providers.py:generic-api-key:112
|
|
14
|
+
tests/test_builtin_providers.py:generic-api-key:113
|
|
15
|
+
tests/test_builtin_providers.py:generic-api-key:116
|
|
16
|
+
tests/test_builtin_providers.py:generic-api-key:118
|
|
17
|
+
tests/test_builtin_providers.py:generic-api-key:119
|
|
18
|
+
tests/test_builtin_providers.py:generic-api-key:121
|
|
19
|
+
tests/test_builtin_providers.py:generic-api-key:122
|
|
20
|
+
tests/test_builtin_providers.py:generic-api-key:148
|
|
21
|
+
tests/test_builtin_providers.py:generic-api-key:91
|
|
22
|
+
tests/test_builtin_providers.py:generic-api-key:92
|
|
23
|
+
tests/test_builtin_providers.py:generic-api-key:94
|
|
24
|
+
tests/test_builtin_providers.py:generic-api-key:95
|
|
25
|
+
tests/test_builtin_providers.py:generic-api-key:97
|
|
26
|
+
tests/test_builtin_providers.py:generic-api-key:98
|
|
27
|
+
tests/test_builtin_providers.py:generic-api-key:115
|
|
28
|
+
tests/test_builtin_providers.py:generic-api-key:25
|
|
29
|
+
tests/test_builtin_providers.py:generic-api-key:46
|
|
30
|
+
tests/test_builtin_providers.py:generic-api-key:49
|
|
31
|
+
tests/test_builtin_providers.py:generic-api-key:52
|
|
32
|
+
tests/test_builtin_providers.py:generic-api-key:53
|
|
33
|
+
tests/test_builtin_providers.py:generic-api-key:55
|
|
34
|
+
tests/test_builtin_providers.py:generic-api-key:58
|
|
35
|
+
tests/test_builtin_providers.py:generic-api-key:61
|
|
36
|
+
tests/test_builtin_providers.py:generic-api-key:62
|
|
37
|
+
tests/test_builtin_providers.py:generic-api-key:70
|
|
38
|
+
tests/test_builtin_providers.py:generic-api-key:71
|
|
39
|
+
tests/test_builtin_providers.py:generic-api-key:73
|
|
40
|
+
tests/test_builtin_providers.py:generic-api-key:74
|
|
41
|
+
tests/test_builtin_providers.py:generic-api-key:76
|
|
42
|
+
tests/test_builtin_providers.py:generic-api-key:79
|
|
43
|
+
tests/test_builtin_providers.py:generic-api-key:82
|
|
44
|
+
tests/test_builtin_providers.py:generic-api-key:85
|
|
45
|
+
tests/test_builtin_providers.py:jwt:88
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to token-hunt are documented here.
|
|
4
|
+
Format based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
|
5
|
+
project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
6
|
+
|
|
7
|
+
## [Unreleased]
|
|
8
|
+
|
|
9
|
+
### Added
|
|
10
|
+
- Provider coverage expanded 12 → 37 rules for LLM-inference parity with the 53 providers Curtis ships: OpenRouter, Groq, Together, Fireworks, xAI, Perplexity, Hugging Face, Cerebras, Replicate, Vercel AI Gateway, NVIDIA NIM, Chutes, Requesty, Novita, Upstage, Baseten, Baidu Qianfan, fal.ai, Alibaba DashScope, Moonshot Kimi, Mistral, Cohere, Scaleway.
|
|
11
|
+
- Generic fallback rules: unattributed `sk-` 32-char key (DeepSeek / StepFun / Moonshot / SiliconFlow / Poe / Qwen shape) and generic JWT (MiniMax / DeepInfra / Crusoe).
|
|
12
|
+
- OpenAI rule tightened to the T3BlbkFJ marker shape — no longer double-fires with the generic `sk-` rule.
|
|
13
|
+
- Prefixless shapes (Mistral, Cohere, Scaleway) and generic-prefix shapes (Novita, Upstage) are keyword-gated: the provider name must appear in the scanned text before the regex is tried.
|
|
14
|
+
- Providers with no publicly documented key format get **keyword-gated opaque rules** (SambaNova, Nebius, AI21, OVHcloud, FriendliAI, GMI Cloud, Crusoe, Featherless, DeepInfra, Inference.net, BytePlus): provider name in text + 32+-char token. Low-precision by design — attribution + rotation URL, not shape confidence. Shape-verified rules stay provider-documented or multi-scanner-observed only; no guessed regexes.
|
|
15
|
+
|
|
16
|
+
### Planned for v0.1.1
|
|
17
|
+
- Silent redaction via `hookSpecificOutput.updatedToolOutput` for PostToolUse hooks (replaces current WARN-only behavior for Bash/Read/Write outputs)
|
|
18
|
+
- Active verification mode (TruffleHog-style "is this key actually live?")
|
|
19
|
+
- `--file-path` flag on `scan --stdin` to enable path-based allowlist for PostToolUse:Read
|
|
20
|
+
|
|
21
|
+
## [0.1.0] — 2026-07-27
|
|
22
|
+
|
|
23
|
+
### Added
|
|
24
|
+
- Initial release.
|
|
25
|
+
- Detection core: regex patterns (12 built-in providers), bash escape-hatch detector, entropy candidates.
|
|
26
|
+
- Claude Code plugin with 6 hook scripts covering 8 detection rows.
|
|
27
|
+
- CLI peer (`pip install token-hunt`) with `scan`, `list`, `close`, `watch` commands.
|
|
28
|
+
- Pattern layering: builtin → `~/.token-hunt/patterns.local.toml` → `./.token-hunt/patterns.local.toml`.
|
|
29
|
+
- Allowlist engine (path-based + fingerprint-based).
|
|
30
|
+
- `rotations.log` JSONL store with 72-hour OVERDUE tracking.
|
|
31
|
+
- Built-in providers: Z.ai, Anthropic, GitHub (classic + fine-grained), GitLab, Figma, PyPI, npm, Linear, Stripe, OpenAI, Slack.
|
|
32
|
+
- Bash escape-hatch detection (the unique IP — `${VAR:+SET}${VAR:-UNSET}` bug class).
|
|
33
|
+
- `TOKEN_HUNT_DISABLE=1` env var opt-out (skip all hooks).
|
|
34
|
+
- `TOKEN_HUNT_ALLOW=1` env var bypass (one-shot override of BLOCK hooks).
|
|
35
|
+
- Fail-closed behavior: scanner crashes BLOCK with bypass hint, never silently allow.
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
# Contributing
|
|
2
|
+
|
|
3
|
+
Thanks for considering a contribution.
|
|
4
|
+
|
|
5
|
+
## Setup
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
git clone https://github.com/JordanNewell/token-hunt
|
|
9
|
+
cd token-hunt
|
|
10
|
+
pip install -e ".[dev]"
|
|
11
|
+
pytest
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
## Development workflow
|
|
15
|
+
|
|
16
|
+
1. Open an issue describing the change (skip for trivial fixes).
|
|
17
|
+
2. Branch from `main`: `feat/<short-desc>` or `fix/<short-desc>`.
|
|
18
|
+
3. Add tests for new behavior. TDD preferred.
|
|
19
|
+
4. Run `pytest` and `ruff check .` before committing.
|
|
20
|
+
5. Open a PR — describe the change + link the issue.
|
|
21
|
+
|
|
22
|
+
## Adding a new provider pattern
|
|
23
|
+
|
|
24
|
+
1. Add a rule to `src/token_hunt/patterns/builtin.toml` (gitleaks-compatible TOML format).
|
|
25
|
+
2. Add provider metadata to `src/token_hunt/patterns/rotate-urls.toml`.
|
|
26
|
+
3. Add a fake-format test constant to `tests/fixtures.py`.
|
|
27
|
+
4. Add a detection test to `tests/test_regex_scanner.py`.
|
|
28
|
+
|
|
29
|
+
## Code style
|
|
30
|
+
|
|
31
|
+
- Python 3.10+ (use `from __future__ import annotations`).
|
|
32
|
+
- Line length 100 (ruff default).
|
|
33
|
+
- No AI-attribution trailers in commit messages.
|
|
34
|
+
- Tests required for all behavior changes.
|
|
35
|
+
|
|
36
|
+
## Commit message conventions
|
|
37
|
+
|
|
38
|
+
Conventional commits: `feat:`, `fix:`, `docs:`, `test:`, `chore:`, `refactor:`.
|
|
39
|
+
|
|
40
|
+
72-char subject line. Body wraps at 80. Explain the *why* when non-obvious.
|
token_hunt-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
Business Source License 1.1
|
|
2
|
+
|
|
3
|
+
Parameters
|
|
4
|
+
|
|
5
|
+
Licensor: Jordan Newell
|
|
6
|
+
Licensed Work: The token-hunt source code, documentation, and
|
|
7
|
+
bundled assets, as made available at
|
|
8
|
+
https://github.com/JordanNewell/token-hunt
|
|
9
|
+
Additional Use Grant: You may use the Licensed Work, including in production,
|
|
10
|
+
for any personal or noncommercial purpose. A
|
|
11
|
+
noncommercial purpose is any purpose other than a
|
|
12
|
+
commercial one, and specifically includes use by
|
|
13
|
+
charitable organizations, educational institutions,
|
|
14
|
+
public research organizations, and government agencies.
|
|
15
|
+
Any commercial use of the Licensed Work requires a
|
|
16
|
+
separate, written commercial license agreement with the
|
|
17
|
+
Licensor.
|
|
18
|
+
Change Date: 2030-10-12
|
|
19
|
+
Change License: MIT
|
|
20
|
+
|
|
21
|
+
Notice
|
|
22
|
+
|
|
23
|
+
The Business Source License (this document, or the "License") is not an Open
|
|
24
|
+
Source license. However, the Licensed Work will eventually be made available
|
|
25
|
+
under an Open Source License, as stated in this License.
|
|
26
|
+
|
|
27
|
+
Terms
|
|
28
|
+
|
|
29
|
+
The Licensor hereby grants you the right to copy, modify, create derivative
|
|
30
|
+
works, redistribute, and make non-production use of the Licensed Work. The
|
|
31
|
+
Licensor may make an Additional Use Grant, above, permitting limited
|
|
32
|
+
production use.
|
|
33
|
+
|
|
34
|
+
Effective on the Change Date, or the fourth anniversary of the first publicly
|
|
35
|
+
available distribution of a specific version of the Licensed Work under this
|
|
36
|
+
License, whichever comes first, the Licensor hereby grants you rights under
|
|
37
|
+
the terms of the Change License, and the rights granted in the paragraph
|
|
38
|
+
above terminate.
|
|
39
|
+
|
|
40
|
+
If your use of the Licensed Work does not comply with the requirements
|
|
41
|
+
currently in effect as described in this License, you must purchase a
|
|
42
|
+
commercial license from the Licensor, its affiliated entities, or authorized
|
|
43
|
+
resellers, or you must refrain from using the Licensed Work.
|
|
44
|
+
|
|
45
|
+
All copies of the original and modified Licensed Work, and derivative works
|
|
46
|
+
of the Licensed Work, are subject to this License. This License applies
|
|
47
|
+
separately for each version of the Licensed Work and the Change Date may vary
|
|
48
|
+
for each version of the Licensed Work released by Licensor.
|
|
49
|
+
|
|
50
|
+
You must conspicuously display this License on each original or modified copy
|
|
51
|
+
of the Licensed Work. If you receive the Licensed Work in original or
|
|
52
|
+
modified form from a third party, the terms and conditions set forth in this
|
|
53
|
+
License apply to your use of that work.
|
|
54
|
+
|
|
55
|
+
Any use of the Licensed Work in violation of this License will automatically
|
|
56
|
+
terminate your rights under this License for the current and all other
|
|
57
|
+
versions of the Licensed Work.
|
|
58
|
+
|
|
59
|
+
This License does not grant you any right in any trademark or logo of Licensor
|
|
60
|
+
or its affiliates (provided that you may use a trademark or logo of Licensor
|
|
61
|
+
as expressly required by this License).
|
|
62
|
+
|
|
63
|
+
TO THE EXTENT PERMITTED BY APPLICABLE LAW, THE LICENSED WORK IS PROVIDED ON AN
|
|
64
|
+
"AS IS" BASIS. LICENSOR HEREBY DISCLAIMS ALL WARRANTIES AND CONDITIONS,
|
|
65
|
+
EXPRESS OR IMPLIED, INCLUDING (WITHOUT LIMITATION) WARRANTIES OF
|
|
66
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NON-INFRINGEMENT, AND
|
|
67
|
+
TITLE.
|
|
68
|
+
|
|
69
|
+
MariaDB hereby grants you permission to use this License's text to license
|
|
70
|
+
your works, and to refer to it using the trademark "Business Source License",
|
|
71
|
+
as long as you comply with the Covenants of Licensor below.
|
|
72
|
+
|
|
73
|
+
Covenants of Licensor
|
|
74
|
+
|
|
75
|
+
In consideration of the right to use this License's text and the "Business
|
|
76
|
+
Source License" name and trademark, Licensor covenants to MariaDB, and to all
|
|
77
|
+
other recipients of the licensed work to be provided by Licensor:
|
|
78
|
+
|
|
79
|
+
To specify as the Change License the GPL Version 2.0 or any later version, or
|
|
80
|
+
a license that is compatible with GPL Version 2.0 or a later version, where
|
|
81
|
+
"compatible" means that software provided under the Change License can be
|
|
82
|
+
included in a program with software provided under GPL Version 2.0 or a later
|
|
83
|
+
version. Licensor may specify additional Change Licenses without limitation.
|
|
84
|
+
|
|
85
|
+
To either: (a) specify an additional grant of rights to use that does not
|
|
86
|
+
impose any additional restriction on the right granted in this License, as
|
|
87
|
+
the Additional Use Grant; or (b) insert the text "None".
|
|
88
|
+
|
|
89
|
+
Not to modify this License in any other way.
|
|
90
|
+
|
|
91
|
+
Change License Text
|
|
92
|
+
|
|
93
|
+
MIT License
|
|
94
|
+
|
|
95
|
+
Copyright (c) 2026 Jordan Newell
|
|
96
|
+
|
|
97
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
98
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
99
|
+
in the Software without restriction, including without limitation the rights
|
|
100
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
101
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
102
|
+
furnished to do so, subject to the following conditions:
|
|
103
|
+
|
|
104
|
+
The above copyright notice and this permission notice shall be included in all
|
|
105
|
+
copies or substantial portions of the Software.
|
|
106
|
+
|
|
107
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
108
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
109
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
110
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
111
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
112
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
113
|
+
SOFTWARE.
|
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: token-hunt
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Catch secrets at chat time, not commit time. Hook-based scanner for Claude Code / Cursor / Aider.
|
|
5
|
+
Project-URL: Homepage, https://github.com/JordanNewell/token-hunt
|
|
6
|
+
Project-URL: Documentation, https://github.com/JordanNewell/token-hunt#readme
|
|
7
|
+
Project-URL: Issues, https://github.com/JordanNewell/token-hunt/issues
|
|
8
|
+
Author-email: Jordan Newell <jordan@jordannewell.com>
|
|
9
|
+
License-Expression: BUSL-1.1
|
|
10
|
+
License-File: LICENSE
|
|
11
|
+
Classifier: Programming Language :: Python :: 3
|
|
12
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
15
|
+
Classifier: Topic :: Security
|
|
16
|
+
Classifier: Topic :: Software Development :: Quality Assurance
|
|
17
|
+
Requires-Python: >=3.10
|
|
18
|
+
Requires-Dist: click>=8.1.0
|
|
19
|
+
Requires-Dist: platformdirs>=4.0.0
|
|
20
|
+
Requires-Dist: tomli>=2.0.0; python_version < '3.11'
|
|
21
|
+
Requires-Dist: watchdog>=4.0.0
|
|
22
|
+
Provides-Extra: dev
|
|
23
|
+
Requires-Dist: pytest-cov>=5.0.0; extra == 'dev'
|
|
24
|
+
Requires-Dist: pytest>=8.0.0; extra == 'dev'
|
|
25
|
+
Requires-Dist: ruff>=0.6.0; extra == 'dev'
|
|
26
|
+
Description-Content-Type: text/markdown
|
|
27
|
+
|
|
28
|
+
# token-hunt
|
|
29
|
+
|
|
30
|
+
> Catch secrets at chat time, not commit time.
|
|
31
|
+
|
|
32
|
+
[](https://github.com/JordanNewell/token-hunt/releases)
|
|
33
|
+
[](LICENSE)
|
|
34
|
+
[](https://www.python.org/)
|
|
35
|
+
|
|
36
|
+
Hook-based secret scanner for **Claude Code**. Catches leaks when you paste, when your agent reads, and when your agent's tools return — not at commit time when it's already too late.
|
|
37
|
+
|
|
38
|
+
_Cursor and Aider supported via the CLI peer today (manual wiring); first-class plugin integrations ship in v0.2._
|
|
39
|
+
|
|
40
|
+
## Why
|
|
41
|
+
|
|
42
|
+
Existing scanners (gitleaks, trufflehog, ggshield) scan **git history**. By the time you run `git commit`, your secret has been in the AI chat transcript for 30+ minutes — indexed by Anthropic, sync'd to other machines, possibly read by the agent and re-emitted in subsequent tool calls.
|
|
43
|
+
|
|
44
|
+
token-hunt catches at chat time. **Zero cloud, zero telemetry, fail-closed by default.**
|
|
45
|
+
|
|
46
|
+
## Install
|
|
47
|
+
|
|
48
|
+
**Pre-release (today):** not yet on PyPI or the Claude Code plugin marketplace. Install from source:
|
|
49
|
+
|
|
50
|
+
```bash
|
|
51
|
+
git clone https://github.com/JordanNewell/token-hunt
|
|
52
|
+
cd token-hunt
|
|
53
|
+
pip install -e .
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
**Post-v0.1.0 publication** (once tag is pushed and CI completes):
|
|
57
|
+
|
|
58
|
+
```bash
|
|
59
|
+
pip install token-hunt # standalone CLI
|
|
60
|
+
claude plugin install token-hunt@JordanNewell # Claude Code plugin
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
## 60-second demo
|
|
64
|
+
|
|
65
|
+
```bash
|
|
66
|
+
# In one terminal:
|
|
67
|
+
pip install token-hunt
|
|
68
|
+
|
|
69
|
+
# Scan a file:
|
|
70
|
+
echo "ANTHROPIC_API_KEY=sk-ant-..." > /tmp/test.txt
|
|
71
|
+
token-hunt scan /tmp/test.txt
|
|
72
|
+
|
|
73
|
+
# Watch a directory (e.g. Claude Code transcript dir):
|
|
74
|
+
token-hunt watch ~/.claude/projects/
|
|
75
|
+
|
|
76
|
+
# List open leaks:
|
|
77
|
+
token-hunt list
|
|
78
|
+
|
|
79
|
+
# Close after rotating:
|
|
80
|
+
token-hunt close 1 --note "rotated at console.anthropic.com"
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
## Detection points
|
|
84
|
+
|
|
85
|
+
| Hook | What it sees | Action on leak |
|
|
86
|
+
|---|---|---|
|
|
87
|
+
| `UserPromptSubmit` | Your paste | WARN (banner) |
|
|
88
|
+
| `PreToolUse:Bash` | Command about to run | BLOCK (won't run) |
|
|
89
|
+
| `PostToolUse:Bash` | Command output | WARN + log (transcript already has it) |
|
|
90
|
+
| `PostToolUse:Read` | File contents | WARN + log |
|
|
91
|
+
| `PreToolUse:Edit/Write` | New file content | BLOCK |
|
|
92
|
+
| `PostToolUse:Edit/Write` | Echo | WARN + log |
|
|
93
|
+
|
|
94
|
+
## The unique feature: bash escape-hatch detection
|
|
95
|
+
|
|
96
|
+
token-hunt catches patterns where bash evaluates a secret into emitted text, even when the literal secret isn't in your input:
|
|
97
|
+
|
|
98
|
+
```bash
|
|
99
|
+
# BLOCKED — both branches run, leaks the value:
|
|
100
|
+
echo ${ANTHROPIC_API_KEY:+SET}${ANTHROPIC_API_KEY:-UNSET}
|
|
101
|
+
|
|
102
|
+
# BLOCKED — direct echo of secret var:
|
|
103
|
+
echo $GITHUB_TOKEN
|
|
104
|
+
|
|
105
|
+
# ALLOWED — correct status-check pattern:
|
|
106
|
+
[ -n "$ANTHROPIC_API_KEY" ] && echo SET
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
No other scanner detects this class.
|
|
110
|
+
|
|
111
|
+
## Configuration
|
|
112
|
+
|
|
113
|
+
Patterns layer (later extends earlier):
|
|
114
|
+
|
|
115
|
+
1. `token_hunt/patterns/builtin.toml` (ships with package)
|
|
116
|
+
2. `~/.token-hunt/patterns.local.toml` (machine-local, gitignored)
|
|
117
|
+
3. `./.token-hunt/patterns.local.toml` (repo-local, gitignored)
|
|
118
|
+
|
|
119
|
+
Allowlist (test fixtures, etc.):
|
|
120
|
+
|
|
121
|
+
`~/.token-hunt/allowlist.toml`:
|
|
122
|
+
```toml
|
|
123
|
+
fingerprints = [
|
|
124
|
+
"abc123def456...", # SHA-256 first 16 chars of allowlisted value
|
|
125
|
+
]
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
Per-repo opt-out:
|
|
129
|
+
```bash
|
|
130
|
+
export TOKEN_HUNT_DISABLE=1
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
## Bypass
|
|
134
|
+
|
|
135
|
+
Only the PreToolUse BLOCK hooks (Bash, Edit/Write) honor `TOKEN_HUNT_ALLOW`. The WARN hooks (UserPromptSubmit, PostToolUse:*) always fire — they don't block, so bypass is unnecessary.
|
|
136
|
+
|
|
137
|
+
```bash
|
|
138
|
+
TOKEN_HUNT_ALLOW=1 <command> # one-shot bypass of BLOCK-level hooks (use sparingly)
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
## Built-in providers
|
|
142
|
+
|
|
143
|
+
**Dev/infra:** Z.ai · Anthropic · GitHub (classic + fine-grained) · GitLab · Figma · PyPI · npm · Linear · Stripe · OpenAI · Slack
|
|
144
|
+
|
|
145
|
+
**LLM inference (48 rules, 2026-10-15):** OpenRouter · Groq · Together · Fireworks · Mistral · xAI · Perplexity · Hugging Face · Cerebras · Replicate · Vercel AI Gateway · NVIDIA NIM · Chutes · Requesty · Novita · Upstage · Baseten · Baidu Qianfan · fal.ai · Alibaba DashScope · Moonshot Kimi · Cohere · Scaleway · SambaNova · Nebius · AI21 · OVHcloud · FriendliAI · GMI Cloud · Crusoe · Featherless · DeepInfra · Inference.net · BytePlus
|
|
146
|
+
|
|
147
|
+
Providers whose keys are bare `sk-` (DeepSeek, StepFun, Moonshot, SiliconFlow, Poe, Qwen) are caught by the unattributed `sk-` rule; JWT-issued keys (MiniMax, DeepInfra scoped, Crusoe CLI) by the generic JWT rule. Providers with no publicly documented key format (SambaNova, Nebius, AI21, OVHcloud, FriendliAI, GMI Cloud, Crusoe, Featherless, DeepInfra, Inference.net, BytePlus) get **keyword-gated opaque rules**: the provider name must appear in the scanned text AND a 32+-char token must be present. Low-precision by design — the value is attribution and the rotation URL in the warn banner, not shape confidence.
|
|
148
|
+
|
|
149
|
+
## token-hunt vs pat-scanner
|
|
150
|
+
|
|
151
|
+
[pat-scanner](https://github.com/JordanNewell/pat-scanner) is the one-command Claude Code plugin: one hook, 13 credential classes, regex matching. Install it and you're covered.
|
|
152
|
+
|
|
153
|
+
token-hunt is the engine underneath: the Python package, the CLI (`scan / list / close / watch`), six hooks with block-and-rotate behavior, the allowlist, and the bash escape-hatch runtime detector — the class regex can't see. Use pat-scanner when you just want the guard. Use token-hunt when you want the full scanner and the rotation workflow.
|
|
154
|
+
|
|
155
|
+
## Comparison
|
|
156
|
+
|
|
157
|
+
<sup>Verified 2026-07-27. Re-check competitor claims before citing in marketing.</sup>
|
|
158
|
+
|
|
159
|
+
| Tool | Surface | Local-only | Fail-closed | Escape hatch | Fleet sync |
|
|
160
|
+
|---|---|---|---|---|---|
|
|
161
|
+
| **token-hunt** | Claude Code + CLI | yes | yes | **yes** | v0.2 |
|
|
162
|
+
| sensitive-canary | Claude Code | yes | yes | no | no |
|
|
163
|
+
| ggshield | Claude Code | no (cloud API) | no (fail-open) | no | no |
|
|
164
|
+
| gitleaks | git + filesystem + stdin | yes | n/a | no | no |
|
|
165
|
+
|
|
166
|
+
## Development
|
|
167
|
+
|
|
168
|
+
```bash
|
|
169
|
+
pip install -e ".[dev]"
|
|
170
|
+
pytest # full suite (85 tests)
|
|
171
|
+
pytest --cov=token_hunt
|
|
172
|
+
ruff check . # lint (line-length 100, target py310)
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
Python ≥ 3.10. Runtime deps: `click` (CLI), `platformdirs` (config paths),
|
|
176
|
+
`watchdog` (watch mode), `tomli` (< 3.11 only).
|
|
177
|
+
|
|
178
|
+
### Layout
|
|
179
|
+
|
|
180
|
+
```
|
|
181
|
+
src/token_hunt/ engine, regex scanner, escape-hatch detector, entropy,
|
|
182
|
+
patterns loader, allowlist, JSONL store, click CLI
|
|
183
|
+
plugin/ Claude Code plugin manifest + 6 hook shell scripts
|
|
184
|
+
tests/ unit + hook wiring + e2e tests
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
## License
|
|
188
|
+
|
|
189
|
+
BUSL-1.1. Source-available; converts to MIT on 2030-10-12. See [LICENSE](LICENSE).
|
|
190
|
+
|
|
191
|
+
## Security
|
|
192
|
+
|
|
193
|
+
See [SECURITY.md](SECURITY.md). 72-hour acknowledgment SLA.
|