Skip to content

Commit 45d6711

Browse files
committed
ci: add Trivy filesystem security scan workflow
- Run Trivy vulnerability scanner on push, PR, and daily schedule - Record CRITICAL/HIGH/MEDIUM findings as SARIF to GitHub Security tab - Fail the workflow only on CRITICAL or HIGH severity issues
1 parent d577efb commit 45d6711

1 file changed

Lines changed: 49 additions & 0 deletions

File tree

.github/workflows/trivy.yml

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
name: Trivy Security Scan
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- main
7+
push:
8+
branches:
9+
- main
10+
schedule:
11+
- cron: "0 1 * * *" # Run daily at 1:00 AM UTC
12+
13+
jobs:
14+
trivy-scan:
15+
name: Trivy Vulnerability Scan
16+
runs-on: ubuntu-latest
17+
permissions:
18+
contents: read
19+
security-events: write
20+
actions: read
21+
22+
steps:
23+
- name: Checkout code
24+
uses: actions/checkout@v6
25+
26+
- name: Run Trivy vulnerability scanner in fs mode
27+
uses: aquasecurity/trivy-action@0.35.0
28+
with:
29+
scan-type: "fs"
30+
scan-ref: "."
31+
format: "sarif"
32+
output: "trivy-results.sarif"
33+
severity: "CRITICAL,HIGH,MEDIUM"
34+
exit-code: "0" # Don't fail on vulnerabilities, only record them
35+
36+
- name: Upload Trivy results to GitHub Security tab
37+
uses: github/codeql-action/upload-sarif@v4
38+
if: always()
39+
with:
40+
sarif_file: "trivy-results.sarif"
41+
42+
- name: Run Trivy vulnerability scanner in table format
43+
uses: aquasecurity/trivy-action@0.35.0
44+
with:
45+
scan-type: "fs"
46+
scan-ref: "."
47+
format: "table"
48+
severity: "CRITICAL,HIGH"
49+
exit-code: "1" # Fail only if CRITICAL/HIGH vulnerabilities found

0 commit comments

Comments
 (0)