forked from jobtome-labs/ci-templates
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test-docker-security.yml
59 lines (49 loc) · 1.66 KB
/
test-docker-security.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
test:docker-security:
stage: test
image:
name: aquasec/trivy:0.5.2
entrypoint: [""]
variables:
GIT_STRATEGY: none
TRIVY_USERNAME: ${CI_REGISTRY_USER}
TRIVY_PASSWORD: ${CI_REGISTRY_PASSWORD}
script:
- |
# RUN SECURITY CHECKS
if [ -z "${IMAGES}" ]; then
# Build report
trivy --exit-code 0 --no-progress --format template --template "/contrib/gitlab.tpl" -o gl-container-scanning-report.json "${CI_REGISTRY_IMAGE}:${CI_COMMIT_SHORT_SHA}"
echo
echo
echo
# Print report
trivy --exit-code 0 --no-progress --severity HIGH "${CI_REGISTRY_IMAGE}:${CI_COMMIT_SHORT_SHA}"
echo
echo
echo
# Fail on high and critical vulnerabilities
trivy --exit-code 1 --severity CRITICAL --no-progress "${CI_REGISTRY_IMAGE}:${CI_COMMIT_SHORT_SHA}"
else
for image in ${IMAGES}; do
# Build report
trivy --exit-code 0 --no-progress --format template --template "/contrib/gitlab.tpl" -o gl-container-scanning-report.json "${CI_REGISTRY_IMAGE}/${image}:${CI_COMMIT_SHORT_SHA}"
echo
echo
echo
# Print report
trivy --exit-code 0 --no-progress --severity HIGH "${CI_REGISTRY_IMAGE}/${image}:${CI_COMMIT_SHORT_SHA}"
echo
echo
echo
# Fail on high and critical vulnerabilities
trivy --exit-code 1 --severity CRITICAL --no-progress "${CI_REGISTRY_IMAGE}/${image}:${CI_COMMIT_SHORT_SHA}"
done
fi
only:
- /^v.+$/i
- master
- merge_requests
except:
variables:
- $SKIP_CI_TEST == "true"
- $CI_FAST_TRACK == "true"