Skip to content

Commit

Permalink
Initial GitLab CI template to deeply integrated with GitLab Container…
Browse files Browse the repository at this point in the history
… Scanning

Signed-off-by: Takuya Noguchi <takninnovationresearch@gmail.com>
  • Loading branch information
tnir committed Jan 18, 2020
1 parent 4a7fb52 commit 56cc6ab
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions contrib/Trivy.gitlab-ci.yml
@@ -0,0 +1,37 @@
Trivy_container_scanning:
stage: test
image:
name: alpine
variables:
# Override the GIT_STRATEGY variable in your `.gitlab-ci.yml` file and set it to `fetch` if you want to provide a `clair-whitelist.yml`
# file. See https://docs.gitlab.com/ee/user/application_security/container_scanning/index.html#overriding-the-container-scanning-template
# for details
GIT_STRATEGY: none
IMAGE: "$CI_REGISTRY_IMAGE:$CI_COMMIT_SHA"
allow_failure: true
before_script:
- apk add --no-cache curl docker-cli
- docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" $CI_REGISTRY
- export VERSION=$(curl --silent "https://api.github.com/repos/aquasecurity/trivy/releases/latest" | grep '"tag_name":' | sed -E 's/.*"v([^"]+)".*/\1/')
- echo $VERSION
- wget https://github.com/aquasecurity/trivy/releases/download/v${VERSION}/trivy_${VERSION}_Linux-64bit.tar.gz
- tar zxvf trivy_${VERSION}_Linux-64bit.tar.gz
script:
- docker pull $IMAGE
- ./trivy --exit-code 0 --cache-dir $CI_PROJECT_DIR/.trivycache/ --no-progress --format template --template "@contrib/gitlab.tpl" -o ${CI_PROJECT_DIR}/gl-container-scanning-report.json $IMAGE
cache:
paths:
- $CI_PROJECT_DIR/.trivycache/
artifacts:
reports:
container_scanning: gl-container-scanning-report.json
dependencies: []
only:
refs:
- branches
#variables:
# - $GITLAB_FEATURES =~ /\bcontainer_scanning\b/
#except:
# variables:
# - $CONTAINER_SCANNING_DISABLED

0 comments on commit 56cc6ab

Please sign in to comment.