Skip to content

Commit 1614cc7

Browse files
Fix Trivy security scanning workflow failures (#3)
- Pin trivy-action to v0.33.0 instead of @master for stability - Add exit-code: '0' to prevent failures when vulnerabilities are found - Add limit-severities-for-sarif: true to improve SARIF file quality - Fix SARIF upload conditions to check file exists before uploading - Add category labels to distinguish filesystem vs container scans - Fix container image reference to use metadata output version Co-authored-by: Claude <noreply@anthropic.com>
1 parent ecd1b81 commit 1614cc7

1 file changed

Lines changed: 12 additions & 6 deletions

File tree

.github/workflows/ci-cd.yml

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -67,19 +67,22 @@ jobs:
6767
GITLEAKS_LICENSE: ${{ secrets.GITLEAKS_LICENSE }}
6868

6969
- name: Run Trivy vulnerability scanner (filesystem)
70-
uses: aquasecurity/trivy-action@master
70+
uses: aquasecurity/trivy-action@0.33.0
7171
with:
7272
scan-type: 'fs'
7373
scan-ref: '.'
7474
format: 'sarif'
7575
output: 'trivy-results.sarif'
7676
severity: 'CRITICAL,HIGH'
77+
exit-code: '0'
78+
limit-severities-for-sarif: true
7779

7880
- name: Upload Trivy results to GitHub Security
7981
uses: github/codeql-action/upload-sarif@v3
80-
if: always()
82+
if: always() && hashFiles('trivy-results.sarif') != ''
8183
with:
8284
sarif_file: 'trivy-results.sarif'
85+
category: 'trivy-filesystem'
8386

8487
- name: Run Snyk security scan
8588
uses: snyk/actions/node@master
@@ -238,18 +241,21 @@ jobs:
238241
cache-to: type=gha,mode=max
239242

240243
- name: Run Trivy vulnerability scanner (image)
241-
uses: aquasecurity/trivy-action@master
244+
uses: aquasecurity/trivy-action@0.33.0
242245
with:
243-
image-ref: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ github.sha }}
246+
image-ref: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ steps.meta.outputs.version }}
244247
format: 'sarif'
245248
output: 'trivy-image-results.sarif'
246249
severity: 'CRITICAL,HIGH'
250+
exit-code: '0'
251+
limit-severities-for-sarif: true
247252

248253
- name: Upload Trivy image results
249254
uses: github/codeql-action/upload-sarif@v3
250-
if: always()
255+
if: always() && hashFiles('trivy-image-results.sarif') != ''
251256
with:
252257
sarif_file: 'trivy-image-results.sarif'
258+
category: 'trivy-container'
253259

254260
- name: Run Hadolint (Dockerfile linting)
255261
uses: hadolint/hadolint-action@v3.1.0
@@ -260,7 +266,7 @@ jobs:
260266
- name: Scan with Grype
261267
uses: anchore/scan-action@v3
262268
with:
263-
image: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ github.sha }}
269+
image: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ steps.meta.outputs.version }}
264270
fail-build: false
265271
severity-cutoff: high
266272

0 commit comments

Comments
 (0)