Commit 87707291 authored by Lin Jen-Shin's avatar Lin Jen-Shin

Merge branch 'narrow-down-sast-rules' into 'master'

ci: Update report jobs with latest from templates and run upon changes

See merge request gitlab-org/gitlab!71457
parents 9b37811e 2074baed
...@@ -37,6 +37,7 @@ ...@@ -37,6 +37,7 @@
reports: reports:
dast: gl-dast-report.json dast: gl-dast-report.json
expire_in: 1 week # GitLab-specific expire_in: 1 week # GitLab-specific
allow_failure: true
# DAST scan with a subset of Release scan rules. # DAST scan with a subset of Release scan rules.
# ZAP rule details can be found at https://www.zaproxy.org/docs/alerts/ # ZAP rule details can be found at https://www.zaproxy.org/docs/alerts/
......
include: include:
- template: Jobs/Code-Quality.gitlab-ci.yml - template: Jobs/Code-Quality.gitlab-ci.yml
- template: Security/SAST.gitlab-ci.yml - template: Jobs/SAST.gitlab-ci.yml
- template: Security/Secret-Detection.gitlab-ci.yml - template: Jobs/Secret-Detection.gitlab-ci.yml
- template: Security/Dependency-Scanning.gitlab-ci.yml - template: Security/Dependency-Scanning.gitlab-ci.yml
- template: Security/License-Scanning.gitlab-ci.yml - template: Security/License-Scanning.gitlab-ci.yml
...@@ -13,6 +13,7 @@ code_quality: ...@@ -13,6 +13,7 @@ code_quality:
paths: paths:
- gl-code-quality-report.json # GitLab-specific - gl-code-quality-report.json # GitLab-specific
rules: !reference [".reports:rules:code_quality", rules] rules: !reference [".reports:rules:code_quality", rules]
allow_failure: true
.sast-analyzer: .sast-analyzer:
# We need to re-`extends` from `sast` as the `extends` here overrides the one from the template. # We need to re-`extends` from `sast` as the `extends` here overrides the one from the template.
...@@ -30,13 +31,16 @@ code_quality: ...@@ -30,13 +31,16 @@ code_quality:
SAST_EXCLUDED_ANALYZERS: bandit, flawfinder, phpcs-security-audit, pmd-apex, security-code-scan, spotbugs, eslint SAST_EXCLUDED_ANALYZERS: bandit, flawfinder, phpcs-security-audit, pmd-apex, security-code-scan, spotbugs, eslint
brakeman-sast: brakeman-sast:
rules: !reference [".reports:rules:sast", rules] rules: !reference [".reports:rules:brakeman-sast", rules]
allow_failure: true
nodejs-scan-sast: nodejs-scan-sast:
rules: !reference [".reports:rules:sast", rules] rules: !reference [".reports:rules:nodejs-scan-sast", rules]
allow_failure: true
semgrep-sast: semgrep-sast:
rules: !reference [".reports:rules:sast", rules] rules: !reference [".reports:rules:semgrep-sast", rules]
allow_failure: true
gosec-sast: gosec-sast:
variables: variables:
...@@ -52,7 +56,8 @@ gosec-sast: ...@@ -52,7 +56,8 @@ gosec-sast:
cache: cache:
paths: paths:
- vendor/go - vendor/go
rules: !reference [".reports:rules:sast", rules] rules: !reference [".reports:rules:gosec-sast", rules]
allow_failure: true
.secret-analyzer: .secret-analyzer:
extends: .default-retry extends: .default-retry
...@@ -64,6 +69,7 @@ gosec-sast: ...@@ -64,6 +69,7 @@ gosec-sast:
secret_detection: secret_detection:
rules: !reference [".reports:rules:secret_detection", rules] rules: !reference [".reports:rules:secret_detection", rules]
allow_failure: true
.ds-analyzer: .ds-analyzer:
# We need to re-`extends` from `dependency_scanning` as the `extends` here overrides the one from the template. # We need to re-`extends` from `dependency_scanning` as the `extends` here overrides the one from the template.
...@@ -88,21 +94,24 @@ gemnasium-dependency_scanning: ...@@ -88,21 +94,24 @@ gemnasium-dependency_scanning:
# Lower execa severity based on https://gitlab.com/gitlab-org/gitlab/-/issues/223859#note_452922390 # Lower execa severity based on https://gitlab.com/gitlab-org/gitlab/-/issues/223859#note_452922390
- jq '(.vulnerabilities[] | select (.cve == "yarn.lock:execa:gemnasium:05cfa2e8-2d0c-42c1-8894-638e2f12ff3d")).severity = "Medium"' gl-dependency-scanning-report.json > temp.json && mv temp.json gl-dependency-scanning-report.json - jq '(.vulnerabilities[] | select (.cve == "yarn.lock:execa:gemnasium:05cfa2e8-2d0c-42c1-8894-638e2f12ff3d")).severity = "Medium"' gl-dependency-scanning-report.json > temp.json && mv temp.json gl-dependency-scanning-report.json
rules: !reference [".reports:rules:gemnasium-dependency_scanning", rules] rules: !reference [".reports:rules:gemnasium-dependency_scanning", rules]
allow_failure: true
bundler-audit-dependency_scanning: bundler-audit-dependency_scanning:
rules: !reference [".reports:rules:bundler-audit-dependency_scanning", rules] rules: !reference [".reports:rules:bundler-audit-dependency_scanning", rules]
allow_failure: true
retire-js-dependency_scanning: retire-js-dependency_scanning:
rules: !reference [".reports:rules:retire-js-dependency_scanning", rules] rules: !reference [".reports:rules:retire-js-dependency_scanning", rules]
allow_failure: true
gemnasium-python-dependency_scanning: gemnasium-python-dependency_scanning:
rules: !reference [".reports:rules:gemnasium-python-dependency_scanning", rules] rules: !reference [".reports:rules:gemnasium-python-dependency_scanning", rules]
allow_failure: true
# Analyze dependencies for malicious behavior # Analyze dependencies for malicious behavior
# See https://gitlab.com/gitlab-com/gl-security/security-research/package-hunter # See https://gitlab.com/gitlab-com/gl-security/security-research/package-hunter
.package_hunter-base: .package_hunter-base:
extends: extends: .default-retry
- .default-retry
stage: test stage: test
image: image:
name: registry.gitlab.com/gitlab-com/gl-security/security-research/package-hunter-cli:1.1.0 name: registry.gitlab.com/gitlab-com/gl-security/security-research/package-hunter-cli:1.1.0
...@@ -116,6 +125,8 @@ gemnasium-python-dependency_scanning: ...@@ -116,6 +125,8 @@ gemnasium-python-dependency_scanning:
before_script: before_script:
- rm -r spec locale .git app/assets/images doc/ - rm -r spec locale .git app/assets/images doc/
- cd .. && tar -I "gzip --best" -cf gitlab.tgz gitlab/ - cd .. && tar -I "gzip --best" -cf gitlab.tgz gitlab/
script:
- node /usr/src/app/cli.js analyze --format gitlab --manager ${PACKAGE_MANAGER} gitlab.tgz | tee ${CI_PROJECT_DIR}/gl-dependency-scanning-report.json
artifacts: artifacts:
paths: paths:
- gl-dependency-scanning-report.json - gl-dependency-scanning-report.json
...@@ -127,15 +138,15 @@ package_hunter-yarn: ...@@ -127,15 +138,15 @@ package_hunter-yarn:
extends: extends:
- .package_hunter-base - .package_hunter-base
- .reports:rules:package_hunter-yarn - .reports:rules:package_hunter-yarn
script: variables:
- node /usr/src/app/cli.js analyze --format gitlab --manager yarn gitlab.tgz | tee $CI_PROJECT_DIR/gl-dependency-scanning-report.json PACKAGE_MANAGER: yarn
package_hunter-bundler: package_hunter-bundler:
extends: extends:
- .package_hunter-base - .package_hunter-base
- .reports:rules:package_hunter-bundler - .reports:rules:package_hunter-bundler
script: variables:
- node /usr/src/app/cli.js analyze --format gitlab --manager bundler gitlab.tgz | tee $CI_PROJECT_DIR/gl-dependency-scanning-report.json PACKAGE_MANAGER: bundler
license_scanning: license_scanning:
extends: .default-retry extends: .default-retry
...@@ -143,3 +154,4 @@ license_scanning: ...@@ -143,3 +154,4 @@ license_scanning:
artifacts: artifacts:
expire_in: 1 week # GitLab-specific expire_in: 1 week # GitLab-specific
rules: !reference [".reports:rules:license_scanning", rules] rules: !reference [".reports:rules:license_scanning", rules]
allow_failure: true
...@@ -1254,75 +1254,85 @@ ...@@ -1254,75 +1254,85 @@
when: never when: never
- <<: *if-default-refs - <<: *if-default-refs
changes: *code-backstage-patterns changes: *code-backstage-patterns
allow_failure: true
.reports:rules:sast: .reports:rules:brakeman-sast:
rules: rules:
- if: '$SAST_DISABLED || $GITLAB_FEATURES !~ /\bsast\b/' - if: $SAST_DISABLED
when: never when: never
- <<: *if-default-refs - if: $SAST_EXCLUDED_ANALYZERS =~ /brakeman/
changes: *code-backstage-qa-patterns when: never
allow_failure: true - changes:
- '**/*.rb'
- '**/Gemfile'
.reports:rules:nodejs-scan-sast:
rules:
- if: $SAST_DISABLED
when: never
- if: $SAST_EXCLUDED_ANALYZERS =~ /nodejs-scan/
when: never
- changes:
- '**/package.json'
.reports:rules:gosec-sast:
rules:
- if: $SAST_DISABLED
when: never
- if: $SAST_EXCLUDED_ANALYZERS =~ /gosec/
when: never
- changes:
- '**/*.go'
.reports:rules:semgrep-sast:
rules:
- if: $SAST_DISABLED
when: never
- if: $SAST_EXCLUDED_ANALYZERS =~ /semgrep/
when: never
- changes:
- '**/*.py'
- '**/*.js'
- '**/*.jsx'
- '**/*.ts'
- '**/*.tsx'
- '**/*.c'
- '**/*.go'
.reports:rules:secret_detection: .reports:rules:secret_detection:
rules: rules:
- if: '$SECRET_DETECTION_DISABLED' - if: '$SECRET_DETECTION_DISABLED'
when: never when: never
- if: '$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH' # The Secret-Detection template already has a `secret_detection_default_branch` job
when: never
- changes: *code-backstage-qa-patterns - changes: *code-backstage-qa-patterns
allow_failure: true
.reports:rules:gemnasium-dependency_scanning: .reports:rules:gemnasium-dependency_scanning:
rules: rules:
- if: '$DEPENDENCY_SCANNING_DISABLED || $GITLAB_FEATURES !~ /\bdependency_scanning\b/ || $DS_EXCLUDED_ANALYZERS =~ /gemnasium([^-]|$)/' - if: '$DEPENDENCY_SCANNING_DISABLED || $GITLAB_FEATURES !~ /\bdependency_scanning\b/ || $DS_EXCLUDED_ANALYZERS =~ /gemnasium([^-]|$)/ || $DS_DEFAULT_ANALYZERS !~ /gemnasium([^-]|$)/'
when: never when: never
- <<: *if-default-refs - changes: *dependency-patterns
changes: *dependency-patterns
allow_failure: true
.reports:rules:bundler-audit-dependency_scanning: .reports:rules:bundler-audit-dependency_scanning:
rules: rules:
- if: '$DEPENDENCY_SCANNING_DISABLED || $GITLAB_FEATURES !~ /\bdependency_scanning\b/ || $DS_EXCLUDED_ANALYZERS =~ /bundler-audit/' - if: '$DEPENDENCY_SCANNING_DISABLED || $GITLAB_FEATURES !~ /\bdependency_scanning\b/ || $DS_EXCLUDED_ANALYZERS =~ /bundler-audit/ || $DS_DEFAULT_ANALYZERS !~ /bundler-audit/'
when: never when: never
- <<: *if-default-refs - changes: *bundler-patterns
changes: *bundler-patterns
allow_failure: true
.reports:rules:retire-js-dependency_scanning: .reports:rules:retire-js-dependency_scanning:
rules: rules:
- if: '$DEPENDENCY_SCANNING_DISABLED || $GITLAB_FEATURES !~ /\bdependency_scanning\b/ || $DS_EXCLUDED_ANALYZERS =~ /retire.js/' - if: '$DEPENDENCY_SCANNING_DISABLED || $GITLAB_FEATURES !~ /\bdependency_scanning\b/ || $DS_EXCLUDED_ANALYZERS =~ /retire.js/ || $DS_DEFAULT_ANALYZERS !~ /retire.js/'
when: never when: never
- <<: *if-default-refs - changes: *nodejs-patterns
changes: *nodejs-patterns
allow_failure: true
.reports:rules:gemnasium-python-dependency_scanning: .reports:rules:gemnasium-python-dependency_scanning:
rules: rules:
- if: '$DEPENDENCY_SCANNING_DISABLED || $GITLAB_FEATURES !~ /\bdependency_scanning\b/ || $DS_EXCLUDED_ANALYZERS =~ /gemnasium-python/' - if: '$DEPENDENCY_SCANNING_DISABLED || $GITLAB_FEATURES !~ /\bdependency_scanning\b/ || $DS_EXCLUDED_ANALYZERS =~ /gemnasium-python/ || $DS_DEFAULT_ANALYZERS !~ /gemnasium-python/'
when: never when: never
- <<: *if-default-refs - changes: *python-patterns
changes: *python-patterns
allow_failure: true
.reports:rules:dast:
rules:
- if: '$DAST_DISABLED || $GITLAB_FEATURES !~ /\bdast\b/'
when: never
- <<: *if-dot-com-gitlab-org-merge-request
changes: *frontend-patterns
allow_failure: true
- <<: *if-dot-com-gitlab-org-merge-request
changes: *code-qa-patterns
when: manual
allow_failure: true
.reports:rules:schedule-dast: .reports:rules:schedule-dast:
rules: rules:
- if: '$DAST_DISABLED || $GITLAB_FEATURES !~ /\bdast\b/' - if: '$DAST_DISABLED || $GITLAB_FEATURES !~ /\bdast\b/'
when: never when: never
- <<: *if-dot-com-ee-nightly-schedule - <<: *if-dot-com-ee-nightly-schedule
allow_failure: true
.reports:rules:package_hunter-yarn: .reports:rules:package_hunter-yarn:
rules: rules:
...@@ -1342,11 +1352,9 @@ ...@@ -1342,11 +1352,9 @@
.reports:rules:license_scanning: .reports:rules:license_scanning:
rules: rules:
- if: '$LICENSE_SCANNING_DISABLED || $GITLAB_FEATURES !~ /\blicense_scanning\b/' - if: '$LICENSE_MANAGEMENT_DISABLED || $GITLAB_FEATURES !~ /\blicense_scanning\b/'
when: never when: never
- <<: *if-default-refs - changes: *code-backstage-qa-patterns
changes: *code-backstage-qa-patterns
allow_failure: true
################ ################
# Review rules # # Review rules #
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment