199 lines
6 KiB
YAML
199 lines
6 KiB
YAML
# Read more about this feature here: https://docs.gitlab.com/ee/user/application_security/sast/
|
|
#
|
|
# 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
|
|
|
|
variables:
|
|
SAST_ANALYZER_IMAGE_PREFIX: "registry.gitlab.com/gitlab-org/security-products/analyzers"
|
|
SAST_DEFAULT_ANALYZERS: "bandit, brakeman, gosec, spotbugs, flawfinder, phpcs-security-audit, security-code-scan, nodejs-scan, eslint, tslint, secrets, sobelow, pmd-apex, kubesec"
|
|
SAST_ANALYZER_IMAGE_TAG: 2
|
|
SAST_DISABLE_DIND: "false"
|
|
SCAN_KUBERNETES_MANIFESTS: "false"
|
|
|
|
sast:
|
|
stage: test
|
|
allow_failure: true
|
|
artifacts:
|
|
reports:
|
|
sast: gl-sast-report.json
|
|
only:
|
|
refs:
|
|
- branches
|
|
variables:
|
|
- $GITLAB_FEATURES =~ /\bsast\b/
|
|
image: docker:stable
|
|
variables:
|
|
DOCKER_DRIVER: overlay2
|
|
DOCKER_TLS_CERTDIR: ""
|
|
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
|
|
- |
|
|
printenv | grep -E '^(DOCKER_|CI|GITLAB_|FF_|HOME|PWD|OLDPWD|PATH|SHLVL|HOSTNAME)' | cut -d'=' -f1 | \
|
|
(while IFS='\\n' read -r VAR; do unset -v "$VAR"; done; /bin/printenv > .env)
|
|
- |
|
|
docker run \
|
|
--env-file .env \
|
|
--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
|
|
except:
|
|
variables:
|
|
- $SAST_DISABLED
|
|
- $SAST_DISABLE_DIND == 'true'
|
|
|
|
.sast-analyzer:
|
|
extends: sast
|
|
services: []
|
|
except:
|
|
variables:
|
|
- $SAST_DISABLE_DIND == 'false'
|
|
script:
|
|
- /analyzer run
|
|
|
|
bandit-sast:
|
|
extends: .sast-analyzer
|
|
image:
|
|
name: "$SAST_ANALYZER_IMAGE_PREFIX/bandit:$SAST_ANALYZER_IMAGE_TAG"
|
|
only:
|
|
variables:
|
|
- $GITLAB_FEATURES =~ /\bsast\b/ &&
|
|
$SAST_DEFAULT_ANALYZERS =~ /bandit/&&
|
|
$CI_PROJECT_REPOSITORY_LANGUAGES =~ /python/
|
|
|
|
brakeman-sast:
|
|
extends: .sast-analyzer
|
|
image:
|
|
name: "$SAST_ANALYZER_IMAGE_PREFIX/brakeman:$SAST_ANALYZER_IMAGE_TAG"
|
|
only:
|
|
variables:
|
|
- $GITLAB_FEATURES =~ /\bsast\b/ &&
|
|
$SAST_DEFAULT_ANALYZERS =~ /brakeman/ &&
|
|
$CI_PROJECT_REPOSITORY_LANGUAGES =~ /ruby/
|
|
|
|
eslint-sast:
|
|
extends: .sast-analyzer
|
|
image:
|
|
name: "$SAST_ANALYZER_IMAGE_PREFIX/eslint:$SAST_ANALYZER_IMAGE_TAG"
|
|
only:
|
|
variables:
|
|
- $GITLAB_FEATURES =~ /\bsast\b/ &&
|
|
$SAST_DEFAULT_ANALYZERS =~ /eslint/ &&
|
|
$CI_PROJECT_REPOSITORY_LANGUAGES =~ /javascript/
|
|
|
|
flawfinder-sast:
|
|
extends: .sast-analyzer
|
|
image:
|
|
name: "$SAST_ANALYZER_IMAGE_PREFIX/flawfinder:$SAST_ANALYZER_IMAGE_TAG"
|
|
only:
|
|
variables:
|
|
- $GITLAB_FEATURES =~ /\bsast\b/ &&
|
|
$SAST_DEFAULT_ANALYZERS =~ /flawfinder/ &&
|
|
$CI_PROJECT_REPOSITORY_LANGUAGES =~ /\b(c\+\+|c)\b/
|
|
|
|
kubesec-sast:
|
|
extends: .sast-analyzer
|
|
image:
|
|
name: "$SAST_ANALYZER_IMAGE_PREFIX/kubesec:$SAST_ANALYZER_IMAGE_TAG"
|
|
only:
|
|
variables:
|
|
- $GITLAB_FEATURES =~ /\bsast\b/ &&
|
|
$SAST_DEFAULT_ANALYZERS =~ /kubesec/ &&
|
|
$SCAN_KUBERNETES_MANIFESTS == 'true'
|
|
|
|
gosec-sast:
|
|
extends: .sast-analyzer
|
|
image:
|
|
name: "$SAST_ANALYZER_IMAGE_PREFIX/gosec:$SAST_ANALYZER_IMAGE_TAG"
|
|
only:
|
|
variables:
|
|
- $GITLAB_FEATURES =~ /\bsast\b/ &&
|
|
$SAST_DEFAULT_ANALYZERS =~ /gosec/ &&
|
|
$CI_PROJECT_REPOSITORY_LANGUAGES =~ /\bgo\b/
|
|
|
|
nodejs-scan-sast:
|
|
extends: .sast-analyzer
|
|
image:
|
|
name: "$SAST_ANALYZER_IMAGE_PREFIX/nodejs-scan:$SAST_ANALYZER_IMAGE_TAG"
|
|
only:
|
|
variables:
|
|
- $GITLAB_FEATURES =~ /\bsast\b/ &&
|
|
$SAST_DEFAULT_ANALYZERS =~ /nodejs-scan/ &&
|
|
$CI_PROJECT_REPOSITORY_LANGUAGES =~ /javascript/
|
|
|
|
phpcs-security-audit-sast:
|
|
extends: .sast-analyzer
|
|
image:
|
|
name: "$SAST_ANALYZER_IMAGE_PREFIX/phpcs-security-audit:$SAST_ANALYZER_IMAGE_TAG"
|
|
only:
|
|
variables:
|
|
- $GITLAB_FEATURES =~ /\bsast\b/ &&
|
|
$SAST_DEFAULT_ANALYZERS =~ /phpcs-security-audit/ &&
|
|
$CI_PROJECT_REPOSITORY_LANGUAGES =~ /php/
|
|
|
|
pmd-apex-sast:
|
|
extends: .sast-analyzer
|
|
image:
|
|
name: "$SAST_ANALYZER_IMAGE_PREFIX/pmd-apex:$SAST_ANALYZER_IMAGE_TAG"
|
|
only:
|
|
variables:
|
|
- $GITLAB_FEATURES =~ /\bsast\b/ &&
|
|
$SAST_DEFAULT_ANALYZERS =~ /pmd-apex/ &&
|
|
$CI_PROJECT_REPOSITORY_LANGUAGES =~ /apex/
|
|
|
|
secrets-sast:
|
|
extends: .sast-analyzer
|
|
image:
|
|
name: "$SAST_ANALYZER_IMAGE_PREFIX/secrets:$SAST_ANALYZER_IMAGE_TAG"
|
|
only:
|
|
variables:
|
|
- $GITLAB_FEATURES =~ /\bsast\b/ &&
|
|
$SAST_DEFAULT_ANALYZERS =~ /secrets/
|
|
|
|
security-code-scan-sast:
|
|
extends: .sast-analyzer
|
|
image:
|
|
name: "$SAST_ANALYZER_IMAGE_PREFIX/security-code-scan:$SAST_ANALYZER_IMAGE_TAG"
|
|
only:
|
|
variables:
|
|
- $GITLAB_FEATURES =~ /\bsast\b/ &&
|
|
$SAST_DEFAULT_ANALYZERS =~ /security-code-scan/ &&
|
|
$CI_PROJECT_REPOSITORY_LANGUAGES =~ /\b(c\#|visual basic\b)/
|
|
|
|
sobelow-sast:
|
|
extends: .sast-analyzer
|
|
image:
|
|
name: "$SAST_ANALYZER_IMAGE_PREFIX/sobelow:$SAST_ANALYZER_IMAGE_TAG"
|
|
only:
|
|
variables:
|
|
- $GITLAB_FEATURES =~ /\bsast\b/ &&
|
|
$SAST_DEFAULT_ANALYZERS =~ /sobelow/ &&
|
|
$CI_PROJECT_REPOSITORY_LANGUAGES =~ /elixir/
|
|
|
|
spotbugs-sast:
|
|
extends: .sast-analyzer
|
|
image:
|
|
name: "$SAST_ANALYZER_IMAGE_PREFIX/spotbugs:$SAST_ANALYZER_IMAGE_TAG"
|
|
only:
|
|
variables:
|
|
- $GITLAB_FEATURES =~ /\bsast\b/ &&
|
|
$SAST_DEFAULT_ANALYZERS =~ /spotbugs/ &&
|
|
$CI_PROJECT_REPOSITORY_LANGUAGES =~ /java\b/
|
|
|
|
tslint-sast:
|
|
extends: .sast-analyzer
|
|
image:
|
|
name: "$SAST_ANALYZER_IMAGE_PREFIX/tslint:$SAST_ANALYZER_IMAGE_TAG"
|
|
only:
|
|
variables:
|
|
- $GITLAB_FEATURES =~ /\bsast\b/ &&
|
|
$SAST_DEFAULT_ANALYZERS =~ /tslint/ &&
|
|
$CI_PROJECT_REPOSITORY_LANGUAGES =~ /typescript/
|