Skip to content

Pipeline Security Report: Generic security report items of type `commit` construct incorrect link when gitlab instance is under a relative URL

Summary

When a gitlab instance is installed under a relative url any generic security report item will construct an incorrect link:

Screen_Shot_2021-06-21_at_4.10.40_pm

The link does not include the relative URL which the instance has been set up with.

Note: This only happens on the pipeline's security tab and does not affect the vulnerability details page.

Steps to reproduce

  1. Follow these instructions to run a local instance with a relative URL: https://docs.gitlab.com/ee/install/relative_url.html#enable-relative-url-in-gitlab
  2. Create a new project
  3. Add a .gitlab-ci.yml file with the following contents:
stages:
    - dast

dast:
  stage: dast 
  image: alpine:3.10.2
  script:
    - pwd
  artifacts:
    reports:
      dast: dast.json
  1. Add a new file dast.json with the contents from: $2136483
  2. Run a pipeline
  3. Go to the pipeline's result and click the "security" tab

Example Project

What is the current bug behavior?

The constructed URL will not include the defined relative URL and will link to a non-existing URL.

What is the expected correct behavior?

It should correctly link to the given commit.

Relevant logs and/or screenshots

Output of checks

Results of GitLab environment info

Expand for output related to GitLab environment info

(For installations with omnibus-gitlab package run and paste the output of:
`sudo gitlab-rake gitlab:env:info`)

(For installations from source run and paste the output of:
`sudo -u git -H bundle exec rake gitlab:env:info RAILS_ENV=production`)

Results of GitLab application Check

Expand for output related to the GitLab application check

(For installations with omnibus-gitlab package run and paste the output of: sudo gitlab-rake gitlab:check SANITIZE=true)

(For installations from source run and paste the output of: sudo -u git -H bundle exec rake gitlab:check RAILS_ENV=production SANITIZE=true)

(we will only investigate if the tests are passing)

Possible fixes

POC commit that adds a separate URL coming from the backend, which can safely be used for both the pipeline- and vulnerability details view: f15069d2

Edited by David Pisek