import sys, json, subprocess
result = subprocess.run(['uv', 'run', 'python', 'scripts/audit_exception_handling.py', '--json'],
                        capture_output=True, text=True)
data = json.loads(result.stdout)
for f in data['files']:
    fn = f.get('filename', '')
    if fn.endswith('api_hooks.py') or fn.endswith('app_controller.py'):
        bfapi = [x for x in f.get('findings', []) if x.get('category') == 'BOUNDARY_FASTAPI']
        print(fn + ': ' + str(len(bfapi)) + ' BOUNDARY_FASTAPI sites')
        for x in bfapi[:5]:
            print('  L' + str(x['line']) + ': ' + x['snippet'][:60])
