Skip to content

Commit 5526f51

Browse files
sgramsclaude
authored andcommitted
ci: add Trivy security scan workflow
Add GitHub Actions workflow for Trivy scanning with two jobs: - Filesystem vulnerability scan (CRITICAL, HIGH) on Cargo dependencies - Config/IaC misconfiguration scan (CRITICAL, HIGH, MEDIUM) on workflows Results are uploaded as SARIF to GitHub Security tab. External vendored code is excluded via skip-dirs. Runs on push/PR to main and weekly cron. Co-authored-by: Claude Opus 4 (Anthropic) <noreply@anthropic.com> Signed-off-by: Stanislaw Grams <stanislaw.grams@intel.com>
1 parent 2b31823 commit 5526f51

1 file changed

Lines changed: 78 additions & 0 deletions

File tree

.github/workflows/trivy.yml

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
name: Trivy Security Scan
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
branches: [main]
8+
schedule:
9+
# Run weekly to catch newly disclosed vulnerabilities
10+
- cron: "0 6 * * 1"
11+
12+
permissions:
13+
contents: read
14+
15+
jobs:
16+
vulnerability-scan:
17+
name: Vulnerability Scan (fs)
18+
runs-on: ubuntu-latest
19+
permissions:
20+
contents: read
21+
security-events: write
22+
steps:
23+
- name: Checkout repository
24+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
25+
with:
26+
submodules: recursive
27+
28+
- name: Apply patch
29+
shell: bash
30+
run: ./sh_script/pre-build.sh
31+
32+
- name: Run Trivy filesystem scan
33+
uses: aquasecurity/trivy-action@57a97c7e7821a5776cebc9bb87c984fa69cba8f1 # v0.35.0
34+
with:
35+
scan-type: fs
36+
scan-ref: .
37+
format: sarif
38+
output: trivy-fs-results.sarif
39+
severity: CRITICAL,HIGH
40+
# Skip test key material
41+
skip-dirs: test_key
42+
43+
- name: Upload Trivy SARIF to GitHub Security
44+
uses: github/codeql-action/upload-sarif@f443b600d91635bebf5b0d9ebc620189c0d6fba5 # v4.30.8
45+
if: always()
46+
with:
47+
sarif_file: trivy-fs-results.sarif
48+
category: trivy-fs
49+
50+
config-scan:
51+
name: Config & IaC Scan
52+
runs-on: ubuntu-latest
53+
permissions:
54+
contents: read
55+
security-events: write
56+
steps:
57+
- name: Checkout repository
58+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
59+
with:
60+
submodules: recursive
61+
62+
- name: Run Trivy config scan
63+
uses: aquasecurity/trivy-action@57a97c7e7821a5776cebc9bb87c984fa69cba8f1 # v0.35.0
64+
with:
65+
scan-type: config
66+
scan-ref: .
67+
format: sarif
68+
output: trivy-config-results.sarif
69+
severity: CRITICAL,HIGH,MEDIUM
70+
# Skip test key material
71+
skip-dirs: test_key
72+
73+
- name: Upload Trivy config SARIF to GitHub Security
74+
uses: github/codeql-action/upload-sarif@f443b600d91635bebf5b0d9ebc620189c0d6fba5 # v4.30.8
75+
if: always()
76+
with:
77+
sarif_file: trivy-config-results.sarif
78+
category: trivy-config

0 commit comments

Comments
 (0)