Resolve "Ensure vulnerability creation from Security Findings/API associates records with vulnerability tracked context"

What does this MR do and why?

This code change adds tracking context to vulnerability_finding and vulnerbility_reads entries when vulnerability are created in the following scenarions:

  • Security finding operations:
    • Issue creation
    • Merge request creation
    • Link to an external issue
    • Dismissal
  • Vulnerability created via API/Graphql

If no tracking context exist for the requested reference (branch or tag) a new context is created

References

How to set up and validate locally

  1. In rails console enable feature flag

    Feature.enable(:vulnerabilities_across_contexts)
  2. Import project with vulnerabilities (e.g: https://gitlab.com/gitlab-examples/security/security-reports)

  3. Create branch

  4. Run pipeline on new branch

  5. Select a security finding in the pipeline>security tab

  6. Create issue for the security finding

  7. In rails console check that track context has been created for the branch with attributes {is_default: false, context_type: branch, state: 1, context_name: BRANCH_NAME }

    Security::ProjectTrackedContext.all

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.

Related to #582039

Edited by Schmil Monderer

Merge request reports

Loading