2019-09-17 14:16:34 +00:00
|
|
|
# include:
|
2020-02-13 15:08:52 +00:00
|
|
|
# - template: Jobs/Code-Quality.gitlab-ci.yml
|
2019-09-17 14:16:34 +00:00
|
|
|
# - template: Security/SAST.gitlab-ci.yml
|
|
|
|
# - template: Security/Dependency-Scanning.gitlab-ci.yml
|
|
|
|
# - template: Security/DAST.gitlab-ci.yml
|
2019-04-12 08:56:38 +00:00
|
|
|
|
2019-09-17 14:16:34 +00:00
|
|
|
# We need to duplicate this job's definition because it seems it's impossible to
|
|
|
|
# override an included `only.refs`.
|
|
|
|
# See https://gitlab.com/gitlab-org/gitlab/issues/31371.
|
|
|
|
code_quality:
|
2019-08-26 20:41:55 +00:00
|
|
|
extends:
|
|
|
|
- .default-retry
|
2020-02-13 15:08:52 +00:00
|
|
|
- .reports:rules:code_quality
|
2020-04-08 15:09:29 +00:00
|
|
|
- .use-docker-in-docker
|
2019-09-17 14:16:34 +00:00
|
|
|
stage: test
|
2020-02-20 18:08:51 +00:00
|
|
|
needs: []
|
2019-09-17 14:16:34 +00:00
|
|
|
variables:
|
2020-03-17 00:09:12 +00:00
|
|
|
CODE_QUALITY_IMAGE: "registry.gitlab.com/gitlab-org/ci-cd/codequality:0.85.9"
|
2019-09-17 14:16:34 +00:00
|
|
|
script:
|
|
|
|
- |
|
|
|
|
if ! docker info &>/dev/null; then
|
|
|
|
if [ -z "$DOCKER_HOST" -a "$KUBERNETES_PORT" ]; then
|
|
|
|
export DOCKER_HOST='tcp://localhost:2375'
|
|
|
|
fi
|
|
|
|
fi
|
2019-11-26 12:06:18 +00:00
|
|
|
- docker pull --quiet "$CODE_QUALITY_IMAGE"
|
2019-09-17 14:16:34 +00:00
|
|
|
- docker run
|
|
|
|
--env SOURCE_CODE="$PWD"
|
|
|
|
--volume "$PWD":/code
|
|
|
|
--volume /var/run/docker.sock:/var/run/docker.sock
|
2019-11-26 12:06:18 +00:00
|
|
|
"$CODE_QUALITY_IMAGE" /code
|
2019-09-17 14:16:34 +00:00
|
|
|
artifacts:
|
|
|
|
reports:
|
|
|
|
codequality: gl-code-quality-report.json
|
2019-12-16 15:07:39 +00:00
|
|
|
paths:
|
2020-02-13 15:08:52 +00:00
|
|
|
- gl-code-quality-report.json # GitLab-specific
|
|
|
|
expire_in: 1 week # GitLab-specific
|
2019-04-12 08:56:38 +00:00
|
|
|
|
2019-09-17 14:16:34 +00:00
|
|
|
# We need to duplicate this job's definition because it seems it's impossible to
|
|
|
|
# override an included `only.refs`.
|
|
|
|
# See https://gitlab.com/gitlab-org/gitlab/issues/31371.
|
2020-04-10 09:09:39 +00:00
|
|
|
.sast:
|
2019-09-17 14:16:34 +00:00
|
|
|
extends:
|
|
|
|
- .default-retry
|
2020-02-13 15:08:52 +00:00
|
|
|
- .reports:rules:sast
|
2019-09-17 14:16:34 +00:00
|
|
|
stage: test
|
2020-04-10 09:09:39 +00:00
|
|
|
# `needs: []` starts the job immediately in the pipeline
|
|
|
|
# https://docs.gitlab.com/ee/ci/yaml/README.html#needs
|
2020-02-20 18:08:51 +00:00
|
|
|
needs: []
|
2020-02-13 15:08:52 +00:00
|
|
|
artifacts:
|
|
|
|
paths:
|
|
|
|
- gl-sast-report.json # GitLab-specific
|
|
|
|
reports:
|
|
|
|
sast: gl-sast-report.json
|
|
|
|
expire_in: 1 week # GitLab-specific
|
2019-04-12 08:56:38 +00:00
|
|
|
variables:
|
2020-04-10 09:09:39 +00:00
|
|
|
DOCKER_TLS_CERTDIR: ""
|
|
|
|
SAST_ANALYZER_IMAGE_PREFIX: "registry.gitlab.com/gitlab-org/security-products/analyzers"
|
|
|
|
SAST_ANALYZER_IMAGE_TAG: 2
|
2020-02-13 15:08:52 +00:00
|
|
|
SAST_BRAKEMAN_LEVEL: 2 # GitLab-specific
|
|
|
|
SAST_EXCLUDED_PATHS: qa,spec,doc,ee/spec # GitLab-specific
|
2019-09-17 14:16:34 +00:00
|
|
|
script:
|
2020-04-10 09:09:39 +00:00
|
|
|
- /analyzer run
|
|
|
|
|
|
|
|
brakeman-sast:
|
|
|
|
extends: .sast
|
|
|
|
image:
|
|
|
|
name: "$SAST_ANALYZER_IMAGE_PREFIX/brakeman:$SAST_ANALYZER_IMAGE_TAG"
|
|
|
|
|
|
|
|
eslint-sast:
|
|
|
|
extends: .sast
|
|
|
|
image:
|
|
|
|
name: "$SAST_ANALYZER_IMAGE_PREFIX/eslint:$SAST_ANALYZER_IMAGE_TAG"
|
|
|
|
|
2020-05-07 09:09:51 +00:00
|
|
|
# Temporary disabled as it's constantly failing. See https://gitlab.com/gitlab-org/gitlab/-/issues/213769.
|
|
|
|
# nodejs-scan-sast:
|
|
|
|
# extends: .sast
|
|
|
|
# image:
|
|
|
|
# name: "$SAST_ANALYZER_IMAGE_PREFIX/nodejs-scan:$SAST_ANALYZER_IMAGE_TAG"
|
2020-04-10 09:09:39 +00:00
|
|
|
|
|
|
|
secrets-sast:
|
|
|
|
extends: .sast
|
|
|
|
image:
|
|
|
|
name: "$SAST_ANALYZER_IMAGE_PREFIX/secrets:$SAST_ANALYZER_IMAGE_TAG"
|
2019-04-12 08:56:38 +00:00
|
|
|
|
2019-09-17 14:16:34 +00:00
|
|
|
# We need to duplicate this job's definition because it seems it's impossible to
|
|
|
|
# override an included `only.refs`.
|
|
|
|
# See https://gitlab.com/gitlab-org/gitlab/issues/31371.
|
2019-04-12 08:56:38 +00:00
|
|
|
dependency_scanning:
|
2019-09-17 14:16:34 +00:00
|
|
|
extends:
|
|
|
|
- .default-retry
|
2020-02-13 15:08:52 +00:00
|
|
|
- .reports:rules:dependency_scanning
|
2020-04-08 15:09:29 +00:00
|
|
|
- .use-docker-in-docker
|
2019-09-17 14:16:34 +00:00
|
|
|
stage: test
|
2020-02-20 18:08:51 +00:00
|
|
|
needs: []
|
2019-09-17 14:16:34 +00:00
|
|
|
variables:
|
2020-02-13 15:08:52 +00:00
|
|
|
DS_EXCLUDED_PATHS: "qa/qa/ee/fixtures/secure_premade_reports,spec,ee/spec" # GitLab-specific
|
2019-09-17 14:16:34 +00:00
|
|
|
script:
|
|
|
|
- export DS_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
|
|
|
|
- | # this is required to avoid undesirable reset of Docker image ENV variables being set on build stage
|
|
|
|
function propagate_env_vars() {
|
|
|
|
CURRENT_ENV=$(printenv)
|
2019-08-20 17:04:23 +00:00
|
|
|
|
2019-09-17 14:16:34 +00:00
|
|
|
for VAR_NAME; do
|
|
|
|
echo $CURRENT_ENV | grep "${VAR_NAME}=" > /dev/null && echo "--env $VAR_NAME "
|
|
|
|
done
|
|
|
|
}
|
|
|
|
- |
|
|
|
|
docker run \
|
|
|
|
$(propagate_env_vars \
|
|
|
|
DS_ANALYZER_IMAGES \
|
|
|
|
DS_ANALYZER_IMAGE_PREFIX \
|
|
|
|
DS_ANALYZER_IMAGE_TAG \
|
|
|
|
DS_DEFAULT_ANALYZERS \
|
|
|
|
DS_EXCLUDED_PATHS \
|
|
|
|
DS_DOCKER_CLIENT_NEGOTIATION_TIMEOUT \
|
|
|
|
DS_PULL_ANALYZER_IMAGE_TIMEOUT \
|
|
|
|
DS_RUN_ANALYZER_TIMEOUT \
|
|
|
|
DS_PYTHON_VERSION \
|
2020-02-13 15:08:52 +00:00
|
|
|
DS_PIP_VERSION \
|
2019-09-17 14:16:34 +00:00
|
|
|
DS_PIP_DEPENDENCY_PATH \
|
2020-02-13 15:08:52 +00:00
|
|
|
GEMNASIUM_DB_LOCAL_PATH \
|
|
|
|
GEMNASIUM_DB_REMOTE_URL \
|
|
|
|
GEMNASIUM_DB_REF_NAME \
|
2019-09-17 14:16:34 +00:00
|
|
|
PIP_INDEX_URL \
|
|
|
|
PIP_EXTRA_INDEX_URL \
|
2020-02-13 15:08:52 +00:00
|
|
|
PIP_REQUIREMENTS_FILE \
|
|
|
|
MAVEN_CLI_OPTS \
|
|
|
|
BUNDLER_AUDIT_UPDATE_DISABLED \
|
|
|
|
BUNDLER_AUDIT_ADVISORY_DB_URL \
|
|
|
|
BUNDLER_AUDIT_ADVISORY_DB_REF_NAME \
|
2019-09-17 14:16:34 +00:00
|
|
|
) \
|
|
|
|
--volume "$PWD:/code" \
|
|
|
|
--volume /var/run/docker.sock:/var/run/docker.sock \
|
|
|
|
"registry.gitlab.com/gitlab-org/security-products/dependency-scanning:$DS_VERSION" /code
|
|
|
|
artifacts:
|
2020-02-13 15:08:52 +00:00
|
|
|
paths:
|
|
|
|
- gl-dependency-scanning-report.json # GitLab-specific
|
2019-09-17 14:16:34 +00:00
|
|
|
reports:
|
|
|
|
dependency_scanning: gl-dependency-scanning-report.json
|
2020-02-13 15:08:52 +00:00
|
|
|
expire_in: 1 week # GitLab-specific
|
2019-09-17 14:16:34 +00:00
|
|
|
|
|
|
|
# We need to duplicate this job's definition because it seems it's impossible to
|
|
|
|
# override an included `only.refs`.
|
|
|
|
# See https://gitlab.com/gitlab-org/gitlab/issues/31371.
|
2019-08-20 17:04:23 +00:00
|
|
|
dast:
|
2019-08-28 16:11:32 +00:00
|
|
|
extends:
|
2019-09-17 14:16:34 +00:00
|
|
|
- .default-retry
|
2020-02-13 15:08:52 +00:00
|
|
|
- .reports:rules:dast
|
2020-03-20 00:09:29 +00:00
|
|
|
# This is needed so that manual jobs with needs don't block the pipeline.
|
|
|
|
# See https://gitlab.com/gitlab-org/gitlab/-/issues/199979.
|
|
|
|
dependencies: ["review-deploy"]
|
2020-02-13 15:08:52 +00:00
|
|
|
stage: qa # GitLab-specific
|
2019-09-17 14:16:34 +00:00
|
|
|
image:
|
2020-02-13 15:08:52 +00:00
|
|
|
name: "registry.gitlab.com/gitlab-org/security-products/dast:$DAST_VERSION"
|
2019-09-17 14:16:34 +00:00
|
|
|
variables:
|
2020-02-13 15:08:52 +00:00
|
|
|
# To be done in a later iteration
|
|
|
|
# DAST_USERNAME: "root"
|
|
|
|
# DAST_USERNAME_FIELD: "user[login]"
|
|
|
|
# DAST_PASSWORD_FIELD: "user[passowrd]"
|
2020-02-21 09:09:01 +00:00
|
|
|
DAST_VERSION: 1
|
2019-09-17 14:16:34 +00:00
|
|
|
script:
|
2020-02-13 15:08:52 +00:00
|
|
|
- 'export DAST_WEBSITE="${DAST_WEBSITE:-$(cat environment_url.txt)}"'
|
|
|
|
# To be done in a later iteration
|
|
|
|
# - 'export DAST_AUTH_URL="${DAST_WEBSITE}/users/sign_in"'
|
|
|
|
# - 'export DAST_PASSWORD="${REVIEW_APPS_ROOT_PASSWORD}"'
|
2019-09-17 14:16:34 +00:00
|
|
|
- /analyze -t $DAST_WEBSITE
|
2019-08-26 15:21:35 +00:00
|
|
|
artifacts:
|
|
|
|
paths:
|
2020-02-13 15:08:52 +00:00
|
|
|
- gl-dast-report.json # GitLab-specific
|
2019-09-17 14:16:34 +00:00
|
|
|
reports:
|
|
|
|
dast: gl-dast-report.json
|
2020-02-13 15:08:52 +00:00
|
|
|
expire_in: 1 week # GitLab-specific
|
|
|
|
|
|
|
|
# To be done in a later iteration: https://gitlab.com/gitlab-org/gitlab/issues/31160#note_278188255
|
|
|
|
# schedule:dast:
|
2020-02-18 15:08:51 +00:00
|
|
|
# extends:
|
|
|
|
# - dast
|
|
|
|
# - .reports:schedule-dast
|
2020-02-13 15:08:52 +00:00
|
|
|
# variables:
|
|
|
|
# DAST_FULL_SCAN_ENABLED: "true"
|