diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index b1cef4271e3dd04f4780ecc4085382ae5c773b05..b0829d5c2081fd4f1fa2d20604499cc61e68f5d6 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -33,7 +33,7 @@ test: - dockerd script: - docker run --rm its-registry.unl.edu/unl-its/docker-ci/static-code-analysis sonar-scanner -v - - docker run --rm -v "${PWD}:/work" -w /work its-registry.unl.edu/unl-its/docker-ci/detect-secrets scan + - docker run --rm -v "${PWD}:/work" -w /work its-registry.unl.edu/unl-its/docker-ci/detect-secrets -s Push to Container Registry: after_script: diff --git a/detect-secrets/Dockerfile b/detect-secrets/Dockerfile index 1c44f638c7fa772279c555dc61891a7aebd7cf88..51e07dee38d13191436d21e8d8c3ea27971ecd21 100644 --- a/detect-secrets/Dockerfile +++ b/detect-secrets/Dockerfile @@ -15,7 +15,7 @@ LABEL org.label-schema.build-date=$BUILD_DATE \ WORKDIR /work RUN apk update && apk upgrade && \ - apk add --no-cache git && \ + apk add --no-cache git jq && \ pip install detect-secrets COPY entrypoint.sh /usr/local/bin/ diff --git a/detect-secrets/entrypoint.sh b/detect-secrets/entrypoint.sh index 2a25395928d8ad42e74828710bbc76e505329fe3..b60b64ddb60b0cb3d273d5979d44cebc04be4a27 100644 --- a/detect-secrets/entrypoint.sh +++ b/detect-secrets/entrypoint.sh @@ -1,5 +1,20 @@ #!/bin/sh set -e -PARAM=${2:-scan} -/usr/local/bin/detect-secrets ${PARAM} -exit $? + +while [ -n "$1" ]; do +case "$1" in + -s) + RESULT=`/usr/local/bin/detect-secrets scan | jq '.results | length == 0'` + echo ${RESULT} + if [ "${RESULT}" = "true" ]; then + exit 0 + else + exit 1 + fi + ;; + *) + exec /bin/sh + ;; +esac +shift +done