BE: Cron job to automatically refresh MR approvals for updated package metadata
The PacakgeMetada::CveEnrichmentSyncWorker runs every hour however the data it consumes is updated on a daily basis, ref: #581332 (comment 2962261724)
From #581332 (comment 2993972194) :
We need to update Security::FindingEnrichment records when the package metadata is refreshed and update MR approvals based on the updated data.
Possible Steps:
- Queries
security_policieswith KEV/EPSS filters - Gets their associated projects via
security_policy_project_links - Creates
security_finding_enrichmentsby correlating the updatedpm_cve_enrichmentCVE with each project'ssecurity_findings
This approach minimizes the number of security_findings we need to query, but we parallelize them for each projects which should be fine as we've index for it.
Known limitation: If a policy adds a KEV/EPSS filter after a CVE was introduced in pm_cve_enrichment, matching MRs won't be blocked even though they should be. But I think, We can document this edge case for the initial iteration.
Acceptance Criteria
- Cron job frequency is optimized based on actual data update schedule
-
Security::FindingEnrichmentrecords are updated when package metadata refreshes - MR approvals are recalculated based on updated enrichment data
- Performance impact is minimized through efficient querying and parallelization
References: #581332 (comment 2993972194)