Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/feat/v6-query-api' into feat/v6-…
Browse files Browse the repository at this point in the history
…query-api
  • Loading branch information
kzantow committed Jan 1, 2025
2 parents 8556722 + 7b627c8 commit d2e9b0d
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 18 deletions.
6 changes: 0 additions & 6 deletions grype/db/v6/affected_package_store.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion grype/db/v6/refs.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
25 changes: 14 additions & 11 deletions grype/db/v6/vulnerability_provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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
Expand All @@ -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 {
Expand Down

0 comments on commit d2e9b0d

Please sign in to comment.