45
45
path : ' ${{ github.workspace }}/trivy-results.json'
46
46
retention-days : 20
47
47
48
- # Parse results to set has_vulnerabilities (for workflow control)
48
+ # Parse results and create advisory if needed
49
49
- if : inputs.skip_scan != true
50
50
id : parse
51
+ env :
52
+ GH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
51
53
shell : bash
52
54
run : |
53
55
if [ -f trivy-results.json ]; then
@@ -58,15 +60,21 @@ jobs:
58
60
59
61
if [ "${VULN_COUNT:-0}" -gt 0 ]; then
60
62
echo "has_vulnerabilities=true" >> "$GITHUB_OUTPUT"
63
+ CURRENT_DATE=$(date +%Y-%m-%d)
61
64
65
+ # Create step summary and advisory content
62
66
echo "# Security Findings Found" >> $GITHUB_STEP_SUMMARY
63
67
68
+ SUMMARY="## Security Scan Results ($CURRENT_DATE)\n\n### Summary\n- Total Findings: ${VULN_COUNT}"
69
+
64
70
# Handle OS/Package Vulnerabilities
65
71
if jq -e '.Results[] | select(.Vulnerabilities != null)' trivy-results.json > /dev/null; then
66
72
echo "## Package Vulnerabilities" >> $GITHUB_STEP_SUMMARY
67
73
echo "| Severity | Package | Installed Version | Fixed Version | Vulnerability ID |" >> $GITHUB_STEP_SUMMARY
68
74
echo "|----------|---------|-------------------|---------------|-----------------|" >> $GITHUB_STEP_SUMMARY
69
75
jq -r '.Results[] | select(.Vulnerabilities != null) | .Vulnerabilities[] | "| \(.Severity) | \(.PkgName) | \(.InstalledVersion) | \(.FixedVersion) | \(.VulnerabilityID) |"' trivy-results.json >> $GITHUB_STEP_SUMMARY
76
+
77
+ VULNS_SECTION=$(jq -r '.Results[] | select(.Vulnerabilities != null) | .Vulnerabilities[] | "### Vulnerability: \(.VulnerabilityID)\n- Package: \(.PkgName)\n- Severity: \(.Severity)\n- Current Version: \(.InstalledVersion)\n- Fixed Version: \(.FixedVersion)\n"' trivy-results.json)
70
78
fi
71
79
72
80
# Handle Secrets
75
83
echo "| Severity | Category | Title | Target | Rule ID |" >> $GITHUB_STEP_SUMMARY
76
84
echo "|----------|-----------|--------|---------|----------|" >> $GITHUB_STEP_SUMMARY
77
85
jq -r '.Results[] | select(.Secrets != null) | .Secrets[] | "| \(.Severity) | \(.Category) | \(.Title) | \(.Target) | \(.RuleID) |"' trivy-results.json >> $GITHUB_STEP_SUMMARY
86
+
87
+ SECRETS_SECTION=$(jq -r '.Results[] | select(.Secrets != null) | .Secrets[] | "### Secret Finding: \(.Title)\n- Severity: \(.Severity)\n- Category: \(.Category)\n- Location: \(.Target)\n- Rule ID: \(.RuleID)\n"' trivy-results.json)
78
88
fi
79
89
90
+ # Create the security advisory
91
+ FULL_DESCRIPTION="${SUMMARY}\n\n${SECRETS_SECTION}\n${VULNS_SECTION}"
92
+
93
+ gh api \
94
+ --method POST \
95
+ /repos/${{ github.repository }}/security-advisories \
96
+ -f summary="🚨 Security Scan Report ($CURRENT_DATE): Found ${VULN_COUNT} findings" \
97
+ -f description="${FULL_DESCRIPTION}" \
98
+ -f severity="critical"
99
+
80
100
echo "::notice::Found ${VULN_COUNT} security findings that need to be addressed."
81
101
else
82
102
echo "has_vulnerabilities=false" >> "$GITHUB_OUTPUT"
@@ -107,27 +127,4 @@ jobs:
107
127
with :
108
128
release_type : ' security'
109
129
ref_type : ' tag'
110
- version : " ${{ needs.get-latest-release.outputs.release_version }}"
111
-
112
- notify :
113
- needs : [build-security-updates]
114
- runs-on : ubuntu-24.04
115
- if : always()
116
- steps :
117
- - name : Notify maintainers privately
118
- if : needs.build-security-updates.result == 'success'
119
- uses : actions/github-script@v7
120
- with :
121
- script : |
122
- await github.rest.securityAdvisories.createPrivateVulnerabilityReport({
123
- owner: context.repo.owner,
124
- repo: context.repo.name,
125
- title: 'Automated Security Updates Applied',
126
- description: `Security updates were automatically applied.\n\nAction Run: ${context.serverUrl}/${context.repo.owner}/${context.repo.name}/actions/runs/${context.runId}`,
127
- state: 'closed',
128
- severity: 'low',
129
- identifiers: [{
130
- type: 'GHSA',
131
- value: `GHSA-auto-${context.runId}`
132
- }]
133
- });
130
+ version : " ${{ needs.get-latest-release.outputs.release_version }}"
0 commit comments