Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: v6 database support, updated matcher interfaces #2311

Merged
merged 59 commits into from
Feb 11, 2025
Merged
Changes from 2 commits
Commits
Show all changes
59 commits
Select commit Hold shift + click to select a range
fe1eef5
feat: basic v6 database support
kzantow Dec 10, 2024
bb01798
Merge remote-tracking branch 'origin/main' into feat/v6-query-api
kzantow Dec 12, 2024
204fe85
Merge remote-tracking branch 'origin/main' into feat/v6-query-api
kzantow Dec 13, 2024
0a47e70
Merge remote-tracking branch 'origin/main' into feat/v6-query-api
kzantow Dec 16, 2024
f25083a
chore: move towards v6 interfaces
kzantow Dec 17, 2024
01bdb3e
Merge remote-tracking branch 'origin/main' into feat/v6-query-api
kzantow Dec 17, 2024
91c1f5a
Merge remote-tracking branch 'origin/main' into feat/v6-query-api
kzantow Dec 20, 2024
7b627c8
pull in changes from main
wagoodman Dec 24, 2024
8556722
Merge remote-tracking branch 'origin/main' into feat/v6-query-api
kzantow Jan 1, 2025
d2e9b0d
Merge remote-tracking branch 'origin/feat/v6-query-api' into feat/v6-…
kzantow Jan 1, 2025
e298078
Merge remote-tracking branch 'origin/main' into feat/v6-query-api
kzantow Jan 6, 2025
103ec5d
use v6 vuln status enum
wagoodman Jan 8, 2025
d984a23
chore: implement new vulnerability.Provider interface for v5 database
kzantow Jan 10, 2025
25082fa
Merge remote-tracking branch 'origin/feat/v6-query-api' into feat/v6-…
kzantow Jan 10, 2025
49da16c
Merge remote-tracking branch 'origin/main' into feat/v6-query-api
kzantow Jan 10, 2025
eb4a554
chore: update tests
kzantow Jan 13, 2025
9eb7d45
Merge remote-tracking branch 'origin/main' into feat/v6-query-api
kzantow Jan 14, 2025
1e75a9b
chore: cleanup
kzantow Jan 14, 2025
e55f716
chore: properly filter affected ranges
kzantow Jan 14, 2025
44b13ef
add v5 namespace adapter
wagoodman Jan 14, 2025
017b4e1
chore: add language to package specifier lookup
kzantow Jan 15, 2025
cf5d6c4
do not error when effective record lookup fails
wagoodman Jan 15, 2025
205a821
Merge remote-tracking branch 'origin/main' into feat/v6-query-api
wagoodman Jan 15, 2025
d7fb5e4
use single v5 namespace helper
wagoodman Jan 15, 2025
ea5adac
Merge remote-tracking branch 'origin/main' into feat/v6-query-api
kzantow Jan 15, 2025
0e9b313
chore: ignore fields during test compare
kzantow Jan 15, 2025
2c4f0bd
Merge remote-tracking branch 'origin/main' into feat/v6-query-api
kzantow Jan 16, 2025
2b1f3f2
chore: add some v6 Provider tests
kzantow Jan 17, 2025
eed9a9d
Merge remote-tracking branch 'origin/main' into feat/v6-query-api
kzantow Jan 17, 2025
9ad62d8
chore: update tests
kzantow Jan 17, 2025
3eb781b
Merge remote-tracking branch 'origin/main' into feat/v6-query-api
kzantow Jan 21, 2025
b1d3a59
ensure query planner accounts for indexes
wagoodman Jan 23, 2025
fe17bc1
account for distro versions with leading 0s
wagoodman Jan 23, 2025
a74120f
Merge remote-tracking branch 'origin/main' into feat/v6-query-api
wagoodman Jan 23, 2025
6645275
chore: address PR feedback - allow multiple distros and OSes
kzantow Jan 24, 2025
33b106d
Merge remote-tracking branch 'origin/main' into feat/v6-query-api
kzantow Feb 3, 2025
4736379
Merge remote-tracking branch 'origin/main' into feat/v6-query-api
kzantow Feb 3, 2025
9835b7d
chore: no need to lowercase fields in v6 vulnerability_provider
kzantow Feb 3, 2025
52b254c
chore: cleanup
kzantow Feb 3, 2025
5c06401
chore: address PR feedback
kzantow Feb 4, 2025
6d35544
chore: address PR feedback
kzantow Feb 4, 2025
3230006
Merge remote-tracking branch 'origin/main' into feat/v6-query-api
kzantow Feb 4, 2025
d96066a
chore: remove development flag
kzantow Feb 4, 2025
155af81
chore: cleanup
kzantow Feb 4, 2025
437c507
chore: cleanup
kzantow Feb 5, 2025
dda4b5e
unexport getDB() functionality
wagoodman Feb 10, 2025
4b4e92b
chore: address PR feedback
kzantow Feb 10, 2025
27d009f
chore: address PR feedback
kzantow Feb 10, 2025
23b207c
chore: address more PR feedback & cleanup
kzantow Feb 10, 2025
2c6deb3
Merge remote-tracking branch 'origin/main' into feat/v6-query-api
kzantow Feb 10, 2025
15fac11
chore: address more PR feedback & cleanup
kzantow Feb 10, 2025
6c8ec9a
chore: update where v6 advisories come from
kzantow Feb 10, 2025
367c9e8
chore: update tests
kzantow Feb 10, 2025
f454f1b
chore: minor cleanup
kzantow Feb 10, 2025
c14a462
chore: naming, cleanup, survive unparseable constraints
kzantow Feb 10, 2025
fad04b7
chore: naming, cleanup
kzantow Feb 10, 2025
3f53af5
chore: check for nil
kzantow Feb 10, 2025
c6b785b
chore: cleanup
kzantow Feb 10, 2025
1da5037
chore: cleanup
kzantow Feb 10, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions grype/db/v6/affected_package_store.go
Original file line number Diff line number Diff line change
@@ -291,12 +291,6 @@ func (s *affectedPackageStore) GetAffectedPackages(pkg *PackageSpecifier, config
return models, nil
}

func LogQuery(tx *gorm.DB, findTarget any) {
log.Tracef("executing query: %v", tx.ToSQL(func(tx *gorm.DB) *gorm.DB {
return tx.Find(&findTarget)
}))
}

func (s *affectedPackageStore) handlePackage(query *gorm.DB, config *PackageSpecifier) *gorm.DB {
if config == nil {
return query
1 change: 0 additions & 1 deletion grype/db/v6/refs.go
Original file line number Diff line number Diff line change
@@ -39,7 +39,6 @@ func fillRefs[T, R any](db *gorm.DB, handles []*T, getRef refProvider[T, R], ref
// load a map with all id -> ref results
var values []R
tx := db.Where("id IN (?)", ids)
LogQuery(tx, &values)
err := tx.Find(&values).Error
if err != nil {
return err
25 changes: 14 additions & 11 deletions grype/db/v6/vulnerability_provider.go
Original file line number Diff line number Diff line change
@@ -136,8 +136,10 @@ func (s vulnerabilityProvider) FindVulnerabilities(crit ...vulnerability.Criteri

if c.id != "" {
handles, err := s.reader.GetAffectedPackages(&PackageSpecifier{}, &GetAffectedPackageOptions{
Vulnerability: &VulnerabilitySpecifier{
Name: c.id,
Vulnerabilities: []VulnerabilitySpecifier{
{
Name: c.id,
},
},
})
if err != nil {
@@ -185,8 +187,8 @@ func (s vulnerabilityProvider) FindVulnerabilities(crit ...vulnerability.Criteri
PreloadPackageCPEs: false,
PreloadVulnerability: false,
PreloadBlob: false,
Distro: nil,
Vulnerability: nil,
OSs: nil,
Vulnerabilities: nil,
})
if err != nil {
return nil, err
@@ -207,13 +209,14 @@ func (s vulnerabilityProvider) FindVulnerabilities(crit ...vulnerability.Criteri
pkgs, err := s.reader.GetAffectedPackages(&PackageSpecifier{
Name: c.p.Name,
}, &GetAffectedPackageOptions{
Distro: &DistroSpecifier{
Name: d.Name(),
MajorVersion: d.MajorVersion(),
MinorVersion: minorVersion,
LabelVersion: "",
Codename: "",
AllowMultiple: true, // TODO it's unclear when/why I choose this option
OSs: []*OSSpecifier{
{
Name: d.Name(),
MajorVersion: d.MajorVersion(),
MinorVersion: minorVersion,
LabelVersion: "",
AllowMultiple: true, // TODO it's unclear when/why I choose this option
},
},
})
if err != nil {