2022-07-16 23:28:13 +05:30
|
|
|
# Read more about this feature here: https://docs.gitlab.com/ee/user/application_security/sast/
|
|
|
|
#
|
|
|
|
# Configure SAST with CI/CD variables (https://docs.gitlab.com/ee/ci/variables/index.html).
|
|
|
|
# List of available variables: https://docs.gitlab.com/ee/user/application_security/sast/index.html#available-variables
|
|
|
|
|
|
|
|
variables:
|
|
|
|
# Setting this variable will affect all Security templates
|
|
|
|
# (SAST, Dependency Scanning, ...)
|
2022-08-27 11:52:29 +05:30
|
|
|
SECURE_ANALYZERS_PREFIX: "$CI_TEMPLATE_REGISTRY_HOST/security-products"
|
2022-07-16 23:28:13 +05:30
|
|
|
SAST_IMAGE_SUFFIX: ""
|
|
|
|
|
|
|
|
SAST_EXCLUDED_ANALYZERS: ""
|
|
|
|
SAST_EXCLUDED_PATHS: "spec, test, tests, tmp"
|
|
|
|
SCAN_KUBERNETES_MANIFESTS: "false"
|
|
|
|
|
|
|
|
sast:
|
|
|
|
stage: test
|
|
|
|
artifacts:
|
|
|
|
reports:
|
|
|
|
sast: gl-sast-report.json
|
|
|
|
rules:
|
|
|
|
- when: never
|
|
|
|
variables:
|
|
|
|
SEARCH_MAX_DEPTH: 4
|
|
|
|
script:
|
|
|
|
- echo "$CI_JOB_NAME is used for configuration only, and its script should not be executed"
|
|
|
|
- exit 1
|
|
|
|
|
|
|
|
.sast-analyzer:
|
|
|
|
extends: sast
|
|
|
|
allow_failure: true
|
|
|
|
# `rules` must be overridden explicitly by each child job
|
|
|
|
# see https://gitlab.com/gitlab-org/gitlab/-/issues/218444
|
|
|
|
script:
|
|
|
|
- /analyzer run
|
|
|
|
|
|
|
|
bandit-sast:
|
|
|
|
extends: .sast-analyzer
|
2022-10-11 01:57:18 +05:30
|
|
|
script:
|
|
|
|
- echo "This job was deprecated in GitLab 14.8 and removed in GitLab 15.3"
|
|
|
|
- echo "For more information see https://gitlab.com/gitlab-org/gitlab/-/issues/352554"
|
|
|
|
- exit 1
|
2022-07-16 23:28:13 +05:30
|
|
|
rules:
|
2022-10-11 01:57:18 +05:30
|
|
|
- when: never
|
2022-07-16 23:28:13 +05:30
|
|
|
|
|
|
|
brakeman-sast:
|
|
|
|
extends: .sast-analyzer
|
|
|
|
image:
|
|
|
|
name: "$SAST_ANALYZER_IMAGE"
|
|
|
|
variables:
|
|
|
|
SAST_ANALYZER_IMAGE_TAG: 3
|
|
|
|
SAST_ANALYZER_IMAGE: "$SECURE_ANALYZERS_PREFIX/brakeman:$SAST_ANALYZER_IMAGE_TAG"
|
|
|
|
rules:
|
|
|
|
- if: $SAST_DISABLED
|
|
|
|
when: never
|
|
|
|
- if: $SAST_EXCLUDED_ANALYZERS =~ /brakeman/
|
|
|
|
when: never
|
2022-08-27 11:52:29 +05:30
|
|
|
- if: $CI_PIPELINE_SOURCE == "merge_request_event" # Add the job to merge request pipelines if there's an open merge request.
|
2022-07-16 23:28:13 +05:30
|
|
|
exists:
|
|
|
|
- '**/*.rb'
|
|
|
|
- '**/Gemfile'
|
|
|
|
- if: $CI_OPEN_MERGE_REQUESTS # Don't add it to a *branch* pipeline if it's already in a merge request pipeline.
|
|
|
|
when: never
|
|
|
|
- if: $CI_COMMIT_BRANCH # If there's no open merge request, add it to a *branch* pipeline instead.
|
|
|
|
exists:
|
|
|
|
- '**/*.rb'
|
|
|
|
- '**/Gemfile'
|
|
|
|
|
|
|
|
eslint-sast:
|
|
|
|
extends: .sast-analyzer
|
2022-10-11 01:57:18 +05:30
|
|
|
script:
|
|
|
|
- echo "This job was deprecated in GitLab 14.8 and removed in GitLab 15.3"
|
|
|
|
- echo "For more information see https://gitlab.com/gitlab-org/gitlab/-/issues/352554"
|
|
|
|
- exit 1
|
2022-07-16 23:28:13 +05:30
|
|
|
rules:
|
2022-10-11 01:57:18 +05:30
|
|
|
- when: never
|
2022-07-16 23:28:13 +05:30
|
|
|
|
|
|
|
flawfinder-sast:
|
|
|
|
extends: .sast-analyzer
|
|
|
|
image:
|
|
|
|
name: "$SAST_ANALYZER_IMAGE"
|
|
|
|
variables:
|
|
|
|
SAST_ANALYZER_IMAGE_TAG: 3
|
|
|
|
SAST_ANALYZER_IMAGE: "$SECURE_ANALYZERS_PREFIX/flawfinder:$SAST_ANALYZER_IMAGE_TAG"
|
|
|
|
rules:
|
|
|
|
- if: $SAST_DISABLED
|
|
|
|
when: never
|
|
|
|
- if: $SAST_EXCLUDED_ANALYZERS =~ /flawfinder/
|
|
|
|
when: never
|
2022-08-27 11:52:29 +05:30
|
|
|
- if: $CI_PIPELINE_SOURCE == "merge_request_event" # Add the job to merge request pipelines if there's an open merge request.
|
2022-07-16 23:28:13 +05:30
|
|
|
exists:
|
|
|
|
- '**/*.c'
|
|
|
|
- '**/*.cc'
|
|
|
|
- '**/*.cpp'
|
|
|
|
- '**/*.c++'
|
|
|
|
- '**/*.cp'
|
|
|
|
- '**/*.cxx'
|
|
|
|
- if: $CI_OPEN_MERGE_REQUESTS # Don't add it to a *branch* pipeline if it's already in a merge request pipeline.
|
|
|
|
when: never
|
|
|
|
- if: $CI_COMMIT_BRANCH # If there's no open merge request, add it to a *branch* pipeline instead.
|
|
|
|
exists:
|
|
|
|
- '**/*.c'
|
|
|
|
- '**/*.cc'
|
|
|
|
- '**/*.cpp'
|
|
|
|
- '**/*.c++'
|
|
|
|
- '**/*.cp'
|
|
|
|
- '**/*.cxx'
|
|
|
|
|
2022-10-11 01:57:18 +05:30
|
|
|
gosec-sast:
|
|
|
|
extends: .sast-analyzer
|
|
|
|
script:
|
|
|
|
- echo "This job was deprecated in GitLab 15.0 and removed in GitLab 15.2"
|
|
|
|
- echo "For more information see https://gitlab.com/gitlab-org/gitlab/-/issues/352554"
|
|
|
|
- exit 1
|
|
|
|
rules:
|
|
|
|
- when: never
|
|
|
|
|
2022-07-16 23:28:13 +05:30
|
|
|
kubesec-sast:
|
|
|
|
extends: .sast-analyzer
|
|
|
|
image:
|
|
|
|
name: "$SAST_ANALYZER_IMAGE"
|
|
|
|
variables:
|
|
|
|
SAST_ANALYZER_IMAGE_TAG: 3
|
|
|
|
SAST_ANALYZER_IMAGE: "$SECURE_ANALYZERS_PREFIX/kubesec:$SAST_ANALYZER_IMAGE_TAG"
|
|
|
|
rules:
|
|
|
|
- if: $SAST_DISABLED
|
|
|
|
when: never
|
|
|
|
- if: $SAST_EXCLUDED_ANALYZERS =~ /kubesec/
|
|
|
|
when: never
|
|
|
|
# Add the job to merge request pipelines if there's an open merge request.
|
2022-08-27 11:52:29 +05:30
|
|
|
- if: $CI_PIPELINE_SOURCE == "merge_request_event" &&
|
2022-07-16 23:28:13 +05:30
|
|
|
$SCAN_KUBERNETES_MANIFESTS == 'true'
|
|
|
|
- if: $CI_OPEN_MERGE_REQUESTS # Don't add it to a *branch* pipeline if it's already in a merge request pipeline.
|
|
|
|
when: never
|
|
|
|
# If there's no open merge request, add it to a *branch* pipeline instead.
|
|
|
|
- if: $CI_COMMIT_BRANCH &&
|
|
|
|
$SCAN_KUBERNETES_MANIFESTS == 'true'
|
|
|
|
|
|
|
|
.mobsf-sast:
|
|
|
|
extends: .sast-analyzer
|
|
|
|
image:
|
|
|
|
name: "$SAST_ANALYZER_IMAGE"
|
|
|
|
variables:
|
|
|
|
SAST_ANALYZER_IMAGE_TAG: 3
|
|
|
|
SAST_ANALYZER_IMAGE: "$SECURE_ANALYZERS_PREFIX/mobsf:$SAST_ANALYZER_IMAGE_TAG"
|
|
|
|
|
|
|
|
mobsf-android-sast:
|
|
|
|
extends: .mobsf-sast
|
|
|
|
rules:
|
|
|
|
- if: $SAST_DISABLED
|
|
|
|
when: never
|
|
|
|
- if: $SAST_EXCLUDED_ANALYZERS =~ /mobsf/
|
|
|
|
when: never
|
|
|
|
# Add the job to merge request pipelines if there's an open merge request.
|
2022-08-27 11:52:29 +05:30
|
|
|
- if: $CI_PIPELINE_SOURCE == "merge_request_event" &&
|
2022-07-16 23:28:13 +05:30
|
|
|
$SAST_EXPERIMENTAL_FEATURES == 'true'
|
|
|
|
exists:
|
|
|
|
- '**/*.apk'
|
|
|
|
- '**/AndroidManifest.xml'
|
|
|
|
- if: $CI_OPEN_MERGE_REQUESTS # Don't add it to a *branch* pipeline if it's already in a merge request pipeline.
|
|
|
|
when: never
|
|
|
|
# If there's no open merge request, add it to a *branch* pipeline instead.
|
|
|
|
- if: $CI_COMMIT_BRANCH &&
|
|
|
|
$SAST_EXPERIMENTAL_FEATURES == 'true'
|
|
|
|
exists:
|
|
|
|
- '**/*.apk'
|
|
|
|
- '**/AndroidManifest.xml'
|
|
|
|
|
|
|
|
mobsf-ios-sast:
|
|
|
|
extends: .mobsf-sast
|
|
|
|
rules:
|
|
|
|
- if: $SAST_DISABLED
|
|
|
|
when: never
|
|
|
|
- if: $SAST_EXCLUDED_ANALYZERS =~ /mobsf/
|
|
|
|
when: never
|
|
|
|
# Add the job to merge request pipelines if there's an open merge request.
|
2022-08-27 11:52:29 +05:30
|
|
|
- if: $CI_PIPELINE_SOURCE == "merge_request_event" &&
|
2022-07-16 23:28:13 +05:30
|
|
|
$SAST_EXPERIMENTAL_FEATURES == 'true'
|
|
|
|
exists:
|
|
|
|
- '**/*.ipa'
|
|
|
|
- '**/*.xcodeproj/*'
|
|
|
|
- if: $CI_OPEN_MERGE_REQUESTS # Don't add it to a *branch* pipeline if it's already in a merge request pipeline.
|
|
|
|
when: never
|
|
|
|
# If there's no open merge request, add it to a *branch* pipeline instead.
|
|
|
|
- if: $CI_COMMIT_BRANCH &&
|
|
|
|
$SAST_EXPERIMENTAL_FEATURES == 'true'
|
|
|
|
exists:
|
|
|
|
- '**/*.ipa'
|
|
|
|
- '**/*.xcodeproj/*'
|
|
|
|
|
|
|
|
nodejs-scan-sast:
|
|
|
|
extends: .sast-analyzer
|
|
|
|
image:
|
|
|
|
name: "$SAST_ANALYZER_IMAGE"
|
|
|
|
variables:
|
|
|
|
SAST_ANALYZER_IMAGE_TAG: 3
|
|
|
|
SAST_ANALYZER_IMAGE: "$SECURE_ANALYZERS_PREFIX/nodejs-scan:$SAST_ANALYZER_IMAGE_TAG"
|
|
|
|
rules:
|
|
|
|
- if: $SAST_DISABLED
|
|
|
|
when: never
|
|
|
|
- if: $SAST_EXCLUDED_ANALYZERS =~ /nodejs-scan/
|
|
|
|
when: never
|
2022-08-27 11:52:29 +05:30
|
|
|
- if: $CI_PIPELINE_SOURCE == "merge_request_event" # Add the job to merge request pipelines if there's an open merge request.
|
2022-07-16 23:28:13 +05:30
|
|
|
exists:
|
|
|
|
- '**/package.json'
|
|
|
|
- if: $CI_OPEN_MERGE_REQUESTS # Don't add it to a *branch* pipeline if it's already in a merge request pipeline.
|
|
|
|
when: never
|
|
|
|
- if: $CI_COMMIT_BRANCH # If there's no open merge request, add it to a *branch* pipeline instead.
|
|
|
|
exists:
|
|
|
|
- '**/package.json'
|
|
|
|
|
|
|
|
phpcs-security-audit-sast:
|
|
|
|
extends: .sast-analyzer
|
|
|
|
image:
|
|
|
|
name: "$SAST_ANALYZER_IMAGE"
|
|
|
|
variables:
|
|
|
|
SAST_ANALYZER_IMAGE_TAG: 3
|
|
|
|
SAST_ANALYZER_IMAGE: "$SECURE_ANALYZERS_PREFIX/phpcs-security-audit:$SAST_ANALYZER_IMAGE_TAG"
|
|
|
|
rules:
|
|
|
|
- if: $SAST_DISABLED
|
|
|
|
when: never
|
|
|
|
- if: $SAST_EXCLUDED_ANALYZERS =~ /phpcs-security-audit/
|
|
|
|
when: never
|
2022-08-27 11:52:29 +05:30
|
|
|
- if: $CI_PIPELINE_SOURCE == "merge_request_event" # Add the job to merge request pipelines if there's an open merge request.
|
2022-07-16 23:28:13 +05:30
|
|
|
exists:
|
|
|
|
- '**/*.php'
|
|
|
|
- if: $CI_OPEN_MERGE_REQUESTS # Don't add it to a *branch* pipeline if it's already in a merge request pipeline.
|
|
|
|
when: never
|
|
|
|
- if: $CI_COMMIT_BRANCH # If there's no open merge request, add it to a *branch* pipeline instead.
|
|
|
|
exists:
|
|
|
|
- '**/*.php'
|
|
|
|
|
|
|
|
pmd-apex-sast:
|
|
|
|
extends: .sast-analyzer
|
|
|
|
image:
|
|
|
|
name: "$SAST_ANALYZER_IMAGE"
|
|
|
|
variables:
|
|
|
|
SAST_ANALYZER_IMAGE_TAG: 3
|
|
|
|
SAST_ANALYZER_IMAGE: "$SECURE_ANALYZERS_PREFIX/pmd-apex:$SAST_ANALYZER_IMAGE_TAG"
|
|
|
|
rules:
|
|
|
|
- if: $SAST_DISABLED
|
|
|
|
when: never
|
|
|
|
- if: $SAST_EXCLUDED_ANALYZERS =~ /pmd-apex/
|
|
|
|
when: never
|
2022-08-27 11:52:29 +05:30
|
|
|
- if: $CI_PIPELINE_SOURCE == "merge_request_event" # Add the job to merge request pipelines if there's an open merge request.
|
2022-07-16 23:28:13 +05:30
|
|
|
exists:
|
|
|
|
- '**/*.cls'
|
|
|
|
- if: $CI_OPEN_MERGE_REQUESTS # Don't add it to a *branch* pipeline if it's already in a merge request pipeline.
|
|
|
|
when: never
|
|
|
|
- if: $CI_COMMIT_BRANCH # If there's no open merge request, add it to a *branch* pipeline instead.
|
|
|
|
exists:
|
|
|
|
- '**/*.cls'
|
|
|
|
|
|
|
|
security-code-scan-sast:
|
|
|
|
extends: .sast-analyzer
|
|
|
|
image:
|
|
|
|
name: "$SAST_ANALYZER_IMAGE"
|
|
|
|
variables:
|
|
|
|
SAST_ANALYZER_IMAGE_TAG: 3
|
|
|
|
SAST_ANALYZER_IMAGE: "$SECURE_ANALYZERS_PREFIX/security-code-scan:$SAST_ANALYZER_IMAGE_TAG"
|
|
|
|
rules:
|
|
|
|
- if: $SAST_DISABLED
|
|
|
|
when: never
|
|
|
|
- if: $SAST_EXCLUDED_ANALYZERS =~ /security-code-scan/
|
|
|
|
when: never
|
2022-08-27 11:52:29 +05:30
|
|
|
- if: $CI_PIPELINE_SOURCE == "merge_request_event" # Add the job to merge request pipelines if there's an open merge request.
|
2022-07-16 23:28:13 +05:30
|
|
|
exists:
|
|
|
|
- '**/*.csproj'
|
|
|
|
- '**/*.vbproj'
|
|
|
|
- if: $CI_OPEN_MERGE_REQUESTS # Don't add it to a *branch* pipeline if it's already in a merge request pipeline.
|
|
|
|
when: never
|
|
|
|
- if: $CI_COMMIT_BRANCH # If there's no open merge request, add it to a *branch* pipeline instead.
|
|
|
|
exists:
|
|
|
|
- '**/*.csproj'
|
|
|
|
- '**/*.vbproj'
|
|
|
|
|
|
|
|
semgrep-sast:
|
|
|
|
extends: .sast-analyzer
|
|
|
|
image:
|
|
|
|
name: "$SAST_ANALYZER_IMAGE"
|
|
|
|
variables:
|
2022-10-11 01:57:18 +05:30
|
|
|
SEARCH_MAX_DEPTH: 20
|
2022-07-16 23:28:13 +05:30
|
|
|
SAST_ANALYZER_IMAGE_TAG: 3
|
|
|
|
SAST_ANALYZER_IMAGE: "$SECURE_ANALYZERS_PREFIX/semgrep:$SAST_ANALYZER_IMAGE_TAG$SAST_IMAGE_SUFFIX"
|
|
|
|
rules:
|
|
|
|
- if: $SAST_DISABLED
|
|
|
|
when: never
|
|
|
|
- if: $SAST_EXCLUDED_ANALYZERS =~ /semgrep/
|
|
|
|
when: never
|
2022-08-27 11:52:29 +05:30
|
|
|
- if: $CI_PIPELINE_SOURCE == "merge_request_event" # Add the job to merge request pipelines if there's an open merge request.
|
2022-07-16 23:28:13 +05:30
|
|
|
exists:
|
|
|
|
- '**/*.py'
|
|
|
|
- '**/*.js'
|
|
|
|
- '**/*.jsx'
|
|
|
|
- '**/*.ts'
|
|
|
|
- '**/*.tsx'
|
|
|
|
- '**/*.c'
|
|
|
|
- '**/*.go'
|
|
|
|
- '**/*.java'
|
2022-10-11 01:57:18 +05:30
|
|
|
- '**/*.html'
|
|
|
|
- '**/*.cs'
|
2022-07-16 23:28:13 +05:30
|
|
|
- if: $CI_OPEN_MERGE_REQUESTS # Don't add it to a *branch* pipeline if it's already in a merge request pipeline.
|
|
|
|
when: never
|
|
|
|
- if: $CI_COMMIT_BRANCH # If there's no open merge request, add it to a *branch* pipeline instead.
|
|
|
|
exists:
|
|
|
|
- '**/*.py'
|
|
|
|
- '**/*.js'
|
|
|
|
- '**/*.jsx'
|
|
|
|
- '**/*.ts'
|
|
|
|
- '**/*.tsx'
|
|
|
|
- '**/*.c'
|
|
|
|
- '**/*.go'
|
|
|
|
- '**/*.java'
|
2022-10-11 01:57:18 +05:30
|
|
|
- '**/*.html'
|
|
|
|
- '**/*.cs'
|
2022-07-16 23:28:13 +05:30
|
|
|
|
|
|
|
sobelow-sast:
|
|
|
|
extends: .sast-analyzer
|
|
|
|
image:
|
|
|
|
name: "$SAST_ANALYZER_IMAGE"
|
|
|
|
variables:
|
|
|
|
SAST_ANALYZER_IMAGE_TAG: 3
|
|
|
|
SAST_ANALYZER_IMAGE: "$SECURE_ANALYZERS_PREFIX/sobelow:$SAST_ANALYZER_IMAGE_TAG"
|
|
|
|
rules:
|
|
|
|
- if: $SAST_DISABLED
|
|
|
|
when: never
|
|
|
|
- if: $SAST_EXCLUDED_ANALYZERS =~ /sobelow/
|
|
|
|
when: never
|
2022-08-27 11:52:29 +05:30
|
|
|
- if: $CI_PIPELINE_SOURCE == "merge_request_event" # Add the job to merge request pipelines if there's an open merge request.
|
2022-07-16 23:28:13 +05:30
|
|
|
exists:
|
|
|
|
- 'mix.exs'
|
|
|
|
- if: $CI_OPEN_MERGE_REQUESTS # Don't add it to a *branch* pipeline if it's already in a merge request pipeline.
|
|
|
|
when: never
|
|
|
|
- if: $CI_COMMIT_BRANCH # If there's no open merge request, add it to a *branch* pipeline instead.
|
|
|
|
exists:
|
|
|
|
- 'mix.exs'
|
|
|
|
|
|
|
|
spotbugs-sast:
|
|
|
|
extends: .sast-analyzer
|
|
|
|
image:
|
|
|
|
name: "$SAST_ANALYZER_IMAGE"
|
|
|
|
variables:
|
|
|
|
SAST_ANALYZER_IMAGE_TAG: 3
|
|
|
|
SAST_ANALYZER_IMAGE: "$SECURE_ANALYZERS_PREFIX/spotbugs:$SAST_ANALYZER_IMAGE_TAG"
|
|
|
|
rules:
|
|
|
|
- if: $SAST_EXCLUDED_ANALYZERS =~ /spotbugs/
|
|
|
|
when: never
|
|
|
|
- if: $SAST_EXPERIMENTAL_FEATURES == 'true'
|
|
|
|
exists:
|
|
|
|
- '**/AndroidManifest.xml'
|
|
|
|
when: never
|
|
|
|
- if: $SAST_DISABLED
|
|
|
|
when: never
|
2022-08-27 11:52:29 +05:30
|
|
|
- if: $CI_PIPELINE_SOURCE == "merge_request_event" # Add the job to merge request pipelines if there's an open merge request.
|
2022-07-16 23:28:13 +05:30
|
|
|
exists:
|
|
|
|
- '**/*.groovy'
|
|
|
|
- '**/*.scala'
|
|
|
|
- '**/*.kt'
|
|
|
|
- if: $CI_OPEN_MERGE_REQUESTS # Don't add it to a *branch* pipeline if it's already in a merge request pipeline.
|
|
|
|
when: never
|
|
|
|
- if: $CI_COMMIT_BRANCH # If there's no open merge request, add it to a *branch* pipeline instead.
|
|
|
|
exists:
|
|
|
|
- '**/*.groovy'
|
|
|
|
- '**/*.scala'
|
|
|
|
- '**/*.kt'
|