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

198 lines
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"
2020-01-01 13:55:28 +05:30
SAST_DEFAULT_ANALYZERS: "bandit, brakeman, gosec, spotbugs, flawfinder, phpcs-security-audit, security-code-scan, nodejs-scan, eslint, tslint, secrets, sobelow, pmd-apex, kubesec"
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"
2020-01-01 13:55:28 +05:30
SCAN_KUBERNETES_MANIFESTS: "false"
2019-12-21 20:55:43 +05:30
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
- |
2020-03-13 15:44:24 +05:30
ENVS=`printenv | grep -vE '^(DOCKER_|CI|GITLAB_|FF_|HOME|PWD|OLDPWD|PATH|SHLVL|HOSTNAME)' | sed -n '/^[^\t]/s/=.*//p' | sed '/^$/d' | sed 's/^/-e /g' | tr '\n' ' '`
docker run "$ENVS" \
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'
2020-01-01 13:55:28 +05:30
.sast-analyzer:
2019-12-21 20:55:43 +05:30
extends: sast
services: []
2019-12-04 20:38:33 +05:30
except:
variables:
2020-03-13 15:44:24 +05:30
- $SAST_DISABLED
2019-12-04 20:38:33 +05:30
- $SAST_DISABLE_DIND == 'false'
script:
- /analyzer run
bandit-sast:
2020-01-01 13:55:28 +05:30
extends: .sast-analyzer
2019-12-04 20:38:33 +05:30
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:
2020-01-01 13:55:28 +05:30
extends: .sast-analyzer
2019-12-04 20:38:33 +05:30
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:
2020-01-01 13:55:28 +05:30
extends: .sast-analyzer
2019-12-04 20:38:33 +05:30
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:
2020-01-01 13:55:28 +05:30
extends: .sast-analyzer
2019-12-04 20:38:33 +05:30
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
2020-01-01 13:55:28 +05:30
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'
2019-12-04 20:38:33 +05:30
gosec-sast:
2020-01-01 13:55:28 +05:30
extends: .sast-analyzer
2019-12-04 20:38:33 +05:30
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:
2020-01-01 13:55:28 +05:30
extends: .sast-analyzer
2019-12-04 20:38:33 +05:30
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:
2020-01-01 13:55:28 +05:30
extends: .sast-analyzer
2019-12-04 20:38:33 +05:30
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:
2020-01-01 13:55:28 +05:30
extends: .sast-analyzer
2019-12-04 20:38:33 +05:30
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:
2020-01-01 13:55:28 +05:30
extends: .sast-analyzer
2019-12-04 20:38:33 +05:30
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:
2020-01-01 13:55:28 +05:30
extends: .sast-analyzer
2019-12-04 20:38:33 +05:30
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:
2020-01-01 13:55:28 +05:30
extends: .sast-analyzer
2019-12-04 20:38:33 +05:30
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:
2020-01-01 13:55:28 +05:30
extends: .sast-analyzer
2019-12-04 20:38:33 +05:30
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:
2020-01-01 13:55:28 +05:30
extends: .sast-analyzer
2019-12-04 20:38:33 +05:30
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/