Improved CSV Generation
A Python utility to extract vulnerability data from Trivy's JSON structure.
Processing Logic
- Load the JSON report.
- Iterate
Results->Vulnerabilities. - Extract
PkgName,InstalledVersion,VulnerabilityID,Severity,CVSS(checking nvd, ghsa, redhat sources),FixedVersion(if any),Title,PrimaryURL. - Use
csv.DictWriterfor clean field escaping.
Best Practice
- Always provide a fallback string (e.g., "N/A") for missing fields to avoid runtime
KeyError. - Ensure the CSV is opened with
newline=""to prevent extra lines in some OS environments.