You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* perf(importers): batch vulnerability_id inserts
Replace per-row Vulnerability_Id saves with bulk_create in two layers:
- fix sanitize_vulnerability_ids to return filtered list (was a no-op
bug — reassigned local variable, caller never saw the result)
- save_vulnerability_ids now uses bulk_create per finding instead of
one INSERT per ID; fixes all callers including the reimporter path
- DefaultImporter.store_vulnerability_ids accumulates Vulnerability_Id
objects across all findings in a batch; flush_vulnerability_ids()
does a single bulk_create at each batch boundary (alongside
location_handler.persist())
For a scan with 1000 findings × 5 CVEs each: 5000 INSERT queries
reduced to O(batches) bulk_create calls.
* perf(reimporter): batch vulnerability_id reconciliation
Extend the cross-finding accumulation pattern to DefaultReImporter:
- reconcile_vulnerability_ids now accumulates changed findings into
pending_vuln_id_deletes / pending_vulnerability_ids instead of
issuing per-finding DELETE + INSERT immediately
- flush_vulnerability_ids (BaseImporter) runs one bulk DELETE WHERE
finding_id IN (...) followed by one bulk_create for all new IDs
- flush called at both dedupe batch boundaries (alongside
location_handler.persist()) and after the mitigation loop
Early-exit path (unchanged IDs) never touches either buffer, so the
common case pays zero extra cost.
Add two unit tests: cross-finding batch (3 findings, 2 changed + 1
unchanged, verify buffer contents before flush and DB state after) and
unchanged-IDs early-exit (verify buffers stay empty).
* test(performance): re-baseline importer query counts
Remove pending-rebaseline skips from TestDojoImporterPerformanceSmall
and TestDojoImporterPerformanceSmallLocations. Update all expected
query counts to reflect the batch Vulnerability_Id insert optimisation
(counts decrease by 1-20 queries per step depending on the scan size
and code path).
* fix(test): update TestSaveVulnerabilityIds mock for bulk_create
The test mocked Vulnerability_Id.save (individual saves) but
save_vulnerability_ids now uses bulk_create. Django's bulk_create
validates FK references before issuing SQL, raising ValueError when
the finding has no pk. Mock bulk_create instead and assert on the
deduplicated object list passed to it.
---------
Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
0 commit comments