| |
| """Run all audit scripts and print a summary.""" |
|
|
| import sys |
| import argparse |
| import subprocess |
| from pathlib import Path |
| from datetime import datetime |
|
|
| |
| |
| |
| _SCRIPTS_DIR = Path(__file__).parent |
| _HAS_SANITIZATION = (_SCRIPTS_DIR / 'audit_sanitization.py').exists() |
|
|
| AUDITS = [ |
| ('sanitization', 'Sanitization (PII verification)'), |
| ('users', 'Users (Survey Responses)'), |
| ('card', 'Card (Basic Card Test)'), |
| ('cardd', 'CardD (Card Draw)'), |
| ('cards', 'CardS (Sequential Card)'), |
| ('rv', 'RV (Full Remote Viewing)'), |
| ('rvq', 'RVQ (Quick Remote Viewing)'), |
| ('location', 'Location (Coordinate RV)'), |
| ('lottery', 'Lottery'), |
| ('identifier_survey', 'Identifier Survey (cross-dataset)'), |
| ] |
|
|
|
|
| def main(): |
| parser = argparse.ArgumentParser(description='Run all audit scripts') |
| parser.add_argument('--only', nargs='+', metavar='NAME', |
| help='Run only these audits') |
| parser.add_argument('--skip', nargs='+', metavar='NAME', |
| help='Skip these audits') |
| args = parser.parse_args() |
|
|
| audits = AUDITS.copy() |
| if args.only: |
| audits = [(n, d) for n, d in AUDITS if n in args.only] |
| if not audits: |
| print(f'No valid audits in --only: {args.only}') |
| print(f'Available: {", ".join(n for n, _ in AUDITS)}') |
| sys.exit(1) |
| if args.skip: |
| audits = [(n, d) for n, d in audits if n not in args.skip] |
|
|
| scripts_dir = Path(__file__).parent |
|
|
| print('=' * 70) |
| print('GotPsi Audit Suite') |
| print('=' * 70) |
| print(f'\nRunning {len(audits)} audit(s):') |
| for name, desc in audits: |
| print(f' - {name:25s} {desc}') |
| print() |
|
|
| start_time = datetime.now() |
| results = [] |
|
|
| for i, (name, desc) in enumerate(audits, 1): |
| print('=' * 70) |
| print(f'[{i}/{len(audits)}] {desc}') |
| print('=' * 70) |
| print() |
|
|
| |
| |
| if name == 'sanitization' and not _HAS_SANITIZATION: |
| print('audit_sanitization not present (public artifact) -- skipping') |
| results.append((name, 'SKIPPED', 'not present in public artifact')) |
| print() |
| continue |
|
|
| script = scripts_dir / f'audit_{name}.py' |
| if not script.exists(): |
| print(f'Script not found: {script}') |
| results.append((name, 'FAILED', 'Script not found')) |
| continue |
|
|
| audit_start = datetime.now() |
| try: |
| subprocess.run([sys.executable, str(script)], check=True) |
| elapsed = datetime.now() - audit_start |
| results.append((name, 'SUCCESS', str(elapsed))) |
| except subprocess.CalledProcessError as e: |
| elapsed = datetime.now() - audit_start |
| results.append((name, 'FAILED', f'Exit code {e.returncode}')) |
| except KeyboardInterrupt: |
| results.append((name, 'INTERRUPTED', '-')) |
| break |
|
|
| print() |
|
|
| total_elapsed = datetime.now() - start_time |
|
|
| print() |
| print('=' * 70) |
| print('Audit Suite Complete') |
| print('=' * 70) |
| print(f'\nTotal time: {total_elapsed}') |
|
|
| success = sum(1 for _, s, _ in results if s == 'SUCCESS') |
| failed = sum(1 for _, s, _ in results if s == 'FAILED') |
| skipped = sum(1 for _, s, _ in results if s == 'SKIPPED') |
|
|
| print(f'Audits run: {len(results)}') |
| print(f'Successful: {success}') |
| print(f'Failed: {failed}') |
| if skipped: |
| print(f'Skipped: {skipped}') |
| print() |
|
|
| for name, status, info in results: |
| icon = '+' if status == 'SUCCESS' else ('-' if status == 'SKIPPED' else 'X') |
| print(f' [{icon}] {name:25s} {status:12s} {info}') |
| print() |
|
|
| if failed > 0: |
| sys.exit(1) |
|
|
|
|
| if __name__ == '__main__': |
| main() |
|
|