Set vulnerability_occurrence_id during sbom_occurrences_vulnerabilities ingestion
Summary
Update the SBOM ingestion to populate vulnerability_occurrence_id when creating sbom_occurrences_vulnerabilities records.
Background
The vulnerability_occurrence_id column was added to sbom_occurrences_vulnerabilities as part of the Vulnerabilities Across Contexts initiative, but the ingestion code was never updated to populate it. This was noted in !213084 (merged) which excluded this table from the backfill with the comment "We are not setting this ID during ingestion yet."
This gap was identified by @schmil.monderer while reviewing !225631 (merged) (ES preloaders using occurrence_id).
Current State
The Sbom::Ingestion::Tasks::IngestOccurrencesVulnerabilities task only sets:
sbom_occurrence_idvulnerability_id
It does not set vulnerability_occurrence_id.
Proposed Solution
Update IngestOccurrencesVulnerabilities#ingested_links to include vulnerability_occurrence_id:
def ingested_links
insertable_maps.flat_map do |occurrence_map|
occurrence_map.vulnerability_ids.map do |vulnerability_id|
{
sbom_occurrence_id: occurrence_map.occurrence_id,
vulnerability_id: vulnerability_id,
vulnerability_occurrence_id: occurrence_map.finding_id
}
end
end
endThis requires the occurrence_map to have access to the finding_id. The exact implementation depends on how finding information flows through the SBOM ingestion pipeline.
Acceptance Criteria
-
IngestOccurrencesVulnerabilitiessetsvulnerability_occurrence_idfor new records - Tests verify the column is populated correctly
- Works for both dependency scanning and container scanning SBOM reports
Related
- #589839 - Consistency check to backfill existing records
- !213084 (merged) - Original backfill MR that excluded this table
- !225631 (merged) - ES preloaders MR where gap was discovered
- Parent epic: &18653