|
13 | 13 |
|
14 | 14 | # Create a list of dictionaries for scanning
|
15 | 15 | to_scan = []
|
16 |
| -for name in glob.glob("**/*"): |
| 16 | +for name in glob.glob("**/*", recursive=True): |
17 | 17 | with open(name) as fn:
|
18 | 18 | to_scan.append({"document": fn.read(), "filename": os.path.basename(name)})
|
19 | 19 |
|
|
22 | 22 | for i in range(0, len(to_scan), MULTI_DOCUMENT_LIMIT):
|
23 | 23 | chunk = to_scan[i : i + MULTI_DOCUMENT_LIMIT]
|
24 | 24 | try:
|
25 |
| - scan, status_code = client.multi_content_scan(chunk) |
| 25 | + scan = client.multi_content_scan(chunk) |
26 | 26 | except Exception as exc:
|
27 | 27 | # Handle exceptions such as schema validation
|
28 | 28 | traceback.print_exc(2, file=sys.stderr)
|
29 | 29 | print(str(exc))
|
30 |
| - if status_code != 200: |
| 30 | + if not scan.success: |
31 | 31 | print("Error scanning some files. Results may be incomplete.")
|
32 |
| - to_process.extend(scan) |
| 32 | + print(scan) |
| 33 | + to_process.extend(scan.scan_results) |
| 34 | + continue |
33 | 35 |
|
34 |
| -for scan_result in to_process: |
35 |
| - print("Scan results:", scan_result.has_secrets, "-", scan_result.policy_break_count) |
| 36 | +for i, scan_result in enumerate(to_process): |
| 37 | + if scan_result.has_secrets: |
| 38 | + print(f"{chunk[i]['filename']}: {scan_result.policy_break_count} break/s found") |
| 39 | + for policy_break in scan_result.policy_breaks: |
| 40 | + print(f"\t{policy_break.break_type}:") |
| 41 | + for match in policy_break.matches: |
| 42 | + print(f"\t\t{match.match_type}:{match.match}") |
0 commit comments