episodely-leakcheck 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.
- episodely_leakcheck-0.1.0/LICENSE +9 -0
- episodely_leakcheck-0.1.0/PKG-INFO +51 -0
- episodely_leakcheck-0.1.0/README.md +35 -0
- episodely_leakcheck-0.1.0/episodely_leakcheck.egg-info/PKG-INFO +51 -0
- episodely_leakcheck-0.1.0/episodely_leakcheck.egg-info/SOURCES.txt +9 -0
- episodely_leakcheck-0.1.0/episodely_leakcheck.egg-info/dependency_links.txt +1 -0
- episodely_leakcheck-0.1.0/episodely_leakcheck.egg-info/entry_points.txt +2 -0
- episodely_leakcheck-0.1.0/episodely_leakcheck.egg-info/top_level.txt +1 -0
- episodely_leakcheck-0.1.0/leakcheck.py +74 -0
- episodely_leakcheck-0.1.0/pyproject.toml +27 -0
- episodely_leakcheck-0.1.0/setup.cfg +4 -0
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 episodely
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
6
|
+
|
|
7
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
8
|
+
|
|
9
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: episodely-leakcheck
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Scan a folder for leaked API keys and secrets before you push.
|
|
5
|
+
Author: episodely
|
|
6
|
+
License: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/episodely/leakcheck
|
|
8
|
+
Project-URL: Issues, https://github.com/episodely/leakcheck/issues
|
|
9
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
10
|
+
Classifier: Programming Language :: Python :: 3
|
|
11
|
+
Classifier: Operating System :: OS Independent
|
|
12
|
+
Requires-Python: >=3.8
|
|
13
|
+
Description-Content-Type: text/markdown
|
|
14
|
+
License-File: LICENSE
|
|
15
|
+
Dynamic: license-file
|
|
16
|
+
|
|
17
|
+
# leakcheck
|
|
18
|
+
|
|
19
|
+
Scan a folder for leaked API keys and secrets before you `git push`. Pure Python, no dependencies, offline. Secrets are masked in the output so the report itself does not leak them.
|
|
20
|
+
|
|
21
|
+
```
|
|
22
|
+
$ python -m leakcheck .
|
|
23
|
+
./config.py:4: aws-access-key: AKIA************MPLE
|
|
24
|
+
1 potential secret(s) found.
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
Exit code is 1 when anything is found, so it works as a pre-commit or CI step:
|
|
28
|
+
|
|
29
|
+
```
|
|
30
|
+
python -m leakcheck . || exit 1
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
Detects AWS keys, GitHub tokens, OpenAI-style `sk-` keys, Slack tokens, Google API keys, Stripe live keys, PEM private keys, and generic `password = "..."` assignments. Skips `.git`, `node_modules`, virtualenvs, binaries and files over 1 MB. Patterns are in one dict at the top of `leakcheck.py`.
|
|
34
|
+
|
|
35
|
+
It is a regex scanner: it will miss some secrets and flag some false positives. If a real secret was ever committed, rotate it.
|
|
36
|
+
|
|
37
|
+
## Install
|
|
38
|
+
|
|
39
|
+
```
|
|
40
|
+
pip install episodely-leakcheck
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
Or copy `leakcheck.py` into your project, it has no dependencies.
|
|
44
|
+
|
|
45
|
+
## Test
|
|
46
|
+
|
|
47
|
+
```
|
|
48
|
+
python -m pytest
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
MIT licensed.
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
# leakcheck
|
|
2
|
+
|
|
3
|
+
Scan a folder for leaked API keys and secrets before you `git push`. Pure Python, no dependencies, offline. Secrets are masked in the output so the report itself does not leak them.
|
|
4
|
+
|
|
5
|
+
```
|
|
6
|
+
$ python -m leakcheck .
|
|
7
|
+
./config.py:4: aws-access-key: AKIA************MPLE
|
|
8
|
+
1 potential secret(s) found.
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
Exit code is 1 when anything is found, so it works as a pre-commit or CI step:
|
|
12
|
+
|
|
13
|
+
```
|
|
14
|
+
python -m leakcheck . || exit 1
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
Detects AWS keys, GitHub tokens, OpenAI-style `sk-` keys, Slack tokens, Google API keys, Stripe live keys, PEM private keys, and generic `password = "..."` assignments. Skips `.git`, `node_modules`, virtualenvs, binaries and files over 1 MB. Patterns are in one dict at the top of `leakcheck.py`.
|
|
18
|
+
|
|
19
|
+
It is a regex scanner: it will miss some secrets and flag some false positives. If a real secret was ever committed, rotate it.
|
|
20
|
+
|
|
21
|
+
## Install
|
|
22
|
+
|
|
23
|
+
```
|
|
24
|
+
pip install episodely-leakcheck
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
Or copy `leakcheck.py` into your project, it has no dependencies.
|
|
28
|
+
|
|
29
|
+
## Test
|
|
30
|
+
|
|
31
|
+
```
|
|
32
|
+
python -m pytest
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
MIT licensed.
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: episodely-leakcheck
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Scan a folder for leaked API keys and secrets before you push.
|
|
5
|
+
Author: episodely
|
|
6
|
+
License: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/episodely/leakcheck
|
|
8
|
+
Project-URL: Issues, https://github.com/episodely/leakcheck/issues
|
|
9
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
10
|
+
Classifier: Programming Language :: Python :: 3
|
|
11
|
+
Classifier: Operating System :: OS Independent
|
|
12
|
+
Requires-Python: >=3.8
|
|
13
|
+
Description-Content-Type: text/markdown
|
|
14
|
+
License-File: LICENSE
|
|
15
|
+
Dynamic: license-file
|
|
16
|
+
|
|
17
|
+
# leakcheck
|
|
18
|
+
|
|
19
|
+
Scan a folder for leaked API keys and secrets before you `git push`. Pure Python, no dependencies, offline. Secrets are masked in the output so the report itself does not leak them.
|
|
20
|
+
|
|
21
|
+
```
|
|
22
|
+
$ python -m leakcheck .
|
|
23
|
+
./config.py:4: aws-access-key: AKIA************MPLE
|
|
24
|
+
1 potential secret(s) found.
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
Exit code is 1 when anything is found, so it works as a pre-commit or CI step:
|
|
28
|
+
|
|
29
|
+
```
|
|
30
|
+
python -m leakcheck . || exit 1
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
Detects AWS keys, GitHub tokens, OpenAI-style `sk-` keys, Slack tokens, Google API keys, Stripe live keys, PEM private keys, and generic `password = "..."` assignments. Skips `.git`, `node_modules`, virtualenvs, binaries and files over 1 MB. Patterns are in one dict at the top of `leakcheck.py`.
|
|
34
|
+
|
|
35
|
+
It is a regex scanner: it will miss some secrets and flag some false positives. If a real secret was ever committed, rotate it.
|
|
36
|
+
|
|
37
|
+
## Install
|
|
38
|
+
|
|
39
|
+
```
|
|
40
|
+
pip install episodely-leakcheck
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
Or copy `leakcheck.py` into your project, it has no dependencies.
|
|
44
|
+
|
|
45
|
+
## Test
|
|
46
|
+
|
|
47
|
+
```
|
|
48
|
+
python -m pytest
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
MIT licensed.
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
LICENSE
|
|
2
|
+
README.md
|
|
3
|
+
leakcheck.py
|
|
4
|
+
pyproject.toml
|
|
5
|
+
episodely_leakcheck.egg-info/PKG-INFO
|
|
6
|
+
episodely_leakcheck.egg-info/SOURCES.txt
|
|
7
|
+
episodely_leakcheck.egg-info/dependency_links.txt
|
|
8
|
+
episodely_leakcheck.egg-info/entry_points.txt
|
|
9
|
+
episodely_leakcheck.egg-info/top_level.txt
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
leakcheck
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
"""Scan a folder for secrets before you push it."""
|
|
2
|
+
import os, re, sys, argparse
|
|
3
|
+
|
|
4
|
+
PATTERNS = {
|
|
5
|
+
"aws-access-key": r"\bAKIA[0-9A-Z]{16}\b",
|
|
6
|
+
"github-token": r"\bgh[pousr]_[A-Za-z0-9]{36,}\b",
|
|
7
|
+
"github-fine-grained": r"\bgithub_pat_[A-Za-z0-9_]{30,}\b",
|
|
8
|
+
"openai-key": r"\bsk-[A-Za-z0-9_\-]{20,}\b",
|
|
9
|
+
"slack-token": r"\bxox[abprs]-[A-Za-z0-9\-]{10,}\b",
|
|
10
|
+
"google-api-key": r"\bAIza[0-9A-Za-z_\-]{35}\b",
|
|
11
|
+
"stripe-live-key": r"\b[sr]k_live_[0-9a-zA-Z]{20,}\b",
|
|
12
|
+
"private-key": r"-----BEGIN (?:RSA |EC |OPENSSH |DSA )?PRIVATE KEY-----",
|
|
13
|
+
}
|
|
14
|
+
GENERIC = re.compile(
|
|
15
|
+
r"(?i)\b(?:api[_-]?key|secret|passwd|password|token)\b\s*[:=]\s*(['\"]?)([^'\"\s]{8,})\1"
|
|
16
|
+
)
|
|
17
|
+
# unquoted values without a digit are usually references (settings.password), and
|
|
18
|
+
# obvious placeholders are not secrets: skip both to keep noise down
|
|
19
|
+
_PLACEHOLDER = re.compile(r"(?i)^(your|example|sample|dummy|change|<|xxx)")
|
|
20
|
+
SKIP_DIRS = {".git", "node_modules", "__pycache__", ".venv", "venv", "dist", "build"}
|
|
21
|
+
|
|
22
|
+
def scan_text(text, name="<text>"):
|
|
23
|
+
hits = []
|
|
24
|
+
for ln, line in enumerate(text.splitlines(), 1):
|
|
25
|
+
for kind, pat in PATTERNS.items():
|
|
26
|
+
m = re.search(pat, line)
|
|
27
|
+
if m:
|
|
28
|
+
hits.append((name, ln, kind, _mask(m.group(0))))
|
|
29
|
+
g = GENERIC.search(line)
|
|
30
|
+
if g and _generic_ok(g):
|
|
31
|
+
hits.append((name, ln, "generic-secret", _mask(g.group(0))))
|
|
32
|
+
return hits
|
|
33
|
+
|
|
34
|
+
def _generic_ok(m):
|
|
35
|
+
val = m.group(2)
|
|
36
|
+
if _PLACEHOLDER.match(val):
|
|
37
|
+
return False
|
|
38
|
+
if not m.group(1) and not re.search(r"\d", val):
|
|
39
|
+
return False
|
|
40
|
+
return True
|
|
41
|
+
|
|
42
|
+
def _mask(s):
|
|
43
|
+
return s[:4] + "*" * max(4, len(s) - 8) + s[-4:] if len(s) > 10 else "*" * len(s)
|
|
44
|
+
|
|
45
|
+
def scan_path(root):
|
|
46
|
+
hits = []
|
|
47
|
+
for dp, dn, fn in os.walk(root):
|
|
48
|
+
dn[:] = [d for d in dn if d not in SKIP_DIRS]
|
|
49
|
+
for f in fn:
|
|
50
|
+
p = os.path.join(dp, f)
|
|
51
|
+
try:
|
|
52
|
+
if os.path.getsize(p) > 1_000_000:
|
|
53
|
+
continue
|
|
54
|
+
with open(p, "rb") as fh:
|
|
55
|
+
data = fh.read()
|
|
56
|
+
if b"\0" in data[:2048]:
|
|
57
|
+
continue
|
|
58
|
+
hits += scan_text(data.decode("utf-8", "ignore"), p)
|
|
59
|
+
except OSError:
|
|
60
|
+
pass
|
|
61
|
+
return hits
|
|
62
|
+
|
|
63
|
+
def main(argv=None):
|
|
64
|
+
ap = argparse.ArgumentParser(prog="leakcheck")
|
|
65
|
+
ap.add_argument("path", nargs="?", default=".")
|
|
66
|
+
a = ap.parse_args(argv)
|
|
67
|
+
hits = scan_path(a.path)
|
|
68
|
+
for name, ln, kind, masked in hits:
|
|
69
|
+
print(f"{name}:{ln}: {kind}: {masked}")
|
|
70
|
+
print(f"{len(hits)} potential secret(s) found.")
|
|
71
|
+
return 1 if hits else 0
|
|
72
|
+
|
|
73
|
+
if __name__ == "__main__":
|
|
74
|
+
sys.exit(main())
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=61"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "episodely-leakcheck"
|
|
7
|
+
version = "0.1.0"
|
|
8
|
+
description = "Scan a folder for leaked API keys and secrets before you push."
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
license = { text = "MIT" }
|
|
11
|
+
requires-python = ">=3.8"
|
|
12
|
+
authors = [{ name = "episodely" }]
|
|
13
|
+
classifiers = [
|
|
14
|
+
"License :: OSI Approved :: MIT License",
|
|
15
|
+
"Programming Language :: Python :: 3",
|
|
16
|
+
"Operating System :: OS Independent",
|
|
17
|
+
]
|
|
18
|
+
|
|
19
|
+
[project.urls]
|
|
20
|
+
Homepage = "https://github.com/episodely/leakcheck"
|
|
21
|
+
Issues = "https://github.com/episodely/leakcheck/issues"
|
|
22
|
+
|
|
23
|
+
[project.scripts]
|
|
24
|
+
leakcheck = "leakcheck:main"
|
|
25
|
+
|
|
26
|
+
[tool.setuptools]
|
|
27
|
+
py-modules = ["leakcheck"]
|