Skip to content

Commit e33583a

Browse files
committed
ci: improve Trivy workflow configuration and security reporting
- Rename the workflow to "Trivy Security Scan" - Refactor workflow triggers and schedule configuration for clarity and manual dispatch support - Replace deprecated concurrency settings with updated job structure - Update actions/checkout to v6 - Consolidate Trivy scan jobs and improve scanner configuration - Change SARIF output file name to "trivy-results.sarif" - Add step to upload Trivy results to the GitHub Security tab using the latest CodeQL action - Add a new Trivy scan step with table output for critical and high severity findings Signed-off-by: Bo-Yi Wu <[email protected]>
1 parent ad9f32f commit e33583a

File tree

1 file changed

+32
-24
lines changed

1 file changed

+32
-24
lines changed

.github/workflows/security.yml

Lines changed: 32 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,50 @@
1-
name: Security Scanning
1+
name: Trivy Security Scan
22

33
on:
4-
schedule:
5-
# Run daily at midnight UTC
6-
- cron: "0 0 * * *"
74
push:
8-
branches:
9-
- main
5+
branches: [main]
106
pull_request:
11-
12-
permissions:
13-
contents: read
14-
security-events: write
15-
16-
concurrency:
17-
group: ${{ github.workflow }}-${{ github.ref }}
18-
cancel-in-progress: true
7+
branches: [main]
8+
schedule:
9+
- cron: "0 0 * * *" # Daily scan at midnight UTC
10+
workflow_dispatch: # Allow manual trigger
1911

2012
jobs:
21-
trivy-source:
22-
name: Trivy Source Code Scan
13+
trivy-scan:
14+
name: Trivy Security Scan
2315
runs-on: ubuntu-latest
16+
permissions:
17+
contents: read
18+
security-events: write
19+
actions: read
20+
2421
steps:
2522
- name: Checkout repository
26-
uses: actions/checkout@v5
27-
with:
28-
fetch-depth: 0
23+
uses: actions/checkout@v6
2924

3025
- name: Run Trivy vulnerability scanner in repo mode
3126
uses: aquasecurity/[email protected]
3227
with:
3328
scan-type: "fs"
34-
ignore-unfixed: true
29+
scan-ref: "."
3530
format: "sarif"
36-
output: "trivy-source-results.sarif"
31+
output: "trivy-results.sarif"
3732
severity: "CRITICAL,HIGH,MEDIUM"
33+
scanners: "vuln,secret,misconfig"
3834

39-
- name: Upload Trivy scan results to GitHub Security tab
40-
uses: github/codeql-action/upload-sarif@v3
35+
- name: Upload Trivy results to GitHub Security tab
36+
uses: github/codeql-action/upload-sarif@v4
37+
if: always()
4138
with:
42-
sarif_file: "trivy-source-results.sarif"
39+
sarif_file: "trivy-results.sarif"
40+
41+
- name: Run Trivy vulnerability scanner (table output)
42+
uses: aquasecurity/[email protected]
43+
if: always()
44+
with:
45+
scan-type: "fs"
46+
scan-ref: "."
47+
format: "table"
48+
severity: "CRITICAL,HIGH"
49+
scanners: "vuln,secret,misconfig"
50+
exit-code: "1"

0 commit comments

Comments
 (0)