Skip to content

Commit 66da86f

Browse files
authored
Merge pull request trustyai-explainability#7 from ruivieira/trivy
feat: Add GitHub Actions workflow for Trivy security scanning
2 parents b9155a8 + 87744f1 commit 66da86f

File tree

1 file changed

+56
-0
lines changed

1 file changed

+56
-0
lines changed

.github/workflows/security.yml

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
name: Security Scan
2+
3+
on:
4+
pull_request:
5+
branches: [main]
6+
push:
7+
branches: [main]
8+
9+
jobs:
10+
trivy-scan:
11+
name: Trivy Security Scan
12+
runs-on: ubuntu-latest
13+
permissions:
14+
contents: read
15+
security-events: write
16+
actions: read
17+
18+
steps:
19+
- name: Checkout code
20+
uses: actions/checkout@v4
21+
22+
- name: Set up Python
23+
uses: actions/setup-python@v4
24+
with:
25+
python-version: '3.12'
26+
27+
- name: Install dependencies
28+
run: |
29+
python -m pip install --upgrade pip
30+
python -m pip install -e ".[dev]"
31+
32+
- name: Run Trivy vulnerability scan
33+
uses: aquasecurity/trivy-action@0.28.0
34+
with:
35+
scan-type: 'fs'
36+
scan-ref: '.'
37+
format: 'sarif'
38+
output: 'trivy-results.sarif'
39+
severity: 'CRITICAL,HIGH,MEDIUM,LOW'
40+
exit-code: '0'
41+
42+
- name: Check for critical and high vulnerabilities
43+
uses: aquasecurity/trivy-action@0.28.0
44+
with:
45+
scan-type: 'fs'
46+
scan-ref: '.'
47+
format: 'table'
48+
severity: 'CRITICAL,HIGH'
49+
exit-code: '1'
50+
51+
- name: Upload Trivy scan results to GitHub Security tab
52+
uses: github/codeql-action/upload-sarif@v3
53+
if: always()
54+
with:
55+
sarif_file: 'trivy-results.sarif'
56+
category: 'trivy-security-scan'

0 commit comments

Comments
 (0)