4545 path : ' ${{ github.workspace }}/trivy-results.json'
4646 retention-days : 20
4747
48- # Parse results to set has_vulnerabilities (for workflow control)
48+ # Parse results and create advisory if needed
4949 - if : inputs.skip_scan != true
5050 id : parse
51+ env :
52+ GH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
5153 shell : bash
5254 run : |
5355 if [ -f trivy-results.json ]; then
@@ -58,15 +60,21 @@ jobs:
5860
5961 if [ "${VULN_COUNT:-0}" -gt 0 ]; then
6062 echo "has_vulnerabilities=true" >> "$GITHUB_OUTPUT"
63+ CURRENT_DATE=$(date +%Y-%m-%d)
6164
65+ # Create step summary and advisory content
6266 echo "# Security Findings Found" >> $GITHUB_STEP_SUMMARY
6367
68+ SUMMARY="## Security Scan Results ($CURRENT_DATE)\n\n### Summary\n- Total Findings: ${VULN_COUNT}"
69+
6470 # Handle OS/Package Vulnerabilities
6571 if jq -e '.Results[] | select(.Vulnerabilities != null)' trivy-results.json > /dev/null; then
6672 echo "## Package Vulnerabilities" >> $GITHUB_STEP_SUMMARY
6773 echo "| Severity | Package | Installed Version | Fixed Version | Vulnerability ID |" >> $GITHUB_STEP_SUMMARY
6874 echo "|----------|---------|-------------------|---------------|-----------------|" >> $GITHUB_STEP_SUMMARY
6975 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)
7078 fi
7179
7280 # Handle Secrets
7583 echo "| Severity | Category | Title | Target | Rule ID |" >> $GITHUB_STEP_SUMMARY
7684 echo "|----------|-----------|--------|---------|----------|" >> $GITHUB_STEP_SUMMARY
7785 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)
7888 fi
7989
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+
80100 echo "::notice::Found ${VULN_COUNT} security findings that need to be addressed."
81101 else
82102 echo "has_vulnerabilities=false" >> "$GITHUB_OUTPUT"
@@ -107,27 +127,4 @@ jobs:
107127 with :
108128 release_type : ' security'
109129 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