mirror of
https://github.com/anchore/grype
synced 2024-11-10 06:34:13 +00:00
fix: hash vuln db only once on load (#2054)
Signed-off-by: Lucas Rodriguez <lucas.rodriguez9616@gmail.com>
This commit is contained in:
parent
1fb6199dd2
commit
60c0682bb4
2 changed files with 27 additions and 1 deletions
|
@ -122,7 +122,7 @@ func (c *Curator) Status() Status {
|
|||
SchemaVersion: metadata.Version,
|
||||
Location: c.dbDir,
|
||||
Checksum: metadata.Checksum,
|
||||
Err: c.Validate(),
|
||||
Err: nil,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
26
grype/load_vulnerability_db_bench_test.go
Normal file
26
grype/load_vulnerability_db_bench_test.go
Normal file
|
@ -0,0 +1,26 @@
|
|||
package grype
|
||||
|
||||
import (
|
||||
"path/filepath"
|
||||
"testing"
|
||||
|
||||
"github.com/anchore/grype/grype/db"
|
||||
"github.com/anchore/grype/internal"
|
||||
)
|
||||
|
||||
// this benchmark was added to measure the performance
|
||||
// of LoadVulnerabilityDB, specifically in regards to hash validation.
|
||||
// https://github.com/anchore/grype/issues/1502
|
||||
func BenchmarkLoadVulnerabilityDB(b *testing.B) {
|
||||
cfg := db.Config{
|
||||
DBRootDir: filepath.Join(".tmp", "grype-db"),
|
||||
ListingURL: internal.DBUpdateURL,
|
||||
ValidateByHashOnGet: true,
|
||||
}
|
||||
for range b.N {
|
||||
_, _, _, err := LoadVulnerabilityDB(cfg, true)
|
||||
if err != nil {
|
||||
b.Fatal(err)
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue