2019-07-07 11:18:12 +05:30
|
|
|
# Read more about this feature here: https://docs.gitlab.com/ee/user/project/merge_requests/sast.html
|
|
|
|
#
|
|
|
|
# Configure the scanning tool through the environment variables.
|
|
|
|
# List of the variables: https://gitlab.com/gitlab-org/security-products/sast#settings
|
|
|
|
# How to set: https://docs.gitlab.com/ee/ci/yaml/#variables
|
|
|
|
|
|
|
|
sast:
|
|
|
|
stage: test
|
|
|
|
image: docker:stable
|
|
|
|
variables:
|
|
|
|
DOCKER_DRIVER: overlay2
|
2019-09-30 21:07:59 +05:30
|
|
|
DOCKER_TLS_CERTDIR: ""
|
2019-07-07 11:18:12 +05:30
|
|
|
allow_failure: true
|
|
|
|
services:
|
|
|
|
- docker:stable-dind
|
|
|
|
script:
|
|
|
|
- export SAST_VERSION=${SP_VERSION:-$(echo "$CI_SERVER_VERSION" | sed 's/^\([0-9]*\)\.\([0-9]*\).*/\1-\2-stable/')}
|
|
|
|
- |
|
|
|
|
if ! docker info &>/dev/null; then
|
|
|
|
if [ -z "$DOCKER_HOST" -a "$KUBERNETES_PORT" ]; then
|
|
|
|
export DOCKER_HOST='tcp://localhost:2375'
|
|
|
|
fi
|
|
|
|
fi
|
2019-07-31 22:56:46 +05:30
|
|
|
- | # this is required to avoid undesirable reset of Docker image ENV variables being set on build stage
|
|
|
|
function propagate_env_vars() {
|
|
|
|
CURRENT_ENV=$(printenv)
|
|
|
|
|
|
|
|
for VAR_NAME; do
|
|
|
|
echo $CURRENT_ENV | grep "${VAR_NAME}=" > /dev/null && echo "--env $VAR_NAME "
|
|
|
|
done
|
|
|
|
}
|
2019-07-07 11:18:12 +05:30
|
|
|
- |
|
|
|
|
docker run \
|
2019-07-31 22:56:46 +05:30
|
|
|
$(propagate_env_vars \
|
2019-09-04 21:01:54 +05:30
|
|
|
SAST_BANDIT_EXCLUDED_PATHS \
|
2019-07-31 22:56:46 +05:30
|
|
|
SAST_ANALYZER_IMAGES \
|
|
|
|
SAST_ANALYZER_IMAGE_PREFIX \
|
|
|
|
SAST_ANALYZER_IMAGE_TAG \
|
|
|
|
SAST_DEFAULT_ANALYZERS \
|
2019-09-04 21:01:54 +05:30
|
|
|
SAST_PULL_ANALYZER_IMAGES \
|
2019-07-31 22:56:46 +05:30
|
|
|
SAST_BRAKEMAN_LEVEL \
|
|
|
|
SAST_FLAWFINDER_LEVEL \
|
|
|
|
SAST_GITLEAKS_ENTROPY_LEVEL \
|
2019-09-04 21:01:54 +05:30
|
|
|
SAST_GOSEC_LEVEL \
|
|
|
|
SAST_EXCLUDED_PATHS \
|
2019-07-31 22:56:46 +05:30
|
|
|
SAST_DOCKER_CLIENT_NEGOTIATION_TIMEOUT \
|
|
|
|
SAST_PULL_ANALYZER_IMAGE_TIMEOUT \
|
|
|
|
SAST_RUN_ANALYZER_TIMEOUT \
|
2019-09-04 21:01:54 +05:30
|
|
|
ANT_HOME \
|
|
|
|
ANT_PATH \
|
|
|
|
GRADLE_PATH \
|
|
|
|
JAVA_OPTS \
|
|
|
|
JAVA_PATH \
|
|
|
|
MAVEN_CLI_OPTS \
|
|
|
|
MAVEN_PATH \
|
|
|
|
MAVEN_REPO_PATH \
|
|
|
|
SBT_PATH \
|
2019-09-30 21:07:59 +05:30
|
|
|
FAIL_NEVER \
|
2019-07-31 22:56:46 +05:30
|
|
|
) \
|
2019-07-07 11:18:12 +05:30
|
|
|
--volume "$PWD:/code" \
|
|
|
|
--volume /var/run/docker.sock:/var/run/docker.sock \
|
|
|
|
"registry.gitlab.com/gitlab-org/security-products/sast:$SAST_VERSION" /app/bin/run /code
|
|
|
|
artifacts:
|
|
|
|
reports:
|
|
|
|
sast: gl-sast-report.json
|
|
|
|
dependencies: []
|
|
|
|
only:
|
|
|
|
refs:
|
|
|
|
- branches
|
|
|
|
variables:
|
|
|
|
- $GITLAB_FEATURES =~ /\bsast\b/
|
|
|
|
except:
|
|
|
|
variables:
|
|
|
|
- $SAST_DISABLED
|