summaryrefslogtreecommitdiff
path: root/lib/gitlab/ci/templates/Security/DAST.gitlab-ci.yml
blob: 4e708f229cde8cbd40b1fba043ffb2b218a48ec3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# Read more about this feature here: https://docs.gitlab.com/ee/user/project/merge_requests/dast.html

# Configure the scanning tool through the environment variables.
# List of the variables: https://gitlab.com/gitlab-org/security-products/dast#settings
# How to set: https://docs.gitlab.com/ee/ci/yaml/#variables

variables:
  DAST_WEBSITE: http://example.com # Please edit to be your website to scan for vulnerabilities

stages:
  - build
  - test
  - deploy
  - dast

dast:
  stage: dast
  image: docker:stable
  variables:
    DOCKER_DRIVER: overlay2
  allow_failure: true
  services:
    - docker:stable-dind
  before_script:
    - export DAST_VERSION=${SP_VERSION:-$(echo "$CI_SERVER_VERSION" | sed 's/^\([0-9]*\)\.\([0-9]*\).*/\1-\2-stable/')}
    - |
      function dast_run() {
        docker run \
          --env DAST_TARGET_AVAILABILITY_TIMEOUT \
          --volume "$PWD:/output" \
          --volume /var/run/docker.sock:/var/run/docker.sock \
          -w /output \
          "registry.gitlab.com/gitlab-org/security-products/dast:$DAST_VERSION" \
          /analyze -t $DAST_WEBSITE \
          "$@"
      }
  script:
    - |
      if [ -n "$DAST_AUTH_URL" ]
      then
        dast_run \
          --auth-url $DAST_AUTH_URL \
          --auth-username $DAST_USERNAME \
          --auth-password $DAST_PASSWORD \
          --auth-username-field $DAST_USERNAME_FIELD \
          --auth-password-field $DAST_PASSWORD_FIELD
      else
        dast_run
      fi
  artifacts:
    reports:
      dast: gl-dast-report.json
  only:
    refs:
      - branches
    variables:
      - $GITLAB_FEATURES =~ /\bdast\b/
  except:
    variables:
      - $DAST_DISABLED