1
1
#! /usr/bin/env bats
2
+ export GITHUB_OUTPUT=" /github-output"
2
3
3
4
setup_file () {
4
5
docker build . -t neuvector/scan-action
5
6
}
6
7
7
8
@test " docker daemon not reachable" {
8
- run docker run --rm -e SCANNER_REGISTRY=https://index.docker.io/ -e SCANNER_REPOSITORY=library/debian -e SCANNER_TAG=11.0 neuvector/scan-action
9
+ run docker run --rm -e SCANNER_REGISTRY=https://index.docker.io/ -e SCANNER_REPOSITORY=library/debian -e SCANNER_TAG=11.0 -e GITHUB_OUTPUT= " ${GITHUB_OUTPUT} " -v " /github/output:/tmp " neuvector/scan-action
9
10
echo " Status $status "
10
11
echo " Output"
11
12
echo -e $output
@@ -14,7 +15,7 @@ setup_file() {
14
15
}
15
16
16
17
@test " invalid scanner image" {
17
- run docker run --rm -e NV_SCANNER_IMAGE=invalid-image:latest -e SCANNER_REGISTRY=https://index.docker.io/ -e SCANNER_REPOSITORY=library/debian -e SCANNER_TAG=11.0 -v /var/run/docker.sock:/var/run/docker.sock neuvector/scan-action
18
+ run docker run --rm -e NV_SCANNER_IMAGE=invalid-image:latest -e SCANNER_REGISTRY=https://index.docker.io/ -e SCANNER_REPOSITORY=library/debian -e SCANNER_TAG=11.0 -v /var/run/docker.sock:/var/run/docker.sock -e GITHUB_OUTPUT= " ${GITHUB_OUTPUT} " -v " /github/output:/tmp " neuvector/scan-action
18
19
echo " Status $status "
19
20
echo " Output"
20
21
echo -e $output
@@ -23,7 +24,7 @@ setup_file() {
23
24
}
24
25
25
26
@test " scan image with vulnerabilities but don't fail" {
26
- run docker run --rm -e SCANNER_REGISTRY=https://index.docker.io/ -e SCANNER_REPOSITORY=library/debian -e SCANNER_TAG=11.0 -v /var/run/docker.sock:/var/run/docker.sock neuvector/scan-action
27
+ run docker run --rm -e SCANNER_REGISTRY=https://index.docker.io/ -e SCANNER_REPOSITORY=library/debian -e SCANNER_TAG=11.0 -v /var/run/docker.sock:/var/run/docker.sock -e GITHUB_OUTPUT= " ${GITHUB_OUTPUT} " -v " /github/output:/tmp " neuvector/scan-action
27
28
echo " Status $status "
28
29
echo " Output"
29
30
echo -e $output
@@ -32,7 +33,7 @@ setup_file() {
32
33
}
33
34
34
35
@test " scan image with vulnerabilities and high severity fail" {
35
- run docker run --rm -e HIGH_VUL_TO_FAIL=1 -e SCANNER_REGISTRY=https://index.docker.io/ -e SCANNER_REPOSITORY=library/debian -e SCANNER_TAG=11.0 -v /var/run/docker.sock:/var/run/docker.sock neuvector/scan-action
36
+ run docker run --rm -e HIGH_VUL_TO_FAIL=1 -e SCANNER_REGISTRY=https://index.docker.io/ -e SCANNER_REPOSITORY=library/debian -e SCANNER_TAG=11.0 -v /var/run/docker.sock:/var/run/docker.sock -e GITHUB_OUTPUT= " ${GITHUB_OUTPUT} " -v " /github/output:/tmp " neuvector/scan-action
36
37
echo " Status $status "
37
38
echo " Output"
38
39
echo -e $output
@@ -41,7 +42,7 @@ setup_file() {
41
42
}
42
43
43
44
@test " scan image with vulnerabilities and medium severity fail" {
44
- run docker run --rm -e MEDIUM_VUL_TO_FAIL=1 -e SCANNER_REGISTRY=https://index.docker.io/ -e SCANNER_REPOSITORY=library/debian -e SCANNER_TAG=11.0 -v /var/run/docker.sock:/var/run/docker.sock neuvector/scan-action
45
+ run docker run --rm -e MEDIUM_VUL_TO_FAIL=1 -e SCANNER_REGISTRY=https://index.docker.io/ -e SCANNER_REPOSITORY=library/debian -e SCANNER_TAG=11.0 -v /var/run/docker.sock:/var/run/docker.sock -e GITHUB_OUTPUT= " ${GITHUB_OUTPUT} " -v " /github/output:/tmp " neuvector/scan-action
45
46
echo " Status $status "
46
47
echo " Output"
47
48
echo -e $output
@@ -50,7 +51,7 @@ setup_file() {
50
51
}
51
52
52
53
@test " scan image with vulnerabilities and specific CVE fail" {
53
- run docker run --rm -e VUL_NAMES_TO_FAIL=invalid,CVE-2020-16156 -e SCANNER_REGISTRY=https://index.docker.io/ -e SCANNER_REPOSITORY=library/debian -e SCANNER_TAG=11.0 -v /var/run/docker.sock:/var/run/docker.sock neuvector/scan-action
54
+ run docker run --rm -e VUL_NAMES_TO_FAIL=invalid,CVE-2020-16156 -e SCANNER_REGISTRY=https://index.docker.io/ -e SCANNER_REPOSITORY=library/debian -e SCANNER_TAG=11.0 -v /var/run/docker.sock:/var/run/docker.sock -e GITHUB_OUTPUT= " ${GITHUB_OUTPUT} " -v " /github/output:/tmp " neuvector/scan-action
54
55
echo " Status $status "
55
56
echo " Output"
56
57
echo -e $output
@@ -59,7 +60,7 @@ setup_file() {
59
60
}
60
61
61
62
@test " scan image with json output" {
62
- run docker run --rm -e OUTPUT=json -e SCANNER_REGISTRY=https://index.docker.io/ -e SCANNER_REPOSITORY=library/debian -e SCANNER_TAG=11.0 -v /var/run/docker.sock:/var/run/docker.sock neuvector/scan-action
63
+ run docker run --rm -e OUTPUT=json -e SCANNER_REGISTRY=https://index.docker.io/ -e SCANNER_REPOSITORY=library/debian -e SCANNER_TAG=11.0 -v /var/run/docker.sock:/var/run/docker.sock -e GITHUB_OUTPUT= " ${GITHUB_OUTPUT} " -v " /github/output:/tmp " neuvector/scan-action
63
64
echo " Status $status "
64
65
echo " Output"
65
66
echo -e $output
@@ -68,7 +69,7 @@ setup_file() {
68
69
}
69
70
70
71
@test " scan image with csv output" {
71
- run docker run --rm -e OUTPUT=csv -e SCANNER_REGISTRY=https://index.docker.io/ -e SCANNER_REPOSITORY=library/debian -e SCANNER_TAG=11.0 -v /var/run/docker.sock:/var/run/docker.sock neuvector/scan-action
72
+ run docker run --rm -e OUTPUT=csv -e SCANNER_REGISTRY=https://index.docker.io/ -e SCANNER_REPOSITORY=library/debian -e SCANNER_TAG=11.0 -v /var/run/docker.sock:/var/run/docker.sock -e GITHUB_OUTPUT= " ${GITHUB_OUTPUT} " -v " /github/output:/tmp " neuvector/scan-action
72
73
echo " Status $status "
73
74
echo " Output"
74
75
echo -e $output
0 commit comments