Skip to content

Fix Errno::ENOENT issue in RunDastScanService on production

Philip Cunningham requested to merge fix-issue-opening-ci-template-228754 into master

What does this MR do?

switches RunDastScanService over to use Gitlab::Template::GitlabCiYmlTemplate because, even though the tests that exercise this functionality passed, it can't find the file on production. given other files use this (1, 2), i'm going to assume that this is the preferred way to access these files.

Console Output

based on my experiments in the staging console, i am admittedly unsure as to why this doesn't work as-is but i don't think the change i've proposed here makes things any worse, so would appreciate being able to deploy to staging in order to test the hypothesis.

[ gstg ] production> Ci::RunDastScanService.ci_template
=> {"stages"=>["dast"], "variables"=>{"DAST_VERSION"=>1, "SECURE_ANALYZERS_PREFIX"=>"registry.gitlab.com/gitlab-org/security-products/analyzers"}, "dast"=>{"stage"=>"dast", "image"=>{"name"=>"$SECURE_ANALYZERS_PREFIX/dast:$DAST_VERSION"}, "variables"=>{"GIT_STRATEGY"=>"none"}, "allow_failure"=>true, "script"=>["export DAST_WEBSITE=${DAST_WEBSITE:-$(cat environment_url.txt)}", "if [ -z \"$DAST_WEBSITE$DAST_API_SPECIFICATION\" ]; then echo \"Either DAST_WEBSITE or DAST_API_SPECIFICATION must be set. See https://docs.gitlab.com/ee/user/application_security/dast/#configuration for more details.\" && exit 1; fi", "/analyze"], "artifacts"=>{"reports"=>{"dast"=>"gl-dast-report.json"}}}}

[ gstg ] production> Gitlab::Template::GitlabCiYmlTemplate.find('DAST').content
=> "# This file is a template, and might need editing before it works on your project.\n# Read more about this feature here: https://docs.gitlab.com/ee/user/application_security/dast/\n\n# Configure the scanning tool through the environment variables.\n# List of the variables: https://docs.gitlab.com/ee/user/application_security/dast/#available-variables\n# How to set: https://docs.gitlab.com/ee/ci/yaml/#variables\n\nstages:\n  - build\n  - test\n  - deploy\n  - dast\n\nvariables:\n  DAST_VERSION: 1\n  # Setting this variable will affect all Security templates\n  # (SAST, Dependency Scanning, ...)\n  SECURE_ANALYZERS_PREFIX: \"registry.gitlab.com/gitlab-org/security-products/analyzers\"\n\ndast:\n  stage: dast\n  image:\n    name: \"$SECURE_ANALYZERS_PREFIX/dast:$DAST_VERSION\"\n  variables:\n    GIT_STRATEGY: none\n  allow_failure: true\n  script:\n    - export DAST_WEBSITE=${DAST_WEBSITE:-$(cat environment_url.txt)}\n    - if [ -z \"$DAST_WEBSITE$DAST_API_SPECIFICATION\" ]; then echo \"Either DAST_WEBSITE or DAST_API_SPECIFICATION must be set. See https://docs.gitlab.com/ee/user/application_security/dast/#configuration for more details.\" && exit 1; fi\n    - /analyze\n  artifacts:\n    reports:\n      dast: gl-dast-report.json\n  rules:\n    - if: $DAST_DISABLED\n      when: never\n    - if: $DAST_DISABLED_FOR_DEFAULT_BRANCH &&\n          $CI_DEFAULT_BRANCH == $CI_COMMIT_REF_NAME\n      when: never\n    - if: $CI_DEFAULT_BRANCH != $CI_COMMIT_REF_NAME &&\n          $REVIEW_DISABLED && $DAST_WEBSITE == null &&\n          $DAST_API_SPECIFICATION == null\n      when: never\n    - if: $CI_COMMIT_BRANCH &&\n          $CI_KUBERNETES_ACTIVE &&\n          $GITLAB_FEATURES =~ /\\bdast\\b/\n    - if: $CI_COMMIT_BRANCH &&\n          $GITLAB_FEATURES =~ /\\bdast\\b/ &&\n          $DAST_WEBSITE\n    - if: $CI_COMMIT_BRANCH &&\n          $GITLAB_FEATURES =~ /\\bdast\\b/ &&\n          $DAST_API_SPECIFICATION\n"
[ gstg ] production>

Related Issues

#228754 (closed)

Does this MR meet the acceptance criteria?

Conformity

Availability and Testing

Security

If this MR contains changes to processing or storing of credentials or tokens, authorization and authentication methods and other items described in the security review guidelines:

  • [-] Label as security and @ mention @gitlab-com/gl-security/appsec
  • [-] The MR includes necessary changes to maintain consistency between UI, API, email, or other methods
  • [-] Security reports checked/validated by a reviewer from the AppSec team
Edited by Peter Leitzen

Merge request reports

Loading