Skip to content

Commit b404926

Browse files
samuelho-devclaude
andcommitted
fix: proper Trivy SARIF upload control
- Add upload-sarif input parameter (default: false) - Always run Trivy with table format for visible output in logs - Only generate SARIF and upload when upload-sarif: true - Removes need for continue-on-error workaround - Repos without GitHub Advanced Security can still see scan results 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 5de45aa commit b404926

1 file changed

Lines changed: 17 additions & 3 deletions

File tree

.github/workflows/docker-build-push.yml

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,11 @@ on:
6262
required: false
6363
type: string
6464
default: 'HIGH,CRITICAL'
65+
upload-sarif:
66+
description: 'Upload SARIF to GitHub Security (requires Code Scanning enabled)'
67+
required: false
68+
type: boolean
69+
default: false
6570
secrets:
6671
registry-username:
6772
description: 'Registry username'
@@ -160,9 +165,19 @@ jobs:
160165
provenance: true
161166
sbom: false
162167

163-
- name: Run Trivy vulnerability scanner
168+
- name: Run Trivy vulnerability scanner (table output)
164169
if: inputs.scan
165170
uses: aquasecurity/trivy-action@b6643a29fecd7f34b3597bc6acb0a98b03d33ff8 # v0.33.1
171+
with:
172+
image-ref: ${{ inputs.registry }}/${{ github.repository_owner }}/${{ inputs.image }}@${{ steps.build.outputs.digest }}
173+
format: 'table'
174+
severity: ${{ inputs.severity }}
175+
timeout: '10m'
176+
exit-code: '0' # Don't fail on vulnerabilities, just report
177+
178+
- name: Run Trivy vulnerability scanner (SARIF output)
179+
if: inputs.scan && inputs.upload-sarif
180+
uses: aquasecurity/trivy-action@b6643a29fecd7f34b3597bc6acb0a98b03d33ff8 # v0.33.1
166181
with:
167182
image-ref: ${{ inputs.registry }}/${{ github.repository_owner }}/${{ inputs.image }}@${{ steps.build.outputs.digest }}
168183
format: 'sarif'
@@ -171,8 +186,7 @@ jobs:
171186
timeout: '10m'
172187

173188
- name: Upload Trivy scan results to GitHub Security
174-
if: inputs.scan
175-
continue-on-error: true # Don't fail build if upload fails (permissions issue)
189+
if: inputs.scan && inputs.upload-sarif
176190
uses: github/codeql-action/upload-sarif@48ab28a6f5dbc2a99bf1e0131198dd8f1df78169 # v3.28.0
177191
with:
178192
sarif_file: 'trivy-results.sarif'

0 commit comments

Comments
 (0)