File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -15,6 +15,7 @@ before_script:
1515 - mv 'shellcheck-v0.6.0/shellcheck' "$HOME/bin/shellcheck"
1616 - chmod +x "$HOME/bin/shellcheck"
1717 - cp -f scripts/dive "$HOME/bin/dive"
18+ - cp -f scripts/trivy "$HOME/bin/dive"
1819 - rvm install "$(cat .ruby-version)"
1920 - export PATH=$HOME/.local/bin:/usr/sbin:$PATH
2021script :
Original file line number Diff line number Diff line change @@ -52,4 +52,12 @@ shellcheck: ## Run shellcheck on /scripts directory
5252 @find scripts/ -type f | xargs -n 1 shellcheck
5353
5454test : # # Run tests suite
55- @$(MAKE ) pre-commit shellcheck dockerfile-lint serverspec dive
55+ @$(MAKE ) pre-commit shellcheck dockerfile-lint serverspec dive trivy
56+
57+ trivy : # # Run trivy, a simple Vulnerability Scanner for Containers
58+ $(info --> Run `trivy`)
59+ @awk ' /image:/ { print $$2 }' docker-compose.ci.yml \
60+ | xargs -I % -n 1 -P 1 trivy \
61+ --exit-code 1 \
62+ --no-progress \
63+ --severity HIGH,CRITICAL %
Original file line number Diff line number Diff line change 1+ #! /usr/bin/env bash
2+
3+ set -o errexit
4+ set -o pipefail
5+ set -o nounset
6+
7+ DEBUG=${DEBUG:= 0}
8+ [[ $DEBUG -eq 1 ]] && set -o xtrace
9+
10+ GITHUB_TOKEN=${GITHUB_TOKEN:= ' ' }
11+ TRIVY_TIMEOUT_SEC=${TRIVY_TIMEOUT_SEC:= ' 360s' }
12+
13+ export TRIVY_TIMEOUT_SEC
14+
15+ # shellcheck disable=SC2145
16+ echo " --> trivy $@ "
17+
18+ # shellcheck disable=SC2046
19+ docker run --network host --rm --name " trivy_$( date +' %Y%m%d%H%M%S' ) " \
20+ -e GITHUB_TOKEN=" ${GITHUB_TOKEN} " \
21+ -v $( pwd) /.cache:/root/.cache/ \
22+ -v ~ /.docker/config.json:/root/.docker/config.json:ro \
23+ -v /var/run/docker.sock:/var/run/docker.sock:ro \
24+ -t $( tty & > /dev/null && echo ' -i' ) \
25+ aquasec/trivy:0.6.0 \
26+ " $@ "
You can’t perform that action at this time.
0 commit comments