Interview Prep/DevSecOps/Container image and IaC scanning

Trivy and Grype report different CVE counts for the same image

IntermediateTroubleshootingContainer image and IaC scanning
Answer

Likely causes → Different advisory sources (distro feeds vs NVD vs GHSA), different handling of unfixed and disputed CVEs, and different package detection (language binaries, JARs inside JARs).

Diagnose →

trivy image -f json -o t.json myapp:1.4
grype myapp:1.4 -o json > g.json
jq -r '.Results[].Vulnerabilities[]?.VulnerabilityID' t.json | sort -u > t.txt
jq -r '.matches[].vulnerability.id' g.json | sort -u > g.txt
comm -3 t.txt g.txt

Fix → Pick one scanner as the gate of record and use the other for second opinion. Investigate the diff list; most differences are severity source or unfixed handling.

Prevent → Document the scanner, DB source and severity policy so audits and developers see one answer.

All DevSecOps questions

More on Container image and IaC scanning