perf: use a map to track which advisories should be checked for which packages #216
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.
This greatly improves the performance of determining vulnerabilities since now only advisories that actually could match a package are checked, rather than looping through all of them for all packages which scales much better as the number of advisories in a database grows.
You can easily see the difference in speed by just running
make regenerate-e2e-fixtures
- before this change it typically takes 30 seconds whereas after it takes only 10.This also means that the detector no longer loads advisories without any affected packages, which really shouldn't change anything but lets us easily stop using the
Vulnerabilities
function reducing the size by a couple of KB - I've kept the function because its still used in tests and doesn't have to be removed so this is less breaking.