@@ -49,21 +49,34 @@ jobs:
49
49
shell : bash
50
50
run : |
51
51
if [ -f trivy-results.json ]; then
52
- VULN_COUNT=$(jq -r '.vulnerabilities | length // 0' trivy-results.json)
52
+ # Count both vulnerabilities and secrets
53
+ VULN_COUNT=$(jq -r '[.Results[] | (.Vulnerabilities, .Secrets) | select(. != null) | length] | add // 0' trivy-results.json)
54
+
53
55
if [ "${VULN_COUNT:-0}" -gt 0 ]; then
54
56
echo "has_vulnerabilities=true" >> "$GITHUB_OUTPUT"
55
57
56
- # Create native GitHub annotations for vulnerabilities
57
- echo "# Security Vulnerabilities Found" >> $GITHUB_STEP_SUMMARY
58
- echo "| Severity | Package | Installed Version | Vulnerability ID | Description |" >> $GITHUB_STEP_SUMMARY
59
- echo "|----------|---------|-------------------|------------------|-------------|" >> $GITHUB_STEP_SUMMARY
58
+ echo "# Security Findings Found" >> $GITHUB_STEP_SUMMARY
60
59
61
- jq -r '.vulnerabilities[] | "| \(.severity) | \(.pkgName) | \(.installedVersion) | \(.vulnerabilityID) | \(.title) |"' trivy-results.json >> $GITHUB_STEP_SUMMARY
60
+ # Handle OS/Package Vulnerabilities
61
+ if jq -e '.Results[] | select(.Vulnerabilities != null)' trivy-results.json > /dev/null; then
62
+ echo "## Package Vulnerabilities" >> $GITHUB_STEP_SUMMARY
63
+ echo "| Severity | Package | Installed Version | Fixed Version | Vulnerability ID |" >> $GITHUB_STEP_SUMMARY
64
+ echo "|----------|---------|-------------------|---------------|-----------------|" >> $GITHUB_STEP_SUMMARY
65
+ jq -r '.Results[] | select(.Vulnerabilities != null) | .Vulnerabilities[] | "| \(.Severity) | \(.PkgName) | \(.InstalledVersion) | \(.FixedVersion) | \(.VulnerabilityID) |"' trivy-results.json >> $GITHUB_STEP_SUMMARY
66
+ fi
62
67
63
- echo "::notice::Found ${VULN_COUNT} security vulnerabilities that need to be addressed."
68
+ # Handle Secrets
69
+ if jq -e '.Results[] | select(.Secrets != null)' trivy-results.json > /dev/null; then
70
+ echo "## Secrets" >> $GITHUB_STEP_SUMMARY
71
+ echo "| Severity | Category | Title | Target | Rule ID |" >> $GITHUB_STEP_SUMMARY
72
+ echo "|----------|-----------|--------|---------|----------|" >> $GITHUB_STEP_SUMMARY
73
+ jq -r '.Results[] | select(.Secrets != null) | .Secrets[] | "| \(.Severity) | \(.Category) | \(.Title) | \(.Target) | \(.RuleID) |"' trivy-results.json >> $GITHUB_STEP_SUMMARY
74
+ fi
75
+
76
+ echo "::notice::Found ${VULN_COUNT} security findings that need to be addressed."
64
77
else
65
78
echo "has_vulnerabilities=false" >> "$GITHUB_OUTPUT"
66
- echo "No vulnerabilities found." >> $GITHUB_STEP_SUMMARY
79
+ echo "No security findings found." >> $GITHUB_STEP_SUMMARY
67
80
fi
68
81
else
69
82
echo "Error: trivy-results.json not found"
0 commit comments