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:
|
2020-05-24 23:13:21 +05:30
|
|
|
# Setting this variable will affect all Security templates
|
|
|
|
# (SAST, Dependency Scanning, ...)
|
|
|
|
SECURE_ANALYZERS_PREFIX: "registry.gitlab.com/gitlab-org/security-products/analyzers"
|
|
|
|
|
2020-11-24 15:15:51 +05:30
|
|
|
SAST_DEFAULT_ANALYZERS: "bandit, brakeman, gosec, spotbugs, flawfinder, phpcs-security-audit, security-code-scan, nodejs-scan, eslint, sobelow, pmd-apex, kubesec"
|
2020-06-23 00:09:42 +05:30
|
|
|
SAST_EXCLUDED_PATHS: "spec, test, tests, tmp"
|
2019-12-26 22:10:19 +05:30
|
|
|
SAST_ANALYZER_IMAGE_TAG: 2
|
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
|
|
|
artifacts:
|
|
|
|
reports:
|
|
|
|
sast: gl-sast-report.json
|
2020-05-24 23:13:21 +05:30
|
|
|
rules:
|
2020-11-24 15:15:51 +05:30
|
|
|
- when: never
|
2019-07-07 11:18:12 +05:30
|
|
|
variables:
|
2020-05-24 23:13:21 +05:30
|
|
|
SEARCH_MAX_DEPTH: 4
|
2019-07-07 11:18:12 +05:30
|
|
|
script:
|
2020-11-24 15:15:51 +05:30
|
|
|
- echo "$CI_JOB_NAME is used for configuration only, and its script should not be executed"
|
|
|
|
- exit 1
|
2019-12-04 20:38:33 +05:30
|
|
|
|
2020-01-01 13:55:28 +05:30
|
|
|
.sast-analyzer:
|
2019-12-21 20:55:43 +05:30
|
|
|
extends: sast
|
2020-11-24 15:15:51 +05:30
|
|
|
allow_failure: true
|
2020-05-24 23:13:21 +05:30
|
|
|
rules:
|
2020-11-24 15:15:51 +05:30
|
|
|
- if: $SAST_DISABLED
|
2020-05-24 23:13:21 +05:30
|
|
|
when: never
|
2020-10-24 23:57:45 +05:30
|
|
|
- if: $CI_COMMIT_BRANCH
|
2019-12-04 20:38:33 +05:30
|
|
|
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:
|
2020-11-24 15:15:51 +05:30
|
|
|
name: "$SAST_ANALYZER_IMAGE"
|
|
|
|
variables:
|
|
|
|
SAST_ANALYZER_IMAGE: "$SECURE_ANALYZERS_PREFIX/bandit:$SAST_ANALYZER_IMAGE_TAG"
|
2020-05-24 23:13:21 +05:30
|
|
|
rules:
|
2020-11-24 15:15:51 +05:30
|
|
|
- if: $SAST_DISABLED
|
2020-05-24 23:13:21 +05:30
|
|
|
when: never
|
|
|
|
- if: $CI_COMMIT_BRANCH &&
|
|
|
|
$SAST_DEFAULT_ANALYZERS =~ /bandit/
|
|
|
|
exists:
|
|
|
|
- '**/*.py'
|
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:
|
2020-11-24 15:15:51 +05:30
|
|
|
name: "$SAST_ANALYZER_IMAGE"
|
|
|
|
variables:
|
|
|
|
SAST_ANALYZER_IMAGE: "$SECURE_ANALYZERS_PREFIX/brakeman:$SAST_ANALYZER_IMAGE_TAG"
|
2020-05-24 23:13:21 +05:30
|
|
|
rules:
|
2020-11-24 15:15:51 +05:30
|
|
|
- if: $SAST_DISABLED
|
2020-05-24 23:13:21 +05:30
|
|
|
when: never
|
|
|
|
- if: $CI_COMMIT_BRANCH &&
|
|
|
|
$SAST_DEFAULT_ANALYZERS =~ /brakeman/
|
|
|
|
exists:
|
2020-06-23 00:09:42 +05:30
|
|
|
- 'config/routes.rb'
|
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:
|
2020-11-24 15:15:51 +05:30
|
|
|
name: "$SAST_ANALYZER_IMAGE"
|
|
|
|
variables:
|
|
|
|
SAST_ANALYZER_IMAGE: "$SECURE_ANALYZERS_PREFIX/eslint:$SAST_ANALYZER_IMAGE_TAG"
|
2020-05-24 23:13:21 +05:30
|
|
|
rules:
|
2020-11-24 15:15:51 +05:30
|
|
|
- if: $SAST_DISABLED
|
2020-05-24 23:13:21 +05:30
|
|
|
when: never
|
|
|
|
- if: $CI_COMMIT_BRANCH &&
|
|
|
|
$SAST_DEFAULT_ANALYZERS =~ /eslint/
|
|
|
|
exists:
|
|
|
|
- '**/*.html'
|
|
|
|
- '**/*.js'
|
2020-07-28 23:09:34 +05:30
|
|
|
- '**/*.jsx'
|
|
|
|
- '**/*.ts'
|
|
|
|
- '**/*.tsx'
|
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:
|
2020-11-24 15:15:51 +05:30
|
|
|
name: "$SAST_ANALYZER_IMAGE"
|
|
|
|
variables:
|
|
|
|
SAST_ANALYZER_IMAGE: "$SECURE_ANALYZERS_PREFIX/flawfinder:$SAST_ANALYZER_IMAGE_TAG"
|
2020-05-24 23:13:21 +05:30
|
|
|
rules:
|
2020-11-24 15:15:51 +05:30
|
|
|
- if: $SAST_DISABLED
|
2020-05-24 23:13:21 +05:30
|
|
|
when: never
|
|
|
|
- if: $CI_COMMIT_BRANCH &&
|
|
|
|
$SAST_DEFAULT_ANALYZERS =~ /flawfinder/
|
|
|
|
exists:
|
|
|
|
- '**/*.c'
|
|
|
|
- '**/*.cpp'
|
2019-12-04 20:38:33 +05:30
|
|
|
|
2020-01-01 13:55:28 +05:30
|
|
|
kubesec-sast:
|
|
|
|
extends: .sast-analyzer
|
|
|
|
image:
|
2020-11-24 15:15:51 +05:30
|
|
|
name: "$SAST_ANALYZER_IMAGE"
|
|
|
|
variables:
|
|
|
|
SAST_ANALYZER_IMAGE: "$SECURE_ANALYZERS_PREFIX/kubesec:$SAST_ANALYZER_IMAGE_TAG"
|
2020-05-24 23:13:21 +05:30
|
|
|
rules:
|
2020-11-24 15:15:51 +05:30
|
|
|
- if: $SAST_DISABLED
|
2020-05-24 23:13:21 +05:30
|
|
|
when: never
|
|
|
|
- if: $CI_COMMIT_BRANCH &&
|
2020-01-01 13:55:28 +05:30
|
|
|
$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:
|
2020-11-24 15:15:51 +05:30
|
|
|
name: "$SAST_ANALYZER_IMAGE"
|
|
|
|
variables:
|
|
|
|
SAST_ANALYZER_IMAGE: "$SECURE_ANALYZERS_PREFIX/gosec:$SAST_ANALYZER_IMAGE_TAG"
|
2020-05-24 23:13:21 +05:30
|
|
|
rules:
|
2020-11-24 15:15:51 +05:30
|
|
|
- if: $SAST_DISABLED
|
2020-05-24 23:13:21 +05:30
|
|
|
when: never
|
|
|
|
- if: $CI_COMMIT_BRANCH &&
|
|
|
|
$SAST_DEFAULT_ANALYZERS =~ /gosec/
|
|
|
|
exists:
|
|
|
|
- '**/*.go'
|
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:
|
2020-11-24 15:15:51 +05:30
|
|
|
name: "$SAST_ANALYZER_IMAGE"
|
|
|
|
variables:
|
|
|
|
SAST_ANALYZER_IMAGE: "$SECURE_ANALYZERS_PREFIX/nodejs-scan:$SAST_ANALYZER_IMAGE_TAG"
|
2020-05-24 23:13:21 +05:30
|
|
|
rules:
|
2020-11-24 15:15:51 +05:30
|
|
|
- if: $SAST_DISABLED
|
2020-05-24 23:13:21 +05:30
|
|
|
when: never
|
|
|
|
- if: $CI_COMMIT_BRANCH &&
|
|
|
|
$SAST_DEFAULT_ANALYZERS =~ /nodejs-scan/
|
|
|
|
exists:
|
2020-06-23 00:09:42 +05:30
|
|
|
- 'package.json'
|
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:
|
2020-11-24 15:15:51 +05:30
|
|
|
name: "$SAST_ANALYZER_IMAGE"
|
|
|
|
variables:
|
|
|
|
SAST_ANALYZER_IMAGE: "$SECURE_ANALYZERS_PREFIX/phpcs-security-audit:$SAST_ANALYZER_IMAGE_TAG"
|
2020-05-24 23:13:21 +05:30
|
|
|
rules:
|
2020-11-24 15:15:51 +05:30
|
|
|
- if: $SAST_DISABLED
|
2020-05-24 23:13:21 +05:30
|
|
|
when: never
|
|
|
|
- if: $CI_COMMIT_BRANCH &&
|
|
|
|
$SAST_DEFAULT_ANALYZERS =~ /phpcs-security-audit/
|
|
|
|
exists:
|
|
|
|
- '**/*.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:
|
2020-11-24 15:15:51 +05:30
|
|
|
name: "$SAST_ANALYZER_IMAGE"
|
|
|
|
variables:
|
|
|
|
SAST_ANALYZER_IMAGE: "$SECURE_ANALYZERS_PREFIX/pmd-apex:$SAST_ANALYZER_IMAGE_TAG"
|
2020-05-24 23:13:21 +05:30
|
|
|
rules:
|
2020-11-24 15:15:51 +05:30
|
|
|
- if: $SAST_DISABLED
|
2020-05-24 23:13:21 +05:30
|
|
|
when: never
|
|
|
|
- if: $CI_COMMIT_BRANCH &&
|
|
|
|
$SAST_DEFAULT_ANALYZERS =~ /pmd-apex/
|
|
|
|
exists:
|
|
|
|
- '**/*.cls'
|
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:
|
2020-11-24 15:15:51 +05:30
|
|
|
name: "$SAST_ANALYZER_IMAGE"
|
|
|
|
variables:
|
|
|
|
SAST_ANALYZER_IMAGE: "$SECURE_ANALYZERS_PREFIX/security-code-scan:$SAST_ANALYZER_IMAGE_TAG"
|
2020-05-24 23:13:21 +05:30
|
|
|
rules:
|
2020-11-24 15:15:51 +05:30
|
|
|
- if: $SAST_DISABLED
|
2020-05-24 23:13:21 +05:30
|
|
|
when: never
|
|
|
|
- if: $CI_COMMIT_BRANCH &&
|
|
|
|
$SAST_DEFAULT_ANALYZERS =~ /security-code-scan/
|
|
|
|
exists:
|
|
|
|
- '**/*.csproj'
|
|
|
|
- '**/*.vbproj'
|
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:
|
2020-11-24 15:15:51 +05:30
|
|
|
name: "$SAST_ANALYZER_IMAGE"
|
|
|
|
variables:
|
|
|
|
SAST_ANALYZER_IMAGE: "$SECURE_ANALYZERS_PREFIX/sobelow:$SAST_ANALYZER_IMAGE_TAG"
|
2020-05-24 23:13:21 +05:30
|
|
|
rules:
|
2020-11-24 15:15:51 +05:30
|
|
|
- if: $SAST_DISABLED
|
2020-05-24 23:13:21 +05:30
|
|
|
when: never
|
|
|
|
- if: $CI_COMMIT_BRANCH &&
|
|
|
|
$SAST_DEFAULT_ANALYZERS =~ /sobelow/
|
|
|
|
exists:
|
2020-06-23 00:09:42 +05:30
|
|
|
- 'mix.exs'
|
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:
|
2020-11-24 15:15:51 +05:30
|
|
|
name: "$SAST_ANALYZER_IMAGE"
|
|
|
|
variables:
|
|
|
|
SAST_ANALYZER_IMAGE: "$SECURE_ANALYZERS_PREFIX/spotbugs:$SAST_ANALYZER_IMAGE_TAG"
|
2020-05-24 23:13:21 +05:30
|
|
|
rules:
|
2020-11-24 15:15:51 +05:30
|
|
|
- if: $SAST_DISABLED
|
2020-05-24 23:13:21 +05:30
|
|
|
when: never
|
|
|
|
- if: $CI_COMMIT_BRANCH &&
|
|
|
|
$SAST_DEFAULT_ANALYZERS =~ /spotbugs/
|
|
|
|
exists:
|
|
|
|
- '**/*.groovy'
|
|
|
|
- '**/*.java'
|
|
|
|
- '**/*.scala'
|