debian-mirror-gitlab/lib/gitlab/ci/templates/Security/SAST.gitlab-ci.yml

189 lines
5.6 KiB
YAML
Raw Normal View History

2019-12-04 20:38:33 +05:30
# Read more about this feature here: https://docs.gitlab.com/ee/user/application_security/sast/
2019-07-07 11:18:12 +05:30
#
# 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
2019-12-21 20:55:43 +05:30
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"
2019-12-26 22:10:19 +05:30
SAST_ANALYZER_IMAGE_TAG: 2
2019-12-21 20:55:43 +05:30
SAST_DISABLE_DIND: "false"
sast:
2019-07-07 11:18:12 +05:30
stage: test
2019-12-04 20:38:33 +05:30
allow_failure: true
artifacts:
reports:
sast: gl-sast-report.json
only:
refs:
- branches
variables:
- $GITLAB_FEATURES =~ /\bsast\b/
2019-07-07 11:18:12 +05:30
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
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-12-26 22:10:19 +05:30
- |
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)
2019-07-07 11:18:12 +05:30
- |
docker run \
2019-12-26 22:10:19 +05:30
--env-file .env \
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
except:
variables:
- $SAST_DISABLED
2019-12-04 20:38:33 +05:30
- $SAST_DISABLE_DIND == 'true'
.analyzer:
2019-12-21 20:55:43 +05:30
extends: sast
services: []
2019-12-04 20:38:33 +05:30
except:
variables:
- $SAST_DISABLE_DIND == 'false'
script:
- /analyzer run
bandit-sast:
extends: .analyzer
image:
2019-12-26 22:10:19 +05:30
name: "$SAST_ANALYZER_IMAGE_PREFIX/bandit:$SAST_ANALYZER_IMAGE_TAG"
2019-12-04 20:38:33 +05:30
only:
variables:
2019-12-21 20:55:43 +05:30
- $GITLAB_FEATURES =~ /\bsast\b/ &&
$SAST_DEFAULT_ANALYZERS =~ /bandit/&&
$CI_PROJECT_REPOSITORY_LANGUAGES =~ /python/
2019-12-04 20:38:33 +05:30
brakeman-sast:
extends: .analyzer
image:
2019-12-26 22:10:19 +05:30
name: "$SAST_ANALYZER_IMAGE_PREFIX/brakeman:$SAST_ANALYZER_IMAGE_TAG"
2019-12-04 20:38:33 +05:30
only:
variables:
2019-12-21 20:55:43 +05:30
- $GITLAB_FEATURES =~ /\bsast\b/ &&
$SAST_DEFAULT_ANALYZERS =~ /brakeman/ &&
$CI_PROJECT_REPOSITORY_LANGUAGES =~ /ruby/
2019-12-04 20:38:33 +05:30
eslint-sast:
extends: .analyzer
image:
2019-12-26 22:10:19 +05:30
name: "$SAST_ANALYZER_IMAGE_PREFIX/eslint:$SAST_ANALYZER_IMAGE_TAG"
2019-12-04 20:38:33 +05:30
only:
variables:
2019-12-21 20:55:43 +05:30
- $GITLAB_FEATURES =~ /\bsast\b/ &&
$SAST_DEFAULT_ANALYZERS =~ /eslint/ &&
$CI_PROJECT_REPOSITORY_LANGUAGES =~ /javascript/
2019-12-04 20:38:33 +05:30
flawfinder-sast:
extends: .analyzer
image:
2019-12-26 22:10:19 +05:30
name: "$SAST_ANALYZER_IMAGE_PREFIX/flawfinder:$SAST_ANALYZER_IMAGE_TAG"
2019-12-04 20:38:33 +05:30
only:
variables:
2019-12-21 20:55:43 +05:30
- $GITLAB_FEATURES =~ /\bsast\b/ &&
$SAST_DEFAULT_ANALYZERS =~ /flawfinder/ &&
$CI_PROJECT_REPOSITORY_LANGUAGES =~ /\b(c\+\+|c)\b/
2019-12-04 20:38:33 +05:30
gosec-sast:
extends: .analyzer
image:
2019-12-26 22:10:19 +05:30
name: "$SAST_ANALYZER_IMAGE_PREFIX/gosec:$SAST_ANALYZER_IMAGE_TAG"
2019-12-04 20:38:33 +05:30
only:
variables:
2019-12-21 20:55:43 +05:30
- $GITLAB_FEATURES =~ /\bsast\b/ &&
$SAST_DEFAULT_ANALYZERS =~ /gosec/ &&
$CI_PROJECT_REPOSITORY_LANGUAGES =~ /\bgo\b/
2019-12-04 20:38:33 +05:30
nodejs-scan-sast:
extends: .analyzer
image:
2019-12-26 22:10:19 +05:30
name: "$SAST_ANALYZER_IMAGE_PREFIX/nodejs-scan:$SAST_ANALYZER_IMAGE_TAG"
2019-12-04 20:38:33 +05:30
only:
variables:
2019-12-21 20:55:43 +05:30
- $GITLAB_FEATURES =~ /\bsast\b/ &&
$SAST_DEFAULT_ANALYZERS =~ /nodejs-scan/ &&
$CI_PROJECT_REPOSITORY_LANGUAGES =~ /javascript/
2019-12-04 20:38:33 +05:30
phpcs-security-audit-sast:
extends: .analyzer
image:
2019-12-26 22:10:19 +05:30
name: "$SAST_ANALYZER_IMAGE_PREFIX/phpcs-security-audit:$SAST_ANALYZER_IMAGE_TAG"
2019-12-04 20:38:33 +05:30
only:
variables:
2019-12-21 20:55:43 +05:30
- $GITLAB_FEATURES =~ /\bsast\b/ &&
$SAST_DEFAULT_ANALYZERS =~ /phpcs-security-audit/ &&
$CI_PROJECT_REPOSITORY_LANGUAGES =~ /php/
2019-12-04 20:38:33 +05:30
pmd-apex-sast:
extends: .analyzer
image:
2019-12-26 22:10:19 +05:30
name: "$SAST_ANALYZER_IMAGE_PREFIX/pmd-apex:$SAST_ANALYZER_IMAGE_TAG"
2019-12-04 20:38:33 +05:30
only:
variables:
2019-12-21 20:55:43 +05:30
- $GITLAB_FEATURES =~ /\bsast\b/ &&
$SAST_DEFAULT_ANALYZERS =~ /pmd-apex/ &&
$CI_PROJECT_REPOSITORY_LANGUAGES =~ /apex/
2019-12-04 20:38:33 +05:30
secrets-sast:
extends: .analyzer
image:
2019-12-26 22:10:19 +05:30
name: "$SAST_ANALYZER_IMAGE_PREFIX/secrets:$SAST_ANALYZER_IMAGE_TAG"
2019-12-21 20:55:43 +05:30
only:
variables:
- $GITLAB_FEATURES =~ /\bsast\b/ &&
$SAST_DEFAULT_ANALYZERS =~ /secrets/
2019-12-04 20:38:33 +05:30
security-code-scan-sast:
extends: .analyzer
image:
2019-12-26 22:10:19 +05:30
name: "$SAST_ANALYZER_IMAGE_PREFIX/security-code-scan:$SAST_ANALYZER_IMAGE_TAG"
2019-12-04 20:38:33 +05:30
only:
variables:
2019-12-21 20:55:43 +05:30
- $GITLAB_FEATURES =~ /\bsast\b/ &&
$SAST_DEFAULT_ANALYZERS =~ /security-code-scan/ &&
$CI_PROJECT_REPOSITORY_LANGUAGES =~ /\b(c\#|visual basic\b)/
2019-12-04 20:38:33 +05:30
sobelow-sast:
extends: .analyzer
image:
2019-12-26 22:10:19 +05:30
name: "$SAST_ANALYZER_IMAGE_PREFIX/sobelow:$SAST_ANALYZER_IMAGE_TAG"
2019-12-04 20:38:33 +05:30
only:
variables:
2019-12-21 20:55:43 +05:30
- $GITLAB_FEATURES =~ /\bsast\b/ &&
$SAST_DEFAULT_ANALYZERS =~ /sobelow/ &&
$CI_PROJECT_REPOSITORY_LANGUAGES =~ /elixir/
2019-12-04 20:38:33 +05:30
spotbugs-sast:
extends: .analyzer
image:
2019-12-26 22:10:19 +05:30
name: "$SAST_ANALYZER_IMAGE_PREFIX/spotbugs:$SAST_ANALYZER_IMAGE_TAG"
2019-12-04 20:38:33 +05:30
only:
variables:
2019-12-21 20:55:43 +05:30
- $GITLAB_FEATURES =~ /\bsast\b/ &&
$SAST_DEFAULT_ANALYZERS =~ /spotbugs/ &&
$CI_PROJECT_REPOSITORY_LANGUAGES =~ /java\b/
2019-12-04 20:38:33 +05:30
tslint-sast:
extends: .analyzer
image:
2019-12-26 22:10:19 +05:30
name: "$SAST_ANALYZER_IMAGE_PREFIX/tslint:$SAST_ANALYZER_IMAGE_TAG"
2019-12-04 20:38:33 +05:30
only:
variables:
2019-12-21 20:55:43 +05:30
- $GITLAB_FEATURES =~ /\bsast\b/ &&
$SAST_DEFAULT_ANALYZERS =~ /tslint/ &&
$CI_PROJECT_REPOSITORY_LANGUAGES =~ /typescript/