| name | trivy |
| description | This skill should be used when scanning container images, filesystems, or repositories for vulnerabilities using Trivy. Use for CVE detection, security analysis, vulnerability comparison across image versions, understanding scan output (severity levels, status fields), and batch scanning multiple images. |
Trivy Vulnerability Scanner
Core Commands
Node.js / Filesystem Scanning
trivy fs --scanners vuln .
trivy fs --scanners vuln --include-dev-deps .
trivy fs --scanners vuln package-lock.json
trivy fs --scanners vuln --format json -o results.json .
trivy fs --scanners vuln --severity HIGH,CRITICAL .
trivy repo --scanners vuln https://github.com/org/repo
Supported Node.js files:
package.json + package-lock.json (npm)
yarn.lock (Yarn)
pnpm-lock.yaml (pnpm)
Basic Image Scanning
trivy image --severity HIGH,CRITICAL <image:tag>
trivy image <image:tag>
trivy image --format json --output results.json <image:tag>
Common Patterns
trivy image --severity HIGH,CRITICAL image:18.3.2 > v1.txt
trivy image --severity HIGH,CRITICAL image:18.4.0 > v2.txt
diff v1.txt v2.txt
scripts/batch_scan.sh alpine:latest nginx:latest postgres:16
scripts/compare_versions.sh public.ecr.aws/org/image 18.3.2 18.4.0 18.5.0
Output Formats
trivy image --format table <image:tag>
trivy image --format json <image:tag>
trivy image --format sarif <image:tag>
Scanner Types
Use --scanners to control what Trivy scans:
trivy image --scanners vuln <image:tag>
trivy image --scanners vuln,secret <image:tag>
trivy image <image:tag>
Default: All scanners enabled. Use --scanners vuln to disable secret scanning for faster scans.
Performance Options
trivy image --skip-db-update <image:tag>
trivy image --skip-version-check <image:tag>
trivy image --scanners vuln <image:tag>
Understanding Output
For detailed interpretation of Trivy output including status fields, severity levels, and false positives, see output_interpretation.md.
Quick reference:
- Status
fixed: Patch available (check Fixed Version column)
- Status
affected: No fix available yet
- Status
will_not_fix: Vendor won't patch
- False positives: Status shows
fixed but CVE still appears (common with Go binaries)
Common Use Cases
Compare Vulnerabilities Across Versions
Use the provided script:
scripts/compare_versions.sh public.ecr.aws/org/image 14.4.1 15.5.4 16.5.9 17.7.10 18.0.0
Or manually:
for version in 14.4.1 15.5.4 16.5.9; do
trivy image --severity HIGH,CRITICAL image:$version > scan-$version.txt
done
Track Specific CVEs
trivy image <image:tag> | grep CVE-2025-6020
trivy image --format json <image:tag> | \
jq '.Results[].Vulnerabilities[] | select(.VulnerabilityID == "CVE-2025-6020")'
CI/CD Integration
trivy image --exit-code 1 --severity HIGH,CRITICAL <image:tag>
trivy image --format sarif --output trivy-results.sarif <image:tag>
Batch Scanning
For scanning multiple images efficiently:
scripts/batch_scan.sh image1:tag1 image2:tag2 image3:tag3
TRIVY_MAX_PARALLEL=10 scripts/batch_scan.sh image1 image2 image3
TRIVY_OUTPUT_DIR=./scans scripts/batch_scan.sh image1 image2
Filtering and Ignoring
trivy image --ignore-unfixed <image:tag>
cat > .trivyignore <<EOF
CVE-2022-36633
CVE-2023-12345
EOF
trivy image <image:tag>
Best Practices
- Always filter by severity for focused analysis:
--severity HIGH,CRITICAL
- Use JSON for automation to enable scripting and parsing
- Disable secret scanning when not needed:
--scanners vuln
- Skip DB updates in CI/CD after initial download:
--skip-db-update
- Verify "fixed" status - Check if installed version >= fixed version (false positives common)
- Use provided scripts for comparing versions or batch scanning
- Document ignored CVEs in .trivyignore with comments explaining why
Troubleshooting
Slow scans:
trivy image --scanners vuln --skip-db-update <image:tag>
Too many false positives:
trivy image --ignore-unfixed <image:tag>
Database update failures:
trivy image --download-db-only
References