[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

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:

  1. 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.

  2. Enable FF vulnerabilities_across_contexts.

  3. Create a tag, then track a non-default branch and the tag. See Track an additional context.

  4. Run a pipeline on the branch and on the tag.

  5. Navigate to the Project > Secure > Vulnerability report, filter by the branch, and open a vulnerability.

  6. 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_ref

    It returns the ref's id, name, and ref_type: "branch".

  7. Repeat for a vulnerability on the tag. It returns ref_type: "tag".

  8. 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.

Edited by Samantha Ming

Merge request reports

Loading
Loading