[BE] Add the tracked ref to the vulnerability details page data
What does this MR do and why?
Adds the branch or tag a vulnerability is tracked on to the Vulnerability Details page data, so the frontend MR can show it in the page header. It's only included when FF vulnerabilities_across_contexts is on and the user can read tracked refs, the same checks as the API. No visible change.
Changes
- The page data includes the tracked ref's name and whether it's a branch or a tag
- It's left out when the flag is off, the user can't read tracked refs, or the vulnerability has no tracked ref
- Updated the related specs and the frontend fixture
References
- Issue: #629552 (closed). The frontend MR, stacked on this one, closes it.
- Plan: #629552 (comment 4048608043)
Screenshots or screen recordings
n/a. No visible change: this only adds data to the page. The frontend MR shows it in the header, with screenshots.
FE MR: !263709 (merged)
How to set up and validate locally
Nothing changes on the page yet. These steps show the new data.
Prerequisites:
- GDK with advanced search, which the tracked ref filter needs. See Requirements.
Steps:
-
Use a project with SAST in CI and at least one SAST finding. For example, import https://gitlab.com/gl-demo-ultimate-sming/vac-agentic-security-flows/sast-vr.
-
Enable FF
vulnerabilities_across_contexts. -
Create a tag, then track a non-default branch and the tag. See Track an additional context.
-
Run a pipeline on the branch and on the tag.
-
Navigate to the Project > Secure > Vulnerability report, filter by the branch, and open a vulnerability.
-
In the browser console, run this. It reads the page data from the HTML GitLab sends:
JSON.parse( new DOMParser() .parseFromString(await (await fetch(location.href)).text(), 'text/html') .querySelector('#js-vulnerability-main').dataset.vulnerability, ).tracked_refIt returns the ref's
id,name, andref_type: "branch". -
Repeat for a vulnerability on the tag. It returns
ref_type: "tag". -
With the flag off, reload the page and run the command again. It returns
null.
MR acceptance checklist
Evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.