Add context-aware UUID generation for vulnerability findings
What does this MR do and why?
Implements Phase 1 of the Finding UUID migration to support vulnerabilities across contexts (#587625 (closed)).
This adds context-aware UUID generation for Vulnerabilities::Finding that includes the security_project_tracked_context_id, enabling unique identification of findings per branch/tag context.
Changes
- Add
Security::VulnerabilityUUID.generate_v2method that accepts an optionalcontext_idparameter - Update
Security::Ingestion::FindingMap#to_hashto populatenew_uuidwith context-aware UUID - Update
Security::VulnerabilityScanning::FindingMapwith the same changes - Add comprehensive tests for the new UUID generation
How does it work?
The new_uuid column is populated during ingestion when a tracked context exists (guaranteed for default branch pipelines via FindOrCreateService). The UUID is generated using:
- Report type
- Primary identifier fingerprint
- Location fingerprint
- Project ID
- Context ID (tracked context)
When there's no tracked context, new_uuid remains NULL for backward compatibility.
Migration Plan
This is Phase 1 of a 5-phase migration:
-
This MR - Start populating
new_uuidfor new findings -
#587798 - Backfill
new_uuidfor existing findings - #587799 - Add NOT NULL constraint
-
#587800 - Transition GitLab to use
new_uuid -
#587801 - Drop old
uuidcolumn and renamenew_uuid
MR acceptance checklist
Please evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.
Closes #587625 (closed)