Vulnerability MR comparison logic should prioritize appropriate branch when rendering vulnerability data
Summary
When rendering data within the MR widget we should be prioritizing specific branches depending on the vulnerability type.
To quote @gonzoyumo
...The comparison logic should take that into account.
- fixed vulns should point to base tree
- new vulns should point to source tree
- existing vulns should point to source tree (base could work too, but due to some code updates coming with the MR, I think it’s more relevant to point to source tree)
Steps to reproduce
- Add vulnerabilities at a specific path
- Open an MR changing the path of the vulnerabilities (currently this must be done in a way that doesn't change the primary identifiers, so they are considered "sibling" vulnerabilities**)
** It's unclear to me if there's a real world scenario where this could occur yet, but worth considering
Example Project
See MR widget mis-rendering filepaths (resulting in 404s) gitlab-examples/security/security-reports!2 (closed)
However the pipeline view properly renders the paths as it is using the source branch vulnerabilities, not prioritizing the base branch's https://gitlab.com/gitlab-examples/security/security-reports/pipelines/84427114/security/?project_id=6102100&page=1&days=90
What is the current bug behavior?
Existing vulnerabilities are render vuln data from the base pipeline, not source pipeline
What is the expected correct behavior?
Existing vulnerabilities should render vuln data from the source pipeline, not base pipeline
Relevant logs and/or screenshots
Output of checks
This bug happens on GitLab.com
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
(If you can, link to the line of code that might be responsible for the problem)