"""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'(? 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))