open-pushscan 0.3.0__py3-none-any.whl
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.
- open_pushscan/__init__.py +2 -0
- open_pushscan/__main__.py +5 -0
- open_pushscan/agents.py +666 -0
- open_pushscan/ci.py +88 -0
- open_pushscan/cli.py +534 -0
- open_pushscan/config.py +256 -0
- open_pushscan/fingerprints.py +153 -0
- open_pushscan/gitscan.py +248 -0
- open_pushscan/hooks.py +121 -0
- open_pushscan/i18n.py +90 -0
- open_pushscan/media.py +318 -0
- open_pushscan/publish.py +160 -0
- open_pushscan/report.py +130 -0
- open_pushscan/rules.py +277 -0
- open_pushscan/scanner.py +226 -0
- open_pushscan/visibility.py +87 -0
- open_pushscan-0.3.0.dist-info/METADATA +193 -0
- open_pushscan-0.3.0.dist-info/RECORD +22 -0
- open_pushscan-0.3.0.dist-info/WHEEL +5 -0
- open_pushscan-0.3.0.dist-info/entry_points.txt +2 -0
- open_pushscan-0.3.0.dist-info/licenses/LICENSE +202 -0
- open_pushscan-0.3.0.dist-info/top_level.txt +1 -0
open_pushscan/scanner.py
ADDED
|
@@ -0,0 +1,226 @@
|
|
|
1
|
+
"""Apply every rule to what is about to be made public."""
|
|
2
|
+
from __future__ import annotations
|
|
3
|
+
|
|
4
|
+
import json
|
|
5
|
+
import os
|
|
6
|
+
import re
|
|
7
|
+
import shutil
|
|
8
|
+
import subprocess
|
|
9
|
+
import tempfile
|
|
10
|
+
from dataclasses import dataclass, asdict
|
|
11
|
+
|
|
12
|
+
from . import config, media
|
|
13
|
+
from . import fingerprints as fpmod
|
|
14
|
+
from .rules import (AI_CONTENT, AI_FILES, AI_MESSAGE, BUILTIN_ALLOW, DEPENDENCY_FILES, EXAMPLE_FILES, LEGAL_FILES, MEDIA_EXT,
|
|
15
|
+
ROLE_EMAIL, SENSITIVE_FILES, SKIP_PATHS, TEXT_RULES)
|
|
16
|
+
|
|
17
|
+
INLINE_ALLOW = re.compile(r'(?i)open-pushscan\s*:\s*allow')
|
|
18
|
+
AI_AUTHOR = re.compile(r'(?i)\b(?:claude|anthropic|codex|copilot|chatgpt|cursor|gemini|aider)\b')
|
|
19
|
+
SECRET_RULES = {'private-key', 'api-key', 'password', 'url-credentials', 'webhook', 'high-entropy', 'gitleaks'}
|
|
20
|
+
# When matches overlap, the lower tier wins; inside a tier the longer match wins.
|
|
21
|
+
TIER = {'private-key': 0, 'api-key': 0, 'webhook': 0, 'fingerprint': 1, 'team': 1, 'personal': 1, 'local-path': 1,
|
|
22
|
+
'password': 2, 'url-credentials': 2, 'high-entropy': 2, 'ai-note': 4, 'ai-signature': 4}
|
|
23
|
+
ORDER = {'content': 0, 'filename': 1, 'file': 1, 'metadata': 2, 'message': 3, 'author': 4, 'committer': 4, 'tag': 5}
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
@dataclass
|
|
27
|
+
class Finding:
|
|
28
|
+
rule: str
|
|
29
|
+
text: str
|
|
30
|
+
path: str = ''
|
|
31
|
+
line: int = 0
|
|
32
|
+
commit: str = ''
|
|
33
|
+
where: str = 'content' # content, filename, file, message, author, committer, tag, metadata
|
|
34
|
+
detail: str = ''
|
|
35
|
+
|
|
36
|
+
def to_dict(self):
|
|
37
|
+
return asdict(self)
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
def _variants(value: str) -> set:
|
|
41
|
+
v = {value}
|
|
42
|
+
if '\\' in value or '/' in value:
|
|
43
|
+
v |= {value.replace('\\', '/'), value.replace('/', '\\'), value.replace('/', '\\').replace('\\', '\\\\')}
|
|
44
|
+
return {x for x in v if x}
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
class Scanner:
|
|
48
|
+
def __init__(self, repo: str = '', fingerprints=None, ai=None, large_mb=None, team=True):
|
|
49
|
+
if fingerprints is None:
|
|
50
|
+
fingerprints = config.fingerprints() or fpmod.detect()
|
|
51
|
+
self.fp_map = {}
|
|
52
|
+
for fp in fingerprints:
|
|
53
|
+
for var in _variants(fp.value):
|
|
54
|
+
self.fp_map[var.lower()] = fp
|
|
55
|
+
alts = sorted(self.fp_map, key=len, reverse=True)
|
|
56
|
+
self.fp_re = (re.compile(r'(?i)(?<![A-Za-z0-9])(?:' + '|'.join(re.escape(a) for a in alts) + r')(?![A-Za-z0-9])')
|
|
57
|
+
if alts else None)
|
|
58
|
+
self.rules = (config.team_rules() if team else []) + config.personal_rules()
|
|
59
|
+
self.allow = BUILTIN_ALLOW + config.allow_patterns()
|
|
60
|
+
self.skip = config.skip_patterns()
|
|
61
|
+
self.allowed = {(a.get('rule'), a.get('text')) for a in config.allowed() if a.get('repo') in (repo, '*')}
|
|
62
|
+
self.ai = (config.get('ai_checks') != 'off') if ai is None else ai
|
|
63
|
+
try:
|
|
64
|
+
self.large = float(large_mb if large_mb is not None else config.get('large_file_mb')) * 1_000_000
|
|
65
|
+
except ValueError:
|
|
66
|
+
self.large = 50_000_000
|
|
67
|
+
|
|
68
|
+
# ------------------------------------------------------------ text
|
|
69
|
+
|
|
70
|
+
def _allowed(self, rule: str, text: str, line: str) -> bool:
|
|
71
|
+
if (rule, text) in self.allowed or ('*', text) in self.allowed:
|
|
72
|
+
return True
|
|
73
|
+
if any(a.fullmatch(text) for a in self.allow):
|
|
74
|
+
return True
|
|
75
|
+
if rule in ('password', 'high-entropy', 'url-credentials') and any(a.fullmatch(line.strip()) for a in self.allow):
|
|
76
|
+
return True
|
|
77
|
+
return False
|
|
78
|
+
|
|
79
|
+
def scan_text(self, text: str, where='content', path='', line=0, commit='', ai_kind=None) -> list:
|
|
80
|
+
if not text:
|
|
81
|
+
return []
|
|
82
|
+
if INLINE_ALLOW.search(text):
|
|
83
|
+
return [Finding('inline-allow', text.strip()[:160], path, line, commit, where)]
|
|
84
|
+
text = text[:5000]
|
|
85
|
+
cands = [] # (priority, start, end, rule, shown text, detail)
|
|
86
|
+
if self.fp_re:
|
|
87
|
+
for m in self.fp_re.finditer(text):
|
|
88
|
+
fp = self.fp_map.get(m.group(0).lower())
|
|
89
|
+
cands.append((TIER['fingerprint'], m.start(), m.end(), 'fingerprint', m.group(0), fp.label if fp else ''))
|
|
90
|
+
for name, rx, source in self.rules:
|
|
91
|
+
for m in rx.finditer(text):
|
|
92
|
+
if m.group(0):
|
|
93
|
+
cands.append((TIER[source], m.start(), m.end(), source, m.group(0), name))
|
|
94
|
+
relaxed = set()
|
|
95
|
+
if path and DEPENDENCY_FILES.search(path):
|
|
96
|
+
relaxed |= {'private-ip', 'private-ipv6', 'mac-address'}
|
|
97
|
+
if path and LEGAL_FILES.search(path):
|
|
98
|
+
relaxed |= {'email', 'tw-mobile'}
|
|
99
|
+
if path and EXAMPLE_FILES.search(path):
|
|
100
|
+
relaxed |= {'private-ip', 'private-ipv6', 'internal-host', 'email', 'mac-address', 'local-path'}
|
|
101
|
+
for rid, rx, grp, ok in TEXT_RULES:
|
|
102
|
+
if rid in relaxed:
|
|
103
|
+
continue
|
|
104
|
+
for m in rx.finditer(text):
|
|
105
|
+
value = m.group(grp) if grp else m.group(0)
|
|
106
|
+
if not value or (ok and not ok(value)):
|
|
107
|
+
continue
|
|
108
|
+
if rid == 'private-ip' and text[max(0, m.start() - 2):m.start()] in ('==', '>=', '<=', '~='):
|
|
109
|
+
continue # a package version, not an address
|
|
110
|
+
if rid == 'email' and ROLE_EMAIL.search(value):
|
|
111
|
+
continue # public service or role address, not a person
|
|
112
|
+
s, e = (m.start(grp), m.end(grp)) if grp else (m.start(), m.end())
|
|
113
|
+
cands.append((TIER.get(rid, 3), s, e, rid, m.group(0), ''))
|
|
114
|
+
if self.ai and ai_kind:
|
|
115
|
+
for rx in (AI_CONTENT if ai_kind == 'content' else AI_MESSAGE):
|
|
116
|
+
for m in rx.finditer(text):
|
|
117
|
+
cands.append((TIER['ai-note'], m.start(), m.end(), 'ai-note' if ai_kind == 'content' else 'ai-signature', m.group(0), ''))
|
|
118
|
+
out, kept = [], []
|
|
119
|
+
for pri, s, e, rule, shown, detail in sorted(cands, key=lambda c: (c[0], -(c[2] - c[1]), c[1])):
|
|
120
|
+
if any(s < ke and ks < e for ks, ke in kept):
|
|
121
|
+
continue
|
|
122
|
+
if self._allowed(rule, shown, text):
|
|
123
|
+
continue
|
|
124
|
+
kept.append((s, e))
|
|
125
|
+
out.append(Finding(rule, shown, path, line, commit, where, detail))
|
|
126
|
+
return out
|
|
127
|
+
|
|
128
|
+
# ------------------------------------------------------------ commit details
|
|
129
|
+
|
|
130
|
+
def scan_identity(self, ident: str, field: str, commit: str) -> list:
|
|
131
|
+
out = []
|
|
132
|
+
for f in self.scan_text(ident, field, commit=commit):
|
|
133
|
+
if f.rule in ('fingerprint', 'team', 'personal', 'email', 'local-path', 'private-ip', 'internal-host'):
|
|
134
|
+
detail = f.detail or f.rule
|
|
135
|
+
out.append(Finding('commit-identity', f.text, '', 0, commit, field, detail))
|
|
136
|
+
else:
|
|
137
|
+
out.append(f)
|
|
138
|
+
if self.ai and AI_AUTHOR.search(ident) and not self._allowed('ai-signature', ident, ident):
|
|
139
|
+
out.append(Finding('ai-signature', ident, '', 0, commit, field, ''))
|
|
140
|
+
return out
|
|
141
|
+
|
|
142
|
+
def scan_message(self, message: str, commit: str) -> list:
|
|
143
|
+
out = []
|
|
144
|
+
for i, line in enumerate(message.splitlines(), 1):
|
|
145
|
+
out += self.scan_text(line, 'message', '', i, commit, ai_kind='message')
|
|
146
|
+
return out
|
|
147
|
+
|
|
148
|
+
# ------------------------------------------------------------ a commit or the working changes
|
|
149
|
+
|
|
150
|
+
def skipped(self, path: str) -> bool:
|
|
151
|
+
return bool(SKIP_PATHS.search(path) or any(p.search(path) for p in self.skip))
|
|
152
|
+
|
|
153
|
+
def scan_change(self, change, blob, size) -> list:
|
|
154
|
+
commit = change.commit[:7] if change.commit else ''
|
|
155
|
+
out = []
|
|
156
|
+
if change.author:
|
|
157
|
+
out += self.scan_identity(change.author, 'author', commit)
|
|
158
|
+
if change.committer and change.committer != change.author:
|
|
159
|
+
out += self.scan_identity(change.committer, 'committer', commit)
|
|
160
|
+
if change.message:
|
|
161
|
+
out += self.scan_message(change.message, commit)
|
|
162
|
+
for path, status in change.files.items():
|
|
163
|
+
if status == 'D' or self.skipped(path):
|
|
164
|
+
continue
|
|
165
|
+
if SENSITIVE_FILES.search(path):
|
|
166
|
+
out.append(Finding('sensitive-file', path, path, 0, commit, 'file'))
|
|
167
|
+
if self.ai and AI_FILES.search(path):
|
|
168
|
+
out.append(Finding('ai-config', path, path, 0, commit, 'file'))
|
|
169
|
+
for f in self.scan_text(path, 'filename', path, 0, commit):
|
|
170
|
+
if f.rule in ('fingerprint', 'team', 'personal', 'email', 'tw-id', 'tw-mobile'):
|
|
171
|
+
out.append(f)
|
|
172
|
+
n = size(change, path)
|
|
173
|
+
if n > self.large:
|
|
174
|
+
out.append(Finding('large-file', f'{n / 1_000_000:.0f} MB', path, 0, commit, 'file'))
|
|
175
|
+
if MEDIA_EXT.search(path):
|
|
176
|
+
found, texts = media.inspect(path, blob(change, path))
|
|
177
|
+
for rule, detail in found:
|
|
178
|
+
if not self._allowed(rule, detail, detail):
|
|
179
|
+
out.append(Finding(rule, detail, path, 0, commit, 'metadata'))
|
|
180
|
+
for t in texts:
|
|
181
|
+
for piece in t.splitlines():
|
|
182
|
+
out += self.scan_text(piece, 'metadata', path, 0, commit)
|
|
183
|
+
for path, ln, text in change.lines:
|
|
184
|
+
if self.skipped(path) or (self.ai and AI_FILES.search(path)):
|
|
185
|
+
continue
|
|
186
|
+
out += self.scan_text(text, 'content', path, ln, commit, ai_kind='content')
|
|
187
|
+
return out
|
|
188
|
+
|
|
189
|
+
|
|
190
|
+
# ---------------------------------------------------------------- gitleaks (used only when installed)
|
|
191
|
+
|
|
192
|
+
def gitleaks(rev_args=None, staged=False) -> list:
|
|
193
|
+
exe = shutil.which('gitleaks')
|
|
194
|
+
if not exe:
|
|
195
|
+
return []
|
|
196
|
+
fd, report = tempfile.mkstemp(suffix='.json')
|
|
197
|
+
os.close(fd)
|
|
198
|
+
attempts = []
|
|
199
|
+
if staged:
|
|
200
|
+
attempts = [[exe, 'git', '--staged', '--pre-commit'], [exe, 'protect', '--staged']]
|
|
201
|
+
else:
|
|
202
|
+
opts = ' '.join(rev_args or [])
|
|
203
|
+
attempts = [[exe, 'git', f'--log-opts={opts}'], [exe, 'detect', f'--log-opts={opts}']]
|
|
204
|
+
try:
|
|
205
|
+
for args in attempts:
|
|
206
|
+
p = subprocess.run(args + ['--no-banner', '--exit-code', '0', '--report-format', 'json', '--report-path', report],
|
|
207
|
+
capture_output=True, timeout=300)
|
|
208
|
+
if p.returncode == 0:
|
|
209
|
+
break
|
|
210
|
+
else:
|
|
211
|
+
return []
|
|
212
|
+
with open(report, encoding='utf-8') as f:
|
|
213
|
+
items = json.load(f) or []
|
|
214
|
+
except (OSError, ValueError, subprocess.SubprocessError):
|
|
215
|
+
return []
|
|
216
|
+
finally:
|
|
217
|
+
try:
|
|
218
|
+
os.remove(report)
|
|
219
|
+
except OSError:
|
|
220
|
+
pass
|
|
221
|
+
out = []
|
|
222
|
+
for it in items:
|
|
223
|
+
secret = it.get('Secret') or it.get('Match') or ''
|
|
224
|
+
out.append(Finding('gitleaks', secret, it.get('File', ''), it.get('StartLine', 0) or 0,
|
|
225
|
+
(it.get('Commit') or '')[:7], 'content', it.get('RuleID', '')))
|
|
226
|
+
return out
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
"""Is the place a push goes to public? Ask GitHub without signing in, and remember the answer for a while.
|
|
2
|
+
|
|
3
|
+
When the answer cannot be found (no network, not GitHub, no remote), the last known answer is used; a repository
|
|
4
|
+
never checked before is treated as public, so nothing slips through.
|
|
5
|
+
"""
|
|
6
|
+
from __future__ import annotations
|
|
7
|
+
|
|
8
|
+
import json
|
|
9
|
+
import os
|
|
10
|
+
import re
|
|
11
|
+
import time
|
|
12
|
+
import urllib.error
|
|
13
|
+
import urllib.request
|
|
14
|
+
|
|
15
|
+
from . import config
|
|
16
|
+
|
|
17
|
+
PUBLIC, PRIVATE, UNKNOWN = 'public', 'private', 'unknown'
|
|
18
|
+
TTL = {PUBLIC: 86400, PRIVATE: 3600}
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
def github_repo(url: str):
|
|
22
|
+
m = re.match(r'^(?:git@github\.com:|ssh://git@github\.com/|https?://(?:[^@/]+@)?github\.com/)([^/]+)/([^/]+?)(?:\.git)?/?$', url.strip())
|
|
23
|
+
return (m.group(1), m.group(2)) if m else None
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
def _host(url: str) -> str:
|
|
27
|
+
m = re.match(r'^(?:[\w+.-]+://)?(?:[^@/]+@)?([^/:]+)', url.strip())
|
|
28
|
+
return m.group(1).lower() if m else ''
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
def _cache_path() -> str:
|
|
32
|
+
return config.path('state', 'visibility.json')
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
def _cache() -> dict:
|
|
36
|
+
try:
|
|
37
|
+
with open(_cache_path(), encoding='utf-8') as f:
|
|
38
|
+
return json.load(f)
|
|
39
|
+
except (OSError, ValueError):
|
|
40
|
+
return {}
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
def check(url: str) -> str:
|
|
44
|
+
if os.environ.get('OPEN_PUSHSCAN_VISIBILITY') == PUBLIC:
|
|
45
|
+
return PUBLIC # only ever stricter: nothing can make a repository count as private this way
|
|
46
|
+
if not url:
|
|
47
|
+
return UNKNOWN
|
|
48
|
+
if os.path.isdir(url) or url.startswith('file://'):
|
|
49
|
+
return PRIVATE # a folder on this computer is not published anywhere
|
|
50
|
+
private_hosts = [h.strip().lower() for h in config.get('private_hosts').split(',') if h.strip()]
|
|
51
|
+
if _host(url) in private_hosts:
|
|
52
|
+
return PRIVATE
|
|
53
|
+
gh = github_repo(url)
|
|
54
|
+
if not gh:
|
|
55
|
+
return UNKNOWN
|
|
56
|
+
key = f'{gh[0]}/{gh[1]}'.lower()
|
|
57
|
+
cache = _cache()
|
|
58
|
+
hit = cache.get(key)
|
|
59
|
+
if hit and time.time() - hit[1] < TTL.get(hit[0], 0):
|
|
60
|
+
return hit[0]
|
|
61
|
+
answer = UNKNOWN
|
|
62
|
+
try:
|
|
63
|
+
req = urllib.request.Request(f'https://api.github.com/repos/{gh[0]}/{gh[1]}',
|
|
64
|
+
headers={'User-Agent': 'open-pushscan', 'Accept': 'application/vnd.github+json'})
|
|
65
|
+
with urllib.request.urlopen(req, timeout=4) as r:
|
|
66
|
+
data = json.load(r)
|
|
67
|
+
answer = PRIVATE if data.get('private') else PUBLIC
|
|
68
|
+
except urllib.error.HTTPError as e:
|
|
69
|
+
answer = PRIVATE if e.code == 404 else UNKNOWN # 404 without signing in = private (or not created yet)
|
|
70
|
+
except (urllib.error.URLError, OSError, ValueError):
|
|
71
|
+
answer = UNKNOWN
|
|
72
|
+
if answer == UNKNOWN and hit:
|
|
73
|
+
return hit[0] # offline: a repository rarely changes between public and private, so use the last answer
|
|
74
|
+
if answer != UNKNOWN:
|
|
75
|
+
cache[key] = [answer, time.time()]
|
|
76
|
+
try:
|
|
77
|
+
config.ensure()
|
|
78
|
+
with open(_cache_path(), 'w', encoding='utf-8') as f:
|
|
79
|
+
json.dump(cache, f)
|
|
80
|
+
except OSError:
|
|
81
|
+
pass
|
|
82
|
+
return answer
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
def blocks(answer: str) -> bool:
|
|
86
|
+
"""Public and unknown destinations are blocked; private ones only get a reminder."""
|
|
87
|
+
return answer != PRIVATE
|
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: open-pushscan
|
|
3
|
+
Version: 0.3.0
|
|
4
|
+
Summary: Check what you are about to make public: host names, local paths, personal data, keys and AI tool files
|
|
5
|
+
License-Expression: Apache-2.0
|
|
6
|
+
Requires-Python: >=3.9
|
|
7
|
+
Description-Content-Type: text/markdown
|
|
8
|
+
License-File: LICENSE
|
|
9
|
+
Dynamic: license-file
|
|
10
|
+
|
|
11
|
+
# open-pushscan
|
|
12
|
+
|
|
13
|
+
**English** | [繁體中文](README.zh-TW.md)
|
|
14
|
+
|
|
15
|
+
Before you commit or push, open-pushscan looks for things that should not be public: who you are, your computer's
|
|
16
|
+
names, your organisation's internal details, passwords and keys. If it finds any, it stops the commit or push and
|
|
17
|
+
tells you how to fix it.
|
|
18
|
+
|
|
19
|
+
It finds your computer's names and network addresses by itself, so there is nothing to set up.
|
|
20
|
+
|
|
21
|
+
## Get started
|
|
22
|
+
|
|
23
|
+
```
|
|
24
|
+
pip install git+https://github.com/yu-ken0207/open-pushscan
|
|
25
|
+
open-pushscan setup
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
That's it. Commit and push as usual; open-pushscan only speaks up when it finds something.
|
|
29
|
+
|
|
30
|
+
`setup`:
|
|
31
|
+
|
|
32
|
+
- makes every repository on this computer checked, including ones you clone later
|
|
33
|
+
- finds the names and network addresses that identify you (called "fingerprints" below) and shows them to you
|
|
34
|
+
- asks whether you have team rules to use; press Enter if not
|
|
35
|
+
- if you have Claude Code or Codex, stops them from skipping the checks
|
|
36
|
+
|
|
37
|
+
> Typed `open-pushscan` and got "command not found"? This is common on Windows, where pip installs it in a folder
|
|
38
|
+
> outside PATH. Use `python -m open_pushscan` instead, for example `python -m open_pushscan setup`. open-pushscan's
|
|
39
|
+
> own messages also show the form that runs on your computer.
|
|
40
|
+
|
|
41
|
+
## When something is found
|
|
42
|
+
|
|
43
|
+
```
|
|
44
|
+
open-pushscan stopped this push (it goes to a public repo)
|
|
45
|
+
|
|
46
|
+
1. src/app.py line 12 | Your account folder on this computer
|
|
47
|
+
/home/you/
|
|
48
|
+
Why: The path shows your account name and how your folders are laid out
|
|
49
|
+
Fix: Use a relative path, or ~ for the home folder
|
|
50
|
+
|
|
51
|
+
2. photo.jpg hidden details | GPS location inside a photo
|
|
52
|
+
25.04, 121.55
|
|
53
|
+
Why: The photo records where it was taken, which may be your home or office
|
|
54
|
+
Fix: Save a copy without location (most photo apps have "remove location")
|
|
55
|
+
|
|
56
|
+
Fix these, commit again, then push.
|
|
57
|
+
If item 1 is fine: open-pushscan allow 1
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
- **Fix what the report says**, then commit again.
|
|
61
|
+
- **It's fine?** `open-pushscan allow 1` (use the number from the report). It asks you once more and only works in a
|
|
62
|
+
terminal you opened yourself, so an AI assistant cannot allow things for you. You can also add
|
|
63
|
+
`open-pushscan: allow` to the end of that line; lines with it are listed on every commit, so if someone else added
|
|
64
|
+
one, you will notice.
|
|
65
|
+
- **Pushing to a private repository?** You get the same list as a reminder, but nothing is stopped.
|
|
66
|
+
|
|
67
|
+
## What it checks
|
|
68
|
+
|
|
69
|
+
| | Examples |
|
|
70
|
+
|---|---|
|
|
71
|
+
| Your computer | host name, account name, home folder, network and Tailscale addresses, ssh hosts, the email in your git settings — found automatically |
|
|
72
|
+
| Team rules | your organisation, project and client names, internal domains (shared through a private repository) |
|
|
73
|
+
| Private network | private IP addresses, internal host names, MAC addresses |
|
|
74
|
+
| Local paths | `/home/you/…`, `C:\Users\you\…` |
|
|
75
|
+
| Personal data | email addresses, Taiwan ID numbers, mobile numbers |
|
|
76
|
+
| Passwords and keys | GitHub, AWS, Google, OpenAI, Anthropic, Slack and other keys, private keys, passwords written in code, webhook URLs; also uses [gitleaks](https://github.com/gitleaks/gitleaks) if you have it |
|
|
77
|
+
| Sensitive files | `.env`, `id_rsa`, `*.pem`, `credentials.json`, kubeconfig, AI chat logs, files over 50 MB |
|
|
78
|
+
| Commit details | author name and email, commit messages, tag names |
|
|
79
|
+
| Hidden file details | photo GPS, owner and device (JPEG, PNG, WebP, TIFF, HEIC); text hidden in PNG; author and company in PDF, Word, Excel and PowerPoint |
|
|
80
|
+
| AI tool files | `CLAUDE.md`, `AGENTS.md`, `.cursor/` and similar notes for AI tools, AI signatures in commit messages |
|
|
81
|
+
|
|
82
|
+
## When it checks
|
|
83
|
+
|
|
84
|
+
| | Public repository | Private repository |
|
|
85
|
+
|---|---|---|
|
|
86
|
+
| `git commit` | stops | reminds |
|
|
87
|
+
| `git push` | stops | reminds |
|
|
88
|
+
| `open-pushscan check` | lists everything | lists everything |
|
|
89
|
+
| GitHub Action | stops | stops |
|
|
90
|
+
|
|
91
|
+
If open-pushscan cannot tell whether a repository is public (no network, not on GitHub, no remote yet), it treats it
|
|
92
|
+
as public.
|
|
93
|
+
|
|
94
|
+
## Commands
|
|
95
|
+
|
|
96
|
+
| Command | What it does |
|
|
97
|
+
|---|---|
|
|
98
|
+
| `open-pushscan setup` | First time: install, find fingerprints, set up team rules |
|
|
99
|
+
| `open-pushscan check` | Check this repository right now (uncommitted changes, and commits not pushed yet) |
|
|
100
|
+
| `open-pushscan check --history` | Check the whole history |
|
|
101
|
+
| `open-pushscan publish-check` | Everything to look at before making a private repository public |
|
|
102
|
+
| `open-pushscan allow N` | Stop reporting item N of the last report (asks you to confirm) |
|
|
103
|
+
| `open-pushscan status` | See what is installed and checked |
|
|
104
|
+
| `open-pushscan uninstall` | Remove it (from git, Claude Code and Codex) |
|
|
105
|
+
|
|
106
|
+
## Common situations
|
|
107
|
+
|
|
108
|
+
**Making a private repository public.** Run `open-pushscan publish-check`. It checks the whole history, tells you how
|
|
109
|
+
to clean it, and looks at releases, issues, pull requests and the wiki on GitHub. One thing to know: if you rewrite a
|
|
110
|
+
repository's history, GitHub still keeps the old commits, readable by anyone who knows the commit id. Push the cleaned
|
|
111
|
+
history to a brand-new repository instead of switching the old one to public.
|
|
112
|
+
|
|
113
|
+
**Team rules.** Put one name per line in a `.txt` file in a private GitHub repository and give your team read access. Each
|
|
114
|
+
person runs `open-pushscan setup --team <address>`; the rules update once a day.
|
|
115
|
+
|
|
116
|
+
```
|
|
117
|
+
# a word: matched as a whole word, upper or lower case
|
|
118
|
+
Example Corp
|
|
119
|
+
project-falcon
|
|
120
|
+
# a regular expression
|
|
121
|
+
re:\bEXC-\d{4}\b
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
**Checks on GitHub too.** In a repository, run `open-pushscan setup --github-action`, then commit and push the file it
|
|
125
|
+
creates. GitHub then checks every push and pull request, including edits made on the website. Or add it to a workflow
|
|
126
|
+
yourself:
|
|
127
|
+
|
|
128
|
+
```yaml
|
|
129
|
+
on: [push, pull_request]
|
|
130
|
+
permissions:
|
|
131
|
+
contents: read
|
|
132
|
+
jobs:
|
|
133
|
+
open-pushscan:
|
|
134
|
+
runs-on: ubuntu-latest
|
|
135
|
+
steps:
|
|
136
|
+
- uses: actions/checkout@v4
|
|
137
|
+
with:
|
|
138
|
+
fetch-depth: 0 # lets it see every commit in the push
|
|
139
|
+
- uses: yu-ken0207/open-pushscan@v0
|
|
140
|
+
with:
|
|
141
|
+
team-rules: ${{ secrets.OPEN_PUSHSCAN_RULES }} # optional
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
On GitHub it cannot see your computer's names and addresses, so it checks everything else: keys, private IP addresses,
|
|
145
|
+
local paths, personal data, AI tool files, and team rules if you save them as a repository secret named
|
|
146
|
+
`OPEN_PUSHSCAN_RULES`.
|
|
147
|
+
|
|
148
|
+
**Projects that use the pre-commit framework.** If a project manages its hooks with [pre-commit](https://pre-commit.com),
|
|
149
|
+
add open-pushscan to its `.pre-commit-config.yaml` instead of running `setup` (pre-commit will not install its hooks
|
|
150
|
+
while `setup`'s hooks folder is in use):
|
|
151
|
+
|
|
152
|
+
```yaml
|
|
153
|
+
repos:
|
|
154
|
+
- repo: https://github.com/yu-ken0207/open-pushscan
|
|
155
|
+
rev: v0.3.0
|
|
156
|
+
hooks:
|
|
157
|
+
- id: open-pushscan
|
|
158
|
+
- id: open-pushscan-commit-msg
|
|
159
|
+
- id: open-pushscan-pre-push
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
Then run `pre-commit install -t pre-commit -t commit-msg -t pre-push`.
|
|
163
|
+
|
|
164
|
+
**A repository with its own hooks folder.** Some projects set `core.hooksPath` themselves, which hides open-pushscan.
|
|
165
|
+
`open-pushscan status` tells you, and how to connect it.
|
|
166
|
+
|
|
167
|
+
**Letting an AI assistant write code (Claude Code, Codex).** `setup` adds a check to the settings of Claude Code and
|
|
168
|
+
Codex that stops the usual ways around open-pushscan: `--no-verify`, changing `core.hooksPath`, editing the settings folder, and running
|
|
169
|
+
`open-pushscan allow` or `uninstall`. It also adds a short note to their instructions (`CLAUDE.md`, `AGENTS.md`): fix
|
|
170
|
+
what the report says, and ask you when they think something is a false alarm. For Codex, open it once, type `/hooks`
|
|
171
|
+
and trust the open-pushscan check. `open-pushscan status` shows whether they are protected.
|
|
172
|
+
|
|
173
|
+
**Skipping the check once.** `git push --no-verify` skips every hook. Use it only when you are sure.
|
|
174
|
+
|
|
175
|
+
## Your settings
|
|
176
|
+
|
|
177
|
+
Everything stays on your computer (`~/.config/open-pushscan` on Linux and macOS, `%APPDATA%\open-pushscan` on
|
|
178
|
+
Windows), never inside a repository:
|
|
179
|
+
|
|
180
|
+
- `fingerprints.txt`: your fingerprints, the names and network addresses that identify you. Add a line to check one
|
|
181
|
+
more; put `-` in front of a line to stop checking it.
|
|
182
|
+
- `rules.txt`: words or patterns you want checked, same format as team rules.
|
|
183
|
+
- `allowed.json`: items you allowed with `open-pushscan allow`.
|
|
184
|
+
|
|
185
|
+
It goes online for one thing only: asking GitHub whether a repository is public, without signing in to your account.
|
|
186
|
+
|
|
187
|
+
## Requirements
|
|
188
|
+
|
|
189
|
+
Python 3.9 or newer and git. Tested on Linux and Windows; macOS should work too. No other packages are needed.
|
|
190
|
+
|
|
191
|
+
## License
|
|
192
|
+
|
|
193
|
+
Apache-2.0
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
open_pushscan/__init__.py,sha256=6KRCXmGf5N5f-6WgnpC0RwICpV4ApJ4MLDa45blE29I,115
|
|
2
|
+
open_pushscan/__main__.py,sha256=E6Gls0DNz8GQK2K-kOUIx8cYhgANW_CH54VKrfCfs14,52
|
|
3
|
+
open_pushscan/agents.py,sha256=kL0jC0HMoji7w5KFh6Gl4IY0CYRlvyILlFkbmwcT1jQ,29425
|
|
4
|
+
open_pushscan/ci.py,sha256=BJ_qR5Qc32WIc8FV-1SBp_Nh3Qxbay4swdbvDAyjYfg,3889
|
|
5
|
+
open_pushscan/cli.py,sha256=Szc5RDXyBe2DuWTHsYVn-ZdhZdxAvOFMGQH8u_89VFg,25794
|
|
6
|
+
open_pushscan/config.py,sha256=xdiAU9dSleECUqk-tlyA2I4jzYxxHdJCTHN2gdH_3Ko,8697
|
|
7
|
+
open_pushscan/fingerprints.py,sha256=rxIzDrGt-f4ryZW7a9wzrGSW0MTeT9IIxdXgrULoVDo,5904
|
|
8
|
+
open_pushscan/gitscan.py,sha256=dt4CKZZC_SntTTyeYh3UNhwQ2xUPq88zhO1ff4bAMRY,9147
|
|
9
|
+
open_pushscan/hooks.py,sha256=JXfPOaLUgJLPxxD6-Sl5Vkkjbru7HnaA8Nq-CNX8BvE,4994
|
|
10
|
+
open_pushscan/i18n.py,sha256=6BmLWaK0m1XPJ8FqZuWRykRxdoT557wlHOUaOW3-VTQ,5180
|
|
11
|
+
open_pushscan/media.py,sha256=WFyAMMETjzzCMRR9ddQA67oFDt1CfaE0qzk_2SKAcxc,11239
|
|
12
|
+
open_pushscan/publish.py,sha256=eV7KdWY-iUqwTjGSnamJ6g29DO59N3anmt_7dXIoX-k,9233
|
|
13
|
+
open_pushscan/report.py,sha256=Jmds7R9K4NFyQse-eeSoUmUSH6fdJOWy4jHwCwUYL68,4708
|
|
14
|
+
open_pushscan/rules.py,sha256=Br1JpgjZl2gEMn44pdOvUEETTkF3N2j2jP7XlWKFg84,22020
|
|
15
|
+
open_pushscan/scanner.py,sha256=NqZlJylx4zwk9NBH6aGjORedt5cvJGNzMp7srxKQIQM,10608
|
|
16
|
+
open_pushscan/visibility.py,sha256=pdcu1pfTbmHnmS3vJE_SljMP2X5CcqfTen1N8u3I_FA,3100
|
|
17
|
+
open_pushscan-0.3.0.dist-info/licenses/LICENSE,sha256=z8d0m5b2O9McPEK1xHG_dWgUBT6EfBDz6wA0F7xSPTA,11358
|
|
18
|
+
open_pushscan-0.3.0.dist-info/METADATA,sha256=W9ONl-bBZL_FsrbjX0GmTs9jb6k6b6G0Fvya1dtisHw,8705
|
|
19
|
+
open_pushscan-0.3.0.dist-info/WHEEL,sha256=mOdXR9C3wMVov7cSY8PY-XCzo3SmmWCHvGQr5csJoao,91
|
|
20
|
+
open_pushscan-0.3.0.dist-info/entry_points.txt,sha256=6qrZHct28fWjsJQxMKWwI92QGjlBU4eFvkGPe13pESI,57
|
|
21
|
+
open_pushscan-0.3.0.dist-info/top_level.txt,sha256=e9Cta26apbbk2exh5-qmooQFyySjHNz09zWCUOnDkQE,14
|
|
22
|
+
open_pushscan-0.3.0.dist-info/RECORD,,
|