leakkill 0.4.1__tar.gz → 0.5.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.
Files changed (32) hide show
  1. {leakkill-0.4.1/src/leakkill.egg-info → leakkill-0.5.0}/PKG-INFO +100 -17
  2. {leakkill-0.4.1 → leakkill-0.5.0}/README.md +98 -16
  3. leakkill-0.5.0/THIRD_PARTY_NOTICES.md +29 -0
  4. {leakkill-0.4.1 → leakkill-0.5.0}/pyproject.toml +10 -0
  5. {leakkill-0.4.1 → leakkill-0.5.0}/src/leakkill/__init__.py +1 -1
  6. leakkill-0.5.0/src/leakkill/__main__.py +4 -0
  7. leakkill-0.5.0/src/leakkill/baseline.py +37 -0
  8. {leakkill-0.4.1 → leakkill-0.5.0}/src/leakkill/cli.py +28 -8
  9. leakkill-0.5.0/src/leakkill/gitleaks_rules.py +1941 -0
  10. {leakkill-0.4.1 → leakkill-0.5.0}/src/leakkill/guard.py +21 -9
  11. {leakkill-0.4.1 → leakkill-0.5.0}/src/leakkill/providers.py +11 -3
  12. {leakkill-0.4.1 → leakkill-0.5.0}/src/leakkill/report.py +2 -2
  13. leakkill-0.5.0/src/leakkill/sarif.py +53 -0
  14. leakkill-0.5.0/src/leakkill/scanner.py +382 -0
  15. {leakkill-0.4.1 → leakkill-0.5.0/src/leakkill.egg-info}/PKG-INFO +100 -17
  16. {leakkill-0.4.1 → leakkill-0.5.0}/src/leakkill.egg-info/SOURCES.txt +8 -0
  17. {leakkill-0.4.1 → leakkill-0.5.0}/tests/test_cli.py +31 -0
  18. leakkill-0.5.0/tests/test_coverage_gaps.py +118 -0
  19. leakkill-0.5.0/tests/test_fuzz.py +89 -0
  20. leakkill-0.5.0/tests/test_import_gitleaks.py +42 -0
  21. leakkill-0.5.0/tests/test_redos.py +37 -0
  22. {leakkill-0.4.1 → leakkill-0.5.0}/tests/test_scanner.py +67 -0
  23. leakkill-0.4.1/src/leakkill/__main__.py +0 -3
  24. leakkill-0.4.1/src/leakkill/scanner.py +0 -197
  25. {leakkill-0.4.1 → leakkill-0.5.0}/LICENSE +0 -0
  26. {leakkill-0.4.1 → leakkill-0.5.0}/setup.cfg +0 -0
  27. {leakkill-0.4.1 → leakkill-0.5.0}/src/leakkill/aws.py +0 -0
  28. {leakkill-0.4.1 → leakkill-0.5.0}/src/leakkill.egg-info/dependency_links.txt +0 -0
  29. {leakkill-0.4.1 → leakkill-0.5.0}/src/leakkill.egg-info/entry_points.txt +0 -0
  30. {leakkill-0.4.1 → leakkill-0.5.0}/src/leakkill.egg-info/top_level.txt +0 -0
  31. {leakkill-0.4.1 → leakkill-0.5.0}/tests/test_guard.py +0 -0
  32. {leakkill-0.4.1 → leakkill-0.5.0}/tests/test_providers.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: leakkill
3
- Version: 0.4.1
3
+ Version: 0.5.0
4
4
  Summary: Find leaked secrets, check if they're live, revoke them in one command, and keep them out of AI coding agents
5
5
  Author-email: Ayush <andymylove24@gmail.com>
6
6
  License-Expression: MIT
@@ -15,10 +15,13 @@ Classifier: Environment :: Console
15
15
  Requires-Python: >=3.9
16
16
  Description-Content-Type: text/markdown
17
17
  License-File: LICENSE
18
+ License-File: THIRD_PARTY_NOTICES.md
18
19
  Dynamic: license-file
19
20
 
20
21
  # leakkill
21
22
 
23
+ [![PyPI](https://img.shields.io/pypi/v/leakkill)](https://pypi.org/project/leakkill/) [![CI](https://github.com/ayushanand27/leakkill/actions/workflows/ci.yml/badge.svg)](https://github.com/ayushanand27/leakkill/actions/workflows/ci.yml) [![OpenSSF Scorecard](https://api.scorecard.dev/projects/github.com/ayushanand27/leakkill/badge)](https://scorecard.dev/viewer/?uri=github.com/ayushanand27/leakkill)
24
+
22
25
  **Leaked a key? Find it, see if it's live, and kill it in one command. Free, local, zero dependencies.**
23
26
 
24
27
  Free tools are great at *finding* secrets. What happens *after* a leak is usually left to paid
@@ -81,16 +84,39 @@ including secrets you already "deleted"), `--exclude-tests` and `--json`.
81
84
  |---|---|---|---|---|---|
82
85
  | Price | **Free (MIT)** | Free (MIT) | Free (AGPL) | Free for individuals, roughly $15–30/dev/month for teams | Free on public repos, $19/committer/month on private |
83
86
  | Runs fully local | ✅ | ✅ | ✅ | ❌ SaaS | ❌ GitHub only |
84
- | Detectors | 31 | 150+ | 800+ | 550+ | [provider list](https://docs.github.com/en/code-security/secret-scanning/introduction/supported-secret-scanning-patterns) |
87
+ | Detectors | 245 (31 leakkill + 214 imported from Gitleaks, credited) | 150+ | 800+ | 550+ | [provider list](https://docs.github.com/en/code-security/secret-scanning/introduction/supported-secret-scanning-patterns) |
85
88
  | Checks if a key is live | ✅ 17 providers | ❌ | ✅ (its main strength) | ✅ | ✅ some |
86
89
  | Revokes from the CLI | ✅ 6 providers | ❌ | ❌ (Enterprise) | partial | ❌ |
87
90
  | Incident report and history-purge steps | ✅ Markdown file | ❌ | ❌ | ✅ dashboard and playbooks | ❌ |
88
91
  | Guards AI coding agents | ✅ Claude Code hooks | ❌ | ❌ | ❌ | ❌ |
92
+ | SARIF / baselines | ✅ / ✅ hashes only | ✅ / ✅ (stores secrets) | ✅ / ❌ | ✅ / ✅ | built in |
89
93
  | Dependencies | none | Go binary | Go binary | CLI + account | GitHub |
90
94
 
91
95
  Detector and pricing figures come from public sources in October 2026. Use what fits your needs:
92
96
  if breadth of detection matters most, run Gitleaks or TruffleHog alongside leakkill.
93
97
 
98
+ ### Detection rules
99
+
100
+ leakkill's own 31 rules cover the providers it can verify and revoke. On top of those, it includes
101
+ **214 provider rules from [Gitleaks](https://github.com/gitleaks/gitleaks)** (MIT), translated to Python by
102
+ [`tools/import_gitleaks.py`](tools/import_gitleaks.py) from a pinned, checksum-verified release, together with
103
+ Gitleaks' entropy thresholds and allowlists. Thank you to the Gitleaks maintainers. See
104
+ [THIRD_PARTY_NOTICES.md](THIRD_PARTY_NOTICES.md).
105
+
106
+ ### Speed
107
+
108
+ Measured on 4 cores (October 2026), wall-clock time for a full scan:
109
+
110
+ | Repository | leakkill | Gitleaks 8.28 |
111
+ |---|---|---|
112
+ | psf/requests (130 files) | 0.36 s | 0.63 s |
113
+ | pallets/flask (236 files) | 0.31 s | 0.64 s |
114
+ | expressjs/express (214 files) | 0.23 s | 0.48 s |
115
+ | pallets/flask full history (5,557 commits) | 2.0 s | 1.5 s |
116
+ | django/django (7,000 files, 43 MB) | 2.8 s | 1.4 s |
117
+
118
+ On typical repositories leakkill is faster; on very large ones Gitleaks (Go) is about 2x faster.
119
+
94
120
  ### Tested with real credentials
95
121
 
96
122
  End to end on Windows with real, throwaway credentials:
@@ -108,20 +134,32 @@ Against the real AWS, GitLab, Anthropic and npm APIs, invalid keys are correctly
108
134
  Providers not yet tested with a live key (OpenAI, OpenRouter, Groq, Replicate, DigitalOcean,
109
135
  SendGrid, Telegram) are covered by tests using simulated API responses.
110
136
 
111
- ### Benchmark (reproducible, run October 2026)
112
-
113
- Noise on clean, popular repos (unique secrets reported, default settings):
137
+ ### Accuracy (independent dataset)
114
138
 
115
- | Repo | leakkill | Gitleaks 8.28 |
116
- |---|---|---|
117
- | psf/requests | 1 (private-key test fixtures) | 4 (same fixtures, one per file) |
118
- | pallets/flask | 2 (docs example `SECRET_KEY`s) | 2 (same) |
119
- | django/django | 1 (a CSRF test fixture) | 8 |
120
- | expressjs/express | 0 | 0 |
139
+ On [Samsung CredData](https://github.com/Samsung/CredData), 67,896 lines labeled by people, scored by the
140
+ same script for every tool ([details and how to reproduce](benchmarks/README.md)):
121
141
 
122
- Recall on 17 planted realistic secrets: **leakkill 17/17, Gitleaks 14/17**. Gitleaks missed a
123
- Postgres URL with a password, a Discord webhook and a Telegram bot token. The planted set was written
124
- by us, so it is biased toward formats we support. Gitleaks detects many formats we don't.
142
+ | | precision | recall | precision / recall without OpenSSL test vectors |
143
+ |---|---|---|---|
144
+ | **leakkill** | 0.834 | 0.251 | 0.893 / 0.217 |
145
+ | Gitleaks 8.28 | 0.860 | 0.453 | 0.910 / 0.218 |
146
+ | TruffleHog 3.97 (detection only) | 0.579 | 0.024 | 0.486 / 0.026 |
147
+
148
+ On ordinary code leakkill matches Gitleaks; it finds 182/209 passwords in URLs (Gitleaks 0). Gitleaks' higher
149
+ recall on the full set comes mostly from OpenSSL crypto test vectors that leakkill deliberately doesn't flag.
150
+ False alarms on clean repositories (requests, flask, django, express): 1 / 2 / 3 / 0.
151
+
152
+ ### How it's tested
153
+
154
+ - 108 tests on Linux, macOS and Windows with Python 3.9 and 3.13; CI fails below 88% branch coverage (currently 92%).
155
+ - Property-based fuzz tests: the scanner never crashes on random input, never prints a raw secret, finds a
156
+ planted token in any surrounding text, and gives the same answer scanning a whole file or line by line.
157
+ (Fuzzing found two real bugs before release: a guard crash and a slow-input case, both fixed.)
158
+ - Every one of the 245 rules is checked in CI against hostile input built from its own keywords, because
159
+ Python's regex engine, unlike Go's, can be made to backtrack for minutes. The sweep found and fixed 4
160
+ such rules among those imported from Gitleaks.
161
+ - Live tests against real APIs with real throwaway keys (above), and of the Claude Code guard in the real CLI.
162
+ - SonarCloud, OpenSSF Scorecard, pinned and hash-locked CI tooling, signed PyPI provenance.
125
163
 
126
164
  ## Safety model
127
165
 
@@ -163,7 +201,7 @@ hard guarantees.
163
201
  ## Use in CI (GitHub Action)
164
202
 
165
203
  ```yaml
166
- - uses: actions/checkout@v4
204
+ - uses: actions/checkout@v7
167
205
  - uses: ayushanand27/leakkill@v0
168
206
  ```
169
207
 
@@ -181,13 +219,57 @@ The build fails if a secret is found, and the incident report appears in the job
181
219
  The action exposes `found` (the number of unique secrets) as an output. Outside GitHub Actions, use
182
220
  `pip install leakkill && leakkill scan .`.
183
221
 
222
+ ### Findings in the GitHub Security tab (SARIF)
223
+
224
+ ```yaml
225
+ permissions:
226
+ contents: read
227
+ security-events: write # needed to upload SARIF
228
+ steps:
229
+ - uses: actions/checkout@v7
230
+ - uses: ayushanand27/leakkill@v0
231
+ id: leakkill
232
+ - uses: github/codeql-action/upload-sarif@v4
233
+ if: always() # upload even when leakkill fails the build
234
+ with:
235
+ sarif_file: ${{ steps.leakkill.outputs.sarif-file }}
236
+ ```
237
+
238
+ Outside the Action: `leakkill scan --sarif results.sarif .` (validated against the OASIS SARIF 2.1.0 schema).
239
+ The SARIF never contains secrets, only a masked prefix and a truncated hash.
240
+
241
+ ## GitLab CI
242
+
243
+ ```yaml
244
+ leakkill:
245
+ image: python:3.12-slim
246
+ script:
247
+ - pip install leakkill
248
+ - leakkill scan --exclude-tests --sarif gl-leakkill.sarif .
249
+ artifacts:
250
+ when: always
251
+ paths: [gl-leakkill.sarif]
252
+ ```
253
+
254
+ ## Baselines: adopt it on a repo that already has old findings
255
+
256
+ ```sh
257
+ leakkill scan --write-baseline .leakkill-baseline.json . # accept what's there today
258
+ leakkill scan --baseline .leakkill-baseline.json . # from now on, fail only on new secrets
259
+ ```
260
+
261
+ The baseline file is safe to commit: it holds only salted scrypt hashes, never secrets, and scrypt is
262
+ deliberately slow so even weak passwords can't practically be brute-forced back out of it. (Gitleaks'
263
+ baseline is its previous report, which includes the secrets themselves.) Accepting a finding into the
264
+ baseline doesn't make it safe: revoke real keys first.
265
+
184
266
  ## Use with the pre-commit framework
185
267
 
186
268
  ```yaml
187
269
  # .pre-commit-config.yaml
188
270
  repos:
189
271
  - repo: https://github.com/ayushanand27/leakkill
190
- rev: v0.3.0
272
+ rev: v0.5.0
191
273
  hooks:
192
274
  - id: leakkill
193
275
  ```
@@ -203,7 +285,8 @@ Or without the framework: `leakkill install-hook`.
203
285
 
204
286
  ## Known limitations
205
287
 
206
- - Fewer detectors than Gitleaks or TruffleHog.
288
+ - Detection breadth is close to Gitleaks (whose rules it includes) but below TruffleHog (800+ detectors).
289
+ - On very large repositories (tens of MB) scanning is about 2x slower than Gitleaks.
207
290
  - Verification behind a proxy that injects its own credentials (some corporate and sandbox proxies
208
291
  do) can report the proxy's identity. Run `verify` from a normal network.
209
292
  - AWS keys can only be verified when the secret key is found too (any file in the scan).
@@ -1,5 +1,7 @@
1
1
  # leakkill
2
2
 
3
+ [![PyPI](https://img.shields.io/pypi/v/leakkill)](https://pypi.org/project/leakkill/) [![CI](https://github.com/ayushanand27/leakkill/actions/workflows/ci.yml/badge.svg)](https://github.com/ayushanand27/leakkill/actions/workflows/ci.yml) [![OpenSSF Scorecard](https://api.scorecard.dev/projects/github.com/ayushanand27/leakkill/badge)](https://scorecard.dev/viewer/?uri=github.com/ayushanand27/leakkill)
4
+
3
5
  **Leaked a key? Find it, see if it's live, and kill it in one command. Free, local, zero dependencies.**
4
6
 
5
7
  Free tools are great at *finding* secrets. What happens *after* a leak is usually left to paid
@@ -62,16 +64,39 @@ including secrets you already "deleted"), `--exclude-tests` and `--json`.
62
64
  |---|---|---|---|---|---|
63
65
  | Price | **Free (MIT)** | Free (MIT) | Free (AGPL) | Free for individuals, roughly $15–30/dev/month for teams | Free on public repos, $19/committer/month on private |
64
66
  | Runs fully local | ✅ | ✅ | ✅ | ❌ SaaS | ❌ GitHub only |
65
- | Detectors | 31 | 150+ | 800+ | 550+ | [provider list](https://docs.github.com/en/code-security/secret-scanning/introduction/supported-secret-scanning-patterns) |
67
+ | Detectors | 245 (31 leakkill + 214 imported from Gitleaks, credited) | 150+ | 800+ | 550+ | [provider list](https://docs.github.com/en/code-security/secret-scanning/introduction/supported-secret-scanning-patterns) |
66
68
  | Checks if a key is live | ✅ 17 providers | ❌ | ✅ (its main strength) | ✅ | ✅ some |
67
69
  | Revokes from the CLI | ✅ 6 providers | ❌ | ❌ (Enterprise) | partial | ❌ |
68
70
  | Incident report and history-purge steps | ✅ Markdown file | ❌ | ❌ | ✅ dashboard and playbooks | ❌ |
69
71
  | Guards AI coding agents | ✅ Claude Code hooks | ❌ | ❌ | ❌ | ❌ |
72
+ | SARIF / baselines | ✅ / ✅ hashes only | ✅ / ✅ (stores secrets) | ✅ / ❌ | ✅ / ✅ | built in |
70
73
  | Dependencies | none | Go binary | Go binary | CLI + account | GitHub |
71
74
 
72
75
  Detector and pricing figures come from public sources in October 2026. Use what fits your needs:
73
76
  if breadth of detection matters most, run Gitleaks or TruffleHog alongside leakkill.
74
77
 
78
+ ### Detection rules
79
+
80
+ leakkill's own 31 rules cover the providers it can verify and revoke. On top of those, it includes
81
+ **214 provider rules from [Gitleaks](https://github.com/gitleaks/gitleaks)** (MIT), translated to Python by
82
+ [`tools/import_gitleaks.py`](tools/import_gitleaks.py) from a pinned, checksum-verified release, together with
83
+ Gitleaks' entropy thresholds and allowlists. Thank you to the Gitleaks maintainers. See
84
+ [THIRD_PARTY_NOTICES.md](THIRD_PARTY_NOTICES.md).
85
+
86
+ ### Speed
87
+
88
+ Measured on 4 cores (October 2026), wall-clock time for a full scan:
89
+
90
+ | Repository | leakkill | Gitleaks 8.28 |
91
+ |---|---|---|
92
+ | psf/requests (130 files) | 0.36 s | 0.63 s |
93
+ | pallets/flask (236 files) | 0.31 s | 0.64 s |
94
+ | expressjs/express (214 files) | 0.23 s | 0.48 s |
95
+ | pallets/flask full history (5,557 commits) | 2.0 s | 1.5 s |
96
+ | django/django (7,000 files, 43 MB) | 2.8 s | 1.4 s |
97
+
98
+ On typical repositories leakkill is faster; on very large ones Gitleaks (Go) is about 2x faster.
99
+
75
100
  ### Tested with real credentials
76
101
 
77
102
  End to end on Windows with real, throwaway credentials:
@@ -89,20 +114,32 @@ Against the real AWS, GitLab, Anthropic and npm APIs, invalid keys are correctly
89
114
  Providers not yet tested with a live key (OpenAI, OpenRouter, Groq, Replicate, DigitalOcean,
90
115
  SendGrid, Telegram) are covered by tests using simulated API responses.
91
116
 
92
- ### Benchmark (reproducible, run October 2026)
93
-
94
- Noise on clean, popular repos (unique secrets reported, default settings):
117
+ ### Accuracy (independent dataset)
95
118
 
96
- | Repo | leakkill | Gitleaks 8.28 |
97
- |---|---|---|
98
- | psf/requests | 1 (private-key test fixtures) | 4 (same fixtures, one per file) |
99
- | pallets/flask | 2 (docs example `SECRET_KEY`s) | 2 (same) |
100
- | django/django | 1 (a CSRF test fixture) | 8 |
101
- | expressjs/express | 0 | 0 |
119
+ On [Samsung CredData](https://github.com/Samsung/CredData), 67,896 lines labeled by people, scored by the
120
+ same script for every tool ([details and how to reproduce](benchmarks/README.md)):
102
121
 
103
- Recall on 17 planted realistic secrets: **leakkill 17/17, Gitleaks 14/17**. Gitleaks missed a
104
- Postgres URL with a password, a Discord webhook and a Telegram bot token. The planted set was written
105
- by us, so it is biased toward formats we support. Gitleaks detects many formats we don't.
122
+ | | precision | recall | precision / recall without OpenSSL test vectors |
123
+ |---|---|---|---|
124
+ | **leakkill** | 0.834 | 0.251 | 0.893 / 0.217 |
125
+ | Gitleaks 8.28 | 0.860 | 0.453 | 0.910 / 0.218 |
126
+ | TruffleHog 3.97 (detection only) | 0.579 | 0.024 | 0.486 / 0.026 |
127
+
128
+ On ordinary code leakkill matches Gitleaks; it finds 182/209 passwords in URLs (Gitleaks 0). Gitleaks' higher
129
+ recall on the full set comes mostly from OpenSSL crypto test vectors that leakkill deliberately doesn't flag.
130
+ False alarms on clean repositories (requests, flask, django, express): 1 / 2 / 3 / 0.
131
+
132
+ ### How it's tested
133
+
134
+ - 108 tests on Linux, macOS and Windows with Python 3.9 and 3.13; CI fails below 88% branch coverage (currently 92%).
135
+ - Property-based fuzz tests: the scanner never crashes on random input, never prints a raw secret, finds a
136
+ planted token in any surrounding text, and gives the same answer scanning a whole file or line by line.
137
+ (Fuzzing found two real bugs before release: a guard crash and a slow-input case, both fixed.)
138
+ - Every one of the 245 rules is checked in CI against hostile input built from its own keywords, because
139
+ Python's regex engine, unlike Go's, can be made to backtrack for minutes. The sweep found and fixed 4
140
+ such rules among those imported from Gitleaks.
141
+ - Live tests against real APIs with real throwaway keys (above), and of the Claude Code guard in the real CLI.
142
+ - SonarCloud, OpenSSF Scorecard, pinned and hash-locked CI tooling, signed PyPI provenance.
106
143
 
107
144
  ## Safety model
108
145
 
@@ -144,7 +181,7 @@ hard guarantees.
144
181
  ## Use in CI (GitHub Action)
145
182
 
146
183
  ```yaml
147
- - uses: actions/checkout@v4
184
+ - uses: actions/checkout@v7
148
185
  - uses: ayushanand27/leakkill@v0
149
186
  ```
150
187
 
@@ -162,13 +199,57 @@ The build fails if a secret is found, and the incident report appears in the job
162
199
  The action exposes `found` (the number of unique secrets) as an output. Outside GitHub Actions, use
163
200
  `pip install leakkill && leakkill scan .`.
164
201
 
202
+ ### Findings in the GitHub Security tab (SARIF)
203
+
204
+ ```yaml
205
+ permissions:
206
+ contents: read
207
+ security-events: write # needed to upload SARIF
208
+ steps:
209
+ - uses: actions/checkout@v7
210
+ - uses: ayushanand27/leakkill@v0
211
+ id: leakkill
212
+ - uses: github/codeql-action/upload-sarif@v4
213
+ if: always() # upload even when leakkill fails the build
214
+ with:
215
+ sarif_file: ${{ steps.leakkill.outputs.sarif-file }}
216
+ ```
217
+
218
+ Outside the Action: `leakkill scan --sarif results.sarif .` (validated against the OASIS SARIF 2.1.0 schema).
219
+ The SARIF never contains secrets, only a masked prefix and a truncated hash.
220
+
221
+ ## GitLab CI
222
+
223
+ ```yaml
224
+ leakkill:
225
+ image: python:3.12-slim
226
+ script:
227
+ - pip install leakkill
228
+ - leakkill scan --exclude-tests --sarif gl-leakkill.sarif .
229
+ artifacts:
230
+ when: always
231
+ paths: [gl-leakkill.sarif]
232
+ ```
233
+
234
+ ## Baselines: adopt it on a repo that already has old findings
235
+
236
+ ```sh
237
+ leakkill scan --write-baseline .leakkill-baseline.json . # accept what's there today
238
+ leakkill scan --baseline .leakkill-baseline.json . # from now on, fail only on new secrets
239
+ ```
240
+
241
+ The baseline file is safe to commit: it holds only salted scrypt hashes, never secrets, and scrypt is
242
+ deliberately slow so even weak passwords can't practically be brute-forced back out of it. (Gitleaks'
243
+ baseline is its previous report, which includes the secrets themselves.) Accepting a finding into the
244
+ baseline doesn't make it safe: revoke real keys first.
245
+
165
246
  ## Use with the pre-commit framework
166
247
 
167
248
  ```yaml
168
249
  # .pre-commit-config.yaml
169
250
  repos:
170
251
  - repo: https://github.com/ayushanand27/leakkill
171
- rev: v0.3.0
252
+ rev: v0.5.0
172
253
  hooks:
173
254
  - id: leakkill
174
255
  ```
@@ -184,7 +265,8 @@ Or without the framework: `leakkill install-hook`.
184
265
 
185
266
  ## Known limitations
186
267
 
187
- - Fewer detectors than Gitleaks or TruffleHog.
268
+ - Detection breadth is close to Gitleaks (whose rules it includes) but below TruffleHog (800+ detectors).
269
+ - On very large repositories (tens of MB) scanning is about 2x slower than Gitleaks.
188
270
  - Verification behind a proxy that injects its own credentials (some corporate and sandbox proxies
189
271
  do) can report the proxy's identity. Run `verify` from a normal network.
190
272
  - AWS keys can only be verified when the secret key is found too (any file in the scan).
@@ -0,0 +1,29 @@
1
+ # Third-party notices
2
+
3
+ leakkill includes detection rules translated from [Gitleaks](https://github.com/gitleaks/gitleaks)
4
+ v8.28.0 (`config/gitleaks.toml`), generated by `tools/import_gitleaks.py` into
5
+ `src/leakkill/gitleaks_rules.py`. Gitleaks is distributed under the following license:
6
+
7
+ ```
8
+ MIT License
9
+
10
+ Copyright (c) 2019 Zachary Rice
11
+
12
+ Permission is hereby granted, free of charge, to any person obtaining a copy
13
+ of this software and associated documentation files (the "Software"), to deal
14
+ in the Software without restriction, including without limitation the rights
15
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
16
+ copies of the Software, and to permit persons to whom the Software is
17
+ furnished to do so, subject to the following conditions:
18
+
19
+ The above copyright notice and this permission notice shall be included in all
20
+ copies or substantial portions of the Software.
21
+
22
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
23
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
24
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
25
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
26
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
27
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
28
+ SOFTWARE.
29
+ ```
@@ -8,6 +8,7 @@ dynamic = ["version"]
8
8
  description = "Find leaked secrets, check if they're live, revoke them in one command, and keep them out of AI coding agents"
9
9
  readme = "README.md"
10
10
  license = "MIT"
11
+ license-files = ["LICENSE", "THIRD_PARTY_NOTICES.md"]
11
12
  requires-python = ">=3.9"
12
13
  authors = [{ name = "Ayush", email = "andymylove24@gmail.com" }]
13
14
  keywords = ["secrets", "security", "leak", "revoke", "pre-commit", "claude-code", "ai-agents", "devsecops"]
@@ -35,3 +36,12 @@ where = ["src"]
35
36
  [tool.pytest.ini_options]
36
37
  pythonpath = ["src"]
37
38
  testpaths = ["tests"]
39
+
40
+ [tool.coverage.run]
41
+ branch = true
42
+ source = ["src/leakkill"]
43
+ omit = ["*/gitleaks_rules.py"] # generated rule data
44
+
45
+ [tool.coverage.report]
46
+ fail_under = 88
47
+ show_missing = true
@@ -1,2 +1,2 @@
1
1
  """leakkill: find leaked secrets, check if they're live, revoke them, and guard AI coding agents."""
2
- __version__ = "0.4.1"
2
+ __version__ = "0.5.0"
@@ -0,0 +1,4 @@
1
+ from .cli import main_cli
2
+
3
+ if __name__ == "__main__": # guard needed: parallel scanning re-imports this module on Windows/macOS
4
+ main_cli()
@@ -0,0 +1,37 @@
1
+ """Baselines: accept the secrets you already know about and only fail on new ones.
2
+
3
+ The file never contains secrets, only salted scrypt hashes. scrypt is deliberately slow, so even a weak password
4
+ in a committed baseline can't practically be brute-forced back out of it.
5
+ """
6
+ import hashlib, json, os
7
+
8
+ VERSION = 1
9
+ N, R, P = 2 ** 13, 8, 1 # scrypt cost: tens of ms per hash, fine for the handful of entries a baseline holds
10
+
11
+
12
+ def _hash(kind, secret, salt):
13
+ return hashlib.scrypt(f"{kind}\0{secret}".encode(), salt=bytes.fromhex(salt), n=N, r=R, p=P, dklen=32).hex()
14
+
15
+
16
+ def write(items, path):
17
+ salt = os.urandom(16).hex()
18
+ entries = sorted({_hash(it.kind, it.secret, salt) for it in items})
19
+ with open(path, "w", encoding="utf-8") as f:
20
+ json.dump({"leakkill_baseline": VERSION, "salt": salt, "entries": entries}, f, indent=2)
21
+ f.write("\n")
22
+ return len(entries)
23
+
24
+
25
+ def load(path):
26
+ with open(path, encoding="utf-8") as f:
27
+ data = json.load(f)
28
+ if data.get("leakkill_baseline") != VERSION:
29
+ raise ValueError(f"{path} is not a leakkill baseline (version {VERSION})")
30
+ return data["salt"], set(data["entries"])
31
+
32
+
33
+ def filter_new(items, path):
34
+ """Drop items whose secret is in the baseline; returns (new_items, number_suppressed)."""
35
+ salt, known = load(path)
36
+ new = [it for it in items if _hash(it.kind, it.secret, salt) not in known]
37
+ return new, len(items) - len(new)
@@ -8,14 +8,15 @@
8
8
  leakkill install-claude-hook stop Claude Code reading .env/keys or writing secrets
9
9
  leakkill guard hook entry point (reads Claude Code hook JSON on stdin)
10
10
 
11
- Common options: --staged (pre-commit), --history (all commits), --exclude-tests, --json.
11
+ Common options: --staged (pre-commit), --history (all commits), --exclude-tests, --json, --baseline FILE.
12
+ scan/verify also take --report FILE, --sarif FILE and --write-baseline FILE.
12
13
  Ignore a line with `leakkill:ignore`; ignore paths with globs in .leakkillignore.
13
14
  """
14
15
  import argparse, difflib, json, os, sys
15
16
  from concurrent.futures import ThreadPoolExecutor
16
17
  from dataclasses import dataclass
17
18
 
18
- from . import __version__, guard as guard_mod, providers, report, scanner
19
+ from . import __version__, baseline, guard as guard_mod, providers, report, sarif, scanner
19
20
 
20
21
  LEGACY = {"--guard": "guard", "--install-hook": "install-hook", "--install-claude-hook": "install-claude-hook"}
21
22
  COMMANDS = {"scan", "verify", "revoke", "report", "guard", "install-hook", "install-claude-hook"}
@@ -41,7 +42,14 @@ def collect(args):
41
42
  found = [f for f in found if not scanner.ignored(f.path, ignores)]
42
43
  if args.exclude_tests:
43
44
  found = [f for f in found if not scanner.is_test_path(f.path)]
44
- return [Item(n, k, s, fs) for n, (k, s, fs) in enumerate(scanner.group(found), 1)]
45
+ items = [Item(0, k, s, fs) for k, s, fs in scanner.group(found)]
46
+ if args.baseline:
47
+ items, suppressed = baseline.filter_new(items, args.baseline)
48
+ if suppressed:
49
+ print(f"({suppressed} known secret(s) suppressed by baseline {args.baseline})", file=sys.stderr)
50
+ for n, it in enumerate(items, 1):
51
+ it.n = n
52
+ return items
45
53
 
46
54
 
47
55
  def verify_all(items):
@@ -98,6 +106,11 @@ def _target(args):
98
106
 
99
107
  def cmd_scan(args, verify=False):
100
108
  items = collect(args)
109
+ if args.write_baseline:
110
+ n = baseline.write(items, args.write_baseline)
111
+ print(f"Baseline with {n} known secret(s) written to {args.write_baseline} (hashes only, no secrets). "
112
+ f"Use --baseline {args.write_baseline} to only report new ones.")
113
+ return 0
101
114
  if verify and items:
102
115
  verify_all(items)
103
116
  if args.json:
@@ -108,6 +121,9 @@ def cmd_scan(args, verify=False):
108
121
  if args.report:
109
122
  with open(args.report, "w", encoding="utf-8") as f:
110
123
  f.write(report.render(items, _target(args), verified=verify))
124
+ if args.sarif:
125
+ with open(args.sarif, "w", encoding="utf-8") as f:
126
+ f.write(sarif.render(items))
111
127
  if verify:
112
128
  return 1 if any(i.result.status == providers.LIVE for i in items) else 0
113
129
  return 1 if items else 0
@@ -127,14 +143,14 @@ def cmd_revoke(args):
127
143
  if not live:
128
144
  print("\nNo live secrets: nothing to revoke.")
129
145
  return 0
130
- auto = [i for i in live if providers.PROVIDERS[i.kind].revoke]
146
+ auto = [i for i in live if providers.provider(i.kind).revoke]
131
147
  manual = [i for i in live if i not in auto]
132
148
  print(f"\n{len(live)} live secret(s): {len(auto)} can be revoked automatically, {len(manual)} need manual steps.")
133
149
  for i in manual:
134
- print(f" #{i.n} {i.kind}: {providers.PROVIDERS[i.kind].manual}")
150
+ print(f" #{i.n} {i.kind}: {providers.provider(i.kind).manual}")
135
151
  for i in auto:
136
- if providers.PROVIDERS[i.kind].side_effect:
137
- print(f" note for #{i.n} {i.kind}: {providers.PROVIDERS[i.kind].side_effect}")
152
+ if providers.provider(i.kind).side_effect:
153
+ print(f" note for #{i.n} {i.kind}: {providers.provider(i.kind).side_effect}")
138
154
  if not args.yes:
139
155
  if auto:
140
156
  print(f"\nDry run. Re-run with --yes to revoke: " + ", ".join(f"#{i.n}" for i in auto))
@@ -145,7 +161,7 @@ def cmd_revoke(args):
145
161
  print(f" #{i.n} {i.kind}: {'REVOKED' if ok else 'FAILED'} ({msg})")
146
162
  if not ok:
147
163
  failed += 1
148
- print(f" manual: {providers.PROVIDERS[i.kind].manual}")
164
+ print(f" manual: {providers.provider(i.kind).manual}")
149
165
  return 1 if failed or manual else 0
150
166
 
151
167
 
@@ -171,12 +187,16 @@ def parser():
171
187
  common.add_argument("--history", action="store_true", help="scan every commit on every branch")
172
188
  common.add_argument("--exclude-tests", action="store_true", help="skip test_* files and tests/ dirs")
173
189
  common.add_argument("--json", action="store_true", help="machine-readable output")
190
+ common.add_argument("--baseline", metavar="FILE", help="ignore secrets listed in this baseline file")
174
191
  p = argparse.ArgumentParser(prog="leakkill", description=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter)
175
192
  p.add_argument("--version", action="version", version=f"leakkill {__version__}")
176
193
  sub = p.add_subparsers(dest="cmd")
177
194
  for name, h in (("scan", "find secrets (offline)"), ("verify", "find secrets and check which are live")):
178
195
  sp = sub.add_parser(name, parents=[common], help=h)
179
196
  sp.add_argument("--report", metavar="FILE", help="also write the Markdown incident report to FILE")
197
+ sp.add_argument("--sarif", metavar="FILE", help="also write SARIF 2.1.0 (GitHub Security tab) to FILE")
198
+ sp.add_argument("--write-baseline", metavar="FILE",
199
+ help="accept all current findings: write their hashes to FILE and exit 0")
180
200
  r = sub.add_parser("revoke", parents=[common], help="revoke live secrets (dry run unless --yes)")
181
201
  r.add_argument("--only", help="comma-separated ids from `leakkill verify`, e.g. 1,3")
182
202
  r.add_argument("--yes", action="store_true", help="actually revoke")