Skip to content

Commit 4b9b6fb

Browse files
authored
chore: update test to version 0.27.1 (#106)
* chore: update test to version 0.27.0 * chore: add test file secret and update to 0.27.1 * fix: support repository with securityCheck secret Co-authored-by: carolina valencia <[email protected]>
1 parent 2b30463 commit 4b9b6fb

File tree

7 files changed

+79
-9
lines changed

7 files changed

+79
-9
lines changed

.github/workflows/build.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name: "build"
22
on: [push, pull_request]
33
env:
4-
TRIVY_VERSION: 0.26.0
4+
TRIVY_VERSION: 0.27.1
55
jobs:
66
build:
77
name: build

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM aquasec/trivy:0.26.0
1+
FROM aquasec/trivy:0.27.1
22
COPY entrypoint.sh /
33
RUN apk --no-cache add bash
44
RUN chmod +x /entrypoint.sh

entrypoint.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,9 @@ fi
101101
if [ $securityChecks ] && [ "$scanType" == "fs" ];then
102102
ARGS="$ARGS --security-checks $securityChecks"
103103
fi
104+
if [ $securityChecks ] && [ "$scanType" == "repo" ];then
105+
ARGS="$ARGS --security-checks $securityChecks"
106+
fi
104107
if [ $severity ];then
105108
ARGS="$ARGS --severity $severity"
106109
fi

test/data/fs-scheck.test

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
{
2+
"SchemaVersion": 2,
3+
"ArtifactName": ".",
4+
"ArtifactType": "filesystem",
5+
"Metadata": {
6+
"ImageConfig": {
7+
"architecture": "",
8+
"created": "0001-01-01T00:00:00Z",
9+
"os": "",
10+
"rootfs": {
11+
"type": "",
12+
"diff_ids": null
13+
},
14+
"config": {}
15+
}
16+
},
17+
"Results": [
18+
{
19+
"Target": "Dockerfile",
20+
"Class": "config",
21+
"Type": "dockerfile",
22+
"MisconfSummary": {
23+
"Successes": 22,
24+
"Failures": 1,
25+
"Exceptions": 0
26+
},
27+
"Misconfigurations": [
28+
{
29+
"Type": "Dockerfile Security Check",
30+
"ID": "DS002",
31+
"Title": "root user",
32+
"Description": "Running containers with 'root' user can lead to a container escape situation. It is a best practice to run containers as non-root users, which can be done by adding a 'USER' statement to the Dockerfile.",
33+
"Message": "Specify at least 1 USER command in Dockerfile with non-root user as argument",
34+
"Namespace": "appshield.dockerfile.DS002",
35+
"Query": "data.appshield.dockerfile.DS002.deny",
36+
"Resolution": "Add 'USER \u003cnon root user name\u003e' line to the Dockerfile",
37+
"Severity": "HIGH",
38+
"PrimaryURL": "https://avd.aquasec.com/appshield/ds002",
39+
"References": [
40+
"https://docs.docker.com/develop/develop-images/dockerfile_best-practices/",
41+
"https://avd.aquasec.com/appshield/ds002"
42+
],
43+
"Status": "FAIL",
44+
"Layer": {},
45+
"IacMetadata": {}
46+
}
47+
]
48+
}
49+
]
50+
}

test/data/image-sarif.test

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -442,7 +442,7 @@
442442
}
443443
}
444444
],
445-
"version": "0.26.0"
445+
"version": "0.27.1"
446446
}
447447
},
448448
"results": [

test/data/repo.test

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"SchemaVersion": 2,
3-
"ArtifactName": "https://github.com/aquasecurity/trivy-action/",
3+
"ArtifactName": "https://github.com/krol3/demo-trivy/",
44
"ArtifactType": "repository",
55
"Metadata": {
66
"ImageConfig": {
@@ -13,5 +13,22 @@
1313
},
1414
"config": {}
1515
}
16-
}
16+
},
17+
"Results": [
18+
{
19+
"Target": "env",
20+
"Class": "secret",
21+
"Secrets": [
22+
{
23+
"RuleID": "github-pat",
24+
"Category": "GitHub",
25+
"Severity": "CRITICAL",
26+
"Title": "GitHub Personal Access Token",
27+
"StartLine": 5,
28+
"EndLine": 5,
29+
"Match": "export GITHUB_PAT=*****"
30+
}
31+
]
32+
}
33+
]
1734
}

test/test.bats

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,14 +37,14 @@
3737

3838
@test "trivy fs with securityChecks option" {
3939
# trivy fs -f json --security-checks=vuln,config -o fs.test .
40-
./entrypoint.sh '-a fs' '-j .' '-b json' '-s vuln,config' '-h fs-scheck.test'
40+
./entrypoint.sh '-a fs' '-j .' '-b json' '-s vuln,config,secret' '-h fs-scheck.test'
4141
result="$(diff ./test/data/fs.test fs.test)"
4242
[ "$result" == '' ]
4343
}
4444

45-
@test "trivy repo" {
46-
# trivy repo -f json -o repo.test --severity CRITICAL https://github.com/aquasecurity/trivy-action/
47-
./entrypoint.sh '-b json' '-h repo.test' '-g CRITICAL' '-a repo' '-j https://github.com/aquasecurity/trivy-action/'
45+
@test "trivy repo with securityCheck secret only" {
46+
# trivy repo -f json -o repo.test --security-checks=secret https://github.com/krol3/demo-trivy/
47+
./entrypoint.sh '-b json' '-h repo.test' '-s secret' '-a repo' '-j https://github.com/krol3/demo-trivy/'
4848
result="$(diff ./test/data/repo.test repo.test)"
4949
[ "$result" == '' ]
5050
}

0 commit comments

Comments
 (0)