Repository navigation
Backport: Fix excessive churn of vulnerable software associations during mirroring - #7256
Merged
Merged
Conversation
Nearly every OSV mirror run deletes and re-inserts the `VULNERABLESOFTWARE` <-> `VULNERABILITY` associations (and their `AFFECTEDVERSIONATTRIBUTION` records) of ecosystems like Ubuntu, even when the affected version ranges did not change. This bloats `VULNERABLESOFTWARE_VULNERABILITIES` and `AFFECTEDVERSIONATTRIBUTION`, resets `firstSeen`, and makes both mirroring and maintenance slow. `synchronizeVulnerableSoftware` reconciles associations by matching previously reported records against freshly parsed ones via `VulnerableSoftware#equalsIgnoringDatastoreIdentity`. That comparison includes the full `purl` and `purlVersion`, but the lookup it relies on to re-resolve records matches only on the "decomposed" PURL and version range. When a stored record's `purl` differs while those coordinates are unchanged, it fails to match and is removed, only for the PURL-blind lookup to immediately re-resolve the same row and re-add it. Ubuntu's OSV data embeds the source package version in `package.purl`, and bumps it whenever an advisory is updated. The version range derived from it does not change, so those records churn on every run. `purl` and `purlVersion` are derived from the decomposed coordinates that already define a record's identity, and are exactly what the lookup matches on. This change excludes them from `equalsIgnoringDatastoreIdentity` and `hashCodeWithoutDatastoreIdentity`, so a record whose PURL was merely re-serialized is correctly treated as unchanged. (cherry picked from commit 5ebe40a) Signed-off-by: nscuro <nscuro@protonmail.com>
✅ Snyk checks have passed. No issues have been found so far.
💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse. |
Up to standards ✅🟢 Issues
|
| Metric | Results |
|---|---|
| Complexity | -6 |
NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Fixes excessive churn of vulnerable software associations during mirroring.
Addressed Issue
Backports #6499
Additional Details
N/A
Checklist
This PR implements an enhancement, and I have provided tests to verify that it works as intendedThis PR introduces changes to the database model, and I have updated the migration changelog accordinglyThis PR introduces new or alters existing behavior, and I have updated the documentation accordinglyThis PR is a substantial change (per the ADR criteria), and I have added an ADR underdocs/adr/