Skip to content

Commit 8d673aa

Browse files
committed
ci: refactor Trivy workflow and enhance security scan reporting
- Add a GitHub Actions workflow to run scheduled and triggered Trivy security scans, upload results to the Security tab, and provide logs in table format - Remove the previous Trivy workflow and replace it with a more comprehensive configuration targeting only the master branch and including SARIF uploads Signed-off-by: appleboy <[email protected]>
1 parent f8c29dc commit 8d673aa

File tree

2 files changed

+56
-25
lines changed

2 files changed

+56
-25
lines changed

.github/workflows/trivy-scan.yml

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
name: Trivy Security Scan
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
pull_request:
8+
branches:
9+
- master
10+
schedule:
11+
# Run daily at 00:00 UTC
12+
- cron: '0 0 * * *'
13+
workflow_dispatch: # Allow manual trigger
14+
15+
permissions:
16+
contents: read
17+
security-events: write # Required for uploading SARIF results
18+
19+
jobs:
20+
trivy-scan:
21+
name: Trivy Security Scan
22+
runs-on: ubuntu-latest
23+
steps:
24+
- name: Checkout code
25+
uses: actions/checkout@v6
26+
with:
27+
fetch-depth: 0
28+
29+
- name: Run Trivy vulnerability scanner (source code)
30+
uses: aquasecurity/[email protected]
31+
with:
32+
scan-type: 'fs'
33+
scan-ref: '.'
34+
scanners: 'vuln,secret,misconfig'
35+
format: 'sarif'
36+
output: 'trivy-results.sarif'
37+
severity: 'CRITICAL,HIGH,MEDIUM'
38+
ignore-unfixed: true
39+
40+
- name: Upload Trivy results to GitHub Security tab
41+
uses: github/codeql-action/upload-sarif@v4
42+
if: always()
43+
with:
44+
sarif_file: 'trivy-results.sarif'
45+
46+
- name: Run Trivy scanner (table output for logs)
47+
uses: aquasecurity/[email protected]
48+
if: always()
49+
with:
50+
scan-type: 'fs'
51+
scan-ref: '.'
52+
scanners: 'vuln,secret,misconfig'
53+
format: 'table'
54+
severity: 'CRITICAL,HIGH,MEDIUM'
55+
ignore-unfixed: true
56+
exit-code: '1'

.github/workflows/trivy.yml

Lines changed: 0 additions & 25 deletions
This file was deleted.

0 commit comments

Comments
 (0)