fix: hash vuln db only once on load #2054
Merged
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.
Fixes #1502
This PR aims to improve the performance of
LoadVulnerabilityDB
whenValidateByHashOnGet
is set totrue
As described in the linked issue,
GetStore
andStatus
both hash the db. This PR changesStatus
to not hash the db by removing the call toc.Validate
As far as I can tell,
Status
is only used in a few places:LoadVulnerabilityDB
This should not be an issue since
GetStore
already hashes the dbgrype/grype/load_vulnerability_db.go
Line 28 in e7ceffa
runDBStatus
I am unsure whether hashing the db is desired behavior for
grype db status
. If so, perhaps a new field could be added todb.Config
to allow CLI and library users to configure this behavior?grype/cmd/grype/cli/commands/db_status.go
Line 33 in e7ceffa
Test_DifferDirectory
This test doesn't appear to rely on the hashing behavior in
Status
grype/grype/differ/differ_test.go
Line 41 in e7ceffa
grype/grype/differ/differ_test.go
Line 47 in e7ceffa