forked from mtusi2026/mtusi2026lab7
16 lines
591 B
Python
16 lines
591 B
Python
"""Print a compact inventory from raw Trivy JSON."""
|
|
import collections
|
|
import json
|
|
import sys
|
|
from pathlib import Path
|
|
|
|
for path in sorted(Path(sys.argv[1]).glob("*.json")):
|
|
report = json.loads(path.read_text())
|
|
matches = {}
|
|
for target in report.get("Results", []):
|
|
for entry in target.get("Vulnerabilities") or []:
|
|
key = entry["VulnerabilityID"], entry["PkgName"], entry["InstalledVersion"]
|
|
matches[key] = entry
|
|
counts = collections.Counter(entry["Severity"] for entry in matches.values())
|
|
print(path.name, dict(sorted(counts.items())))
|