Skip to content

Commit a43f58e

Browse files
committed
chore: use trivy scan vulnerability and license
1 parent 23ad603 commit a43f58e

3 files changed

Lines changed: 58 additions & 78 deletions

File tree

.github/workflows/dependency-review.yml

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

.github/workflows/trivy-scan.yml

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
name: Trivy Vulnerability + License Scan (PR + Scheduled)
2+
3+
# Trigger conditions: PR/push on main/3.0 branches, daily scheduled scan (00:00 UTC)
4+
on:
5+
workflow_dispatch:
6+
pull_request:
7+
branches: [ main, 3.0 ]
8+
types: [ opened, synchronize, reopened ]
9+
push:
10+
branches: [ main, 3.0 ]
11+
schedule:
12+
- cron: '0 0 * * *' # Daily scan at 00:00 UTC (8:00 Beijing Time)
13+
14+
jobs:
15+
trivy-scan:
16+
runs-on: ubuntu-latest
17+
permissions:
18+
contents: read
19+
security-events: write # Required for uploading SARIF to GitHub Security
20+
21+
steps:
22+
# Step 1: Check out repository code (required for scanning local files/pom.xml)
23+
- name: Checkout code
24+
uses: actions/checkout@v4
25+
26+
# Step 2: Trivy FS Scan - Detect vulnerabilities in code/dependencies
27+
- name: Trivy FS Scan (Code/Dependency Vulnerabilities)
28+
uses: aquasecurity/trivy-action@master
29+
with:
30+
scan-type: 'fs'
31+
scan-ref: '.' # Scan project root directory
32+
format: 'sarif' # Output SARIF for GitHub Security integration
33+
output: 'trivy-fs-results.sarif'
34+
severity: 'CRITICAL,HIGH' # Focus on critical/high severity vulnerabilities
35+
exit-code: '1' # Fail CI if critical/high vulnerabilities are found
36+
ignore-unfixed: true # Ignore vulnerabilities that cannot be fixed
37+
skip-dirs: 'target,node_modules' # Skip Maven build artifacts and node modules
38+
skip-files: 'pom.xml.versionsBackup' # Skip temporary Maven files
39+
40+
# Step 3: Trivy License Scan
41+
- name: Trivy License Scan
42+
uses: aquasecurity/trivy-action@master
43+
with:
44+
scan-type: fs
45+
scan-ref: .
46+
format: table
47+
exit-code: 1 # Fail CI on non-allowed licenses
48+
skip-dirs: target # Skip build artifacts to speed up scan
49+
scanners: license
50+
severity: 'UNKNOWN,HIGH,CRITICAL'
51+
52+
53+
# Step 4: Upload SARIF report to GitHub Security (visualize vulnerabilities)
54+
- name: Upload Trivy Results to GitHub Security
55+
uses: github/codeql-action/upload-sarif@v3
56+
with:
57+
sarif_file: 'trivy-fs-results.sarif'

pom.xml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
<java.version>1.8</java.version>
4040
<maven-compiler-plugin.version>3.6.0</maven-compiler-plugin.version>
4141
<jackson.version>2.20.0</jackson.version>
42-
<httpclient.version>4.5.14</httpclient.version>
42+
<httpclient.version>4.5.12</httpclient.version>
4343
<guava.version>33.5.0-jre</guava.version>
4444
<netty-all.version>4.2.9.Final</netty-all.version>
4545
<junit.version>4.13.2</junit.version>
@@ -105,9 +105,6 @@
105105
<version>${logback.version}</version>
106106
<scope>test</scope>
107107
</dependency>
108-
109-
</dependencies>
110-
111108
<build>
112109
<resources>
113110
<resource>

0 commit comments

Comments
 (0)