Skip to content

Commit 0acf3b2

Browse files
sxdmnencia
andauthored
chore: add trivy scanner for CI and code (#10077)
Add Trivy vulnerability scanner as a standalone workflow for filesystem scanning with SARIF upload to the GitHub Security tab, and as an image scanner in the CI pipeline with table output in build logs. Closes #10075 Signed-off-by: Jonathan Gonzalez V. <[email protected]> Signed-off-by: Marco Nenciarini <[email protected]> Co-authored-by: Marco Nenciarini <[email protected]>
1 parent 48e370c commit 0acf3b2

2 files changed

Lines changed: 43 additions & 0 deletions

File tree

‎.github/workflows/continuous-integration.yml‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -616,6 +616,16 @@ jobs:
616616
image: ${{ env.CONTROLLER_IMG }}
617617
args: --severity-threshold=high --file=Dockerfile --username=${{ env.REGISTRY_USER }} --password=${{ env.REGISTRY_PASSWORD }}
618618

619+
- name: Run Trivy to check Docker image for vulnerabilities
620+
uses: aquasecurity/trivy-action@b6643a29fecd7f34b3597bc6acb0a98b03d33ff8 # 0.33.1
621+
if: env.PUSH == 'true'
622+
id: trivy
623+
continue-on-error: true
624+
with:
625+
version: 'latest'
626+
image-ref: ${{ env.CONTROLLER_IMG }}
627+
format: 'table'
628+
619629
- name: Install cosign
620630
if: |
621631
env.SIGN_IMAGES == 'true' &&

‎.github/workflows/trivy.yml‎

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
name: Trivy Scanning
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
workflow_dispatch:
8+
9+
permissions: read-all
10+
11+
jobs:
12+
trivy-scan:
13+
runs-on: ubuntu-24.04
14+
permissions:
15+
security-events: write
16+
17+
steps:
18+
- name: Checkout code
19+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
20+
21+
- name: Run Trivy vulnerability scanner in fs mode
22+
uses: aquasecurity/trivy-action@b6643a29fecd7f34b3597bc6acb0a98b03d33ff8 # 0.33.1
23+
with:
24+
scan-type: 'fs'
25+
ignore-unfixed: true
26+
format: 'sarif'
27+
output: 'trivy-results-fs.sarif'
28+
severity: 'CRITICAL'
29+
30+
- name: Upload Trivy scan results to GitHub Security tab
31+
uses: github/codeql-action/upload-sarif@89a39a4e59826350b863aa6b6252a07ad50cf83e # v4
32+
with:
33+
sarif_file: 'trivy-results-fs.sarif'

0 commit comments

Comments
 (0)