Initial Adaptive Music v0.5.0 release
This commit is contained in:
commit
14f0d8c26b
114 files changed
+6907
No files matched your search
@@ -0,0 +1,52 @@
|
||||
"""Offline tracked/unignored-file guardrails; not a complete secret scanner."""
|
||||
from __future__ import annotations
|
||||
|
||||
import ipaddress
|
||||
from pathlib import Path
|
||||
import re
|
||||
import subprocess
|
||||
|
||||
ROOT = Path(__file__).resolve().parents[1]
|
||||
REQUIRED = ('AGENTS.md', 'ARCHITECTURE.md', 'PROGRESS.md', 'TESTING.md',
|
||||
'SECURITY.md', 'THIRD-PARTY-NOTICES', '.gitignore')
|
||||
|
||||
|
||||
def findings(name: str, data: str) -> list[str]:
|
||||
issues = []
|
||||
if name.startswith('.local/') or Path(name).name.startswith('.env'):
|
||||
issues.append('private configuration file included')
|
||||
for candidate in re.findall(r'(?<![\w.])(?:\d{1,3}\.){3}\d{1,3}(?![\w.])', data):
|
||||
try:
|
||||
address = ipaddress.ip_address(candidate)
|
||||
except ValueError:
|
||||
continue
|
||||
if address.is_private and not address.is_loopback:
|
||||
issues.append('private IP address included')
|
||||
if re.search(r'-----BEGIN (?:RSA |EC |OPENSSH )?PRIVATE KEY-----', data):
|
||||
issues.append('private key material included')
|
||||
if re.search(r'https?://[^\s/@]+:[^\s/@]+@', data):
|
||||
issues.append('URL credentials included')
|
||||
return sorted(set(issues))
|
||||
|
||||
|
||||
def audit() -> list[str]:
|
||||
errors = [f'missing {name}' for name in REQUIRED if not (ROOT / name).is_file()]
|
||||
paths = subprocess.check_output(
|
||||
['git', 'ls-files', '-z', '--cached', '--others', '--exclude-standard'],
|
||||
cwd=ROOT).decode().split('\0')
|
||||
for name in sorted(set(filter(None, paths))):
|
||||
path = ROOT / name
|
||||
if path.is_file():
|
||||
errors.extend(f'{name}: {reason}' for reason in findings(
|
||||
name, path.read_text(errors='replace')))
|
||||
notices = (ROOT / 'THIRD-PARTY-NOTICES').read_text()
|
||||
for credit in ('CheddahBoxMB', '3 Death Saves', 'Furyspark', 'Tyler', 'Apache-2.0'):
|
||||
if credit not in notices:
|
||||
errors.append(f'missing attribution: {credit}')
|
||||
return errors
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
problems = audit()
|
||||
print('\n'.join(problems) if problems else 'PASS: repository privacy/attribution guardrails')
|
||||
raise SystemExit(bool(problems))
|
||||
Reference in new issue
Block a user