File tree Expand file tree Collapse file tree 5 files changed +103
-0
lines changed
Expand file tree Collapse file tree 5 files changed +103
-0
lines changed Original file line number Diff line number Diff line change 1+ name : Trivy Plugin Test
2+
3+ permissions :
4+ contents : write
5+
6+ on :
7+ push :
8+ paths :
9+ - ' plugins/tools/trivy/**'
10+
11+
12+ jobs :
13+ test :
14+ runs-on : ubuntu-latest
15+ steps :
16+ - name : Checkout code
17+ uses : actions/checkout@v4
18+
19+ - name : Set up Go
20+ uses : actions/setup-go@v5
21+ with :
22+ go-version : ' 1.21'
23+ cache : true
24+
25+ - name : Build CLI
26+ run : |
27+ go build -o cli-v2 ./cli-v2.go
28+ chmod +x cli-v2
29+
30+ - name : Run Trivy plugin tests
31+ run : |
32+ # Store the path to the CLI
33+ CLI_PATH="$(pwd)/cli-v2"
34+ # Change to test directory
35+ cd plugins/tools/trivy/test
36+ # Install the plugin
37+ "$CLI_PATH" install
38+ # Run analysis
39+ "$CLI_PATH" analyze --tool trivy --format sarif --output actual.sarif
40+ # Convert absolute paths to relative paths in the output
41+ sed -i 's|file:///home/runner/work/codacy-cli-v2/codacy-cli-v2/|file:///|g' actual.sarif
42+ # Compare with expected output
43+ diff expected.sarif actual.sarif
44+ # Clean up
45+ rm actual.sarif
Original file line number Diff line number Diff line change 1+ runtimes :
2+ tools :
3+ - trivy@0.59.1
Original file line number Diff line number Diff line change 1+ {
2+ "version" : " 2.1.0" ,
3+ "$schema" : " https://raw.githubusercontent.com/oasis-tcs/sarif-spec/master/Schemata/sarif-schema-2.1.0.json" ,
4+ "runs" : [
5+ {
6+ "tool" : {
7+ "driver" : {
8+ "fullName" : " Trivy Vulnerability Scanner" ,
9+ "informationUri" : " https://github.com/aquasecurity/trivy" ,
10+ "name" : " Trivy" ,
11+ "rules" : [],
12+ "version" : " 0.59.1"
13+ }
14+ },
15+ "results" : [],
16+ "columnKind" : " utf16CodeUnits" ,
17+ "originalUriBaseIds" : {
18+ "ROOTPATH" : {
19+ "uri" : " file:///plugins/tools/trivy/test/"
20+ }
21+ }
22+ }
23+ ]
24+ }
Original file line number Diff line number Diff line change 1+ FROM node:12.0.0
2+
3+ # Using an old version of npm that has known vulnerabilities
4+ RUN npm install -g npm@6.14.4
5+
6+ # Copy application files
7+ WORKDIR /app
8+ COPY package*.json ./
9+
10+ # Install dependencies with known vulnerabilities
11+ RUN npm install express@4.16.4
12+
13+ # Copy source code
14+ COPY . .
15+
16+ # Expose port
17+ EXPOSE 3000
18+
19+ # Start the application
20+ CMD ["node" , "app.js" ]
Original file line number Diff line number Diff line change 1+ {
2+ "name" : " trivy-test-app" ,
3+ "version" : " 1.0.0" ,
4+ "description" : " Test application for Trivy vulnerability scanning" ,
5+ "main" : " app.js" ,
6+ "dependencies" : {
7+ "express" : " 4.16.4" ,
8+ "lodash" : " 4.17.15" ,
9+ "moment" : " 2.24.0"
10+ }
11+ }
You can’t perform that action at this time.
0 commit comments