Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
58 changes: 0 additions & 58 deletions grype/internal/cpe_target_software_to_pkg_type.go

This file was deleted.

6 changes: 3 additions & 3 deletions grype/matcher/internal/only_vulnerable_targets.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ import (
"github.com/facebookincubator/nvdtools/wfn"
"github.com/scylladb/go-set/strset"

"github.com/anchore/grype/grype/internal"
"github.com/anchore/grype/grype/pkg"
"github.com/anchore/grype/grype/search"
"github.com/anchore/grype/grype/vulnerability"
"github.com/anchore/syft/syft/cpe"
syftPkg "github.com/anchore/syft/syft/pkg"
cpe_cataloger "github.com/anchore/syft/syft/pkg/cataloger/common/cpe"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: it's unusual to use underscores in names, a common pattern for syft imports is syft<Thing>, I think I'd prefer to use the name syftCpe here for consistency

)

// OnlyVulnerableTargets returns a criteria object that tests vulnerability qualifiers against the package vulnerability rules.
Expand Down Expand Up @@ -83,7 +83,7 @@ func refuteTargetSoftwareByPackageAttributes(p pkg.Package, vuln vulnerability.V
mismatchWithUnknownLanguage := syftPkg.LanguageByName(targetSW) != p.Language && isUnknownTarget(targetSW)
unspecifiedTargetSW := targetSW == wfn.Any || targetSW == wfn.NA
matchesByLanguage := syftPkg.LanguageByName(targetSW) == p.Language
matchesByPackageType := internal.CPETargetSoftwareToPackageType(targetSW) == p.Type
matchesByPackageType := cpe_cataloger.TargetSoftwareToPackageType(targetSW) == p.Type
if unspecifiedTargetSW || matchesByLanguage || matchesByPackageType || mismatchWithUnknownLanguage {
return true, ""
}
Expand Down Expand Up @@ -164,7 +164,7 @@ func normalizeTargetSoftwares(ts []string) *strset.Set {
normalizedTargetSWs := strset.New()
for _, ts := range ts {
// Attempt to normalize target sw to package type, e.g. node and nodejs should match
pt := string(internal.CPETargetSoftwareToPackageType(ts))
pt := string(cpe_cataloger.TargetSoftwareToPackageType(ts))
if pt == "" && ts != "*" && ts != "?" && ts != "-" {
// normalizing failed; preserve raw cpe target sw string as the type
// unless it is wildcard
Expand Down
4 changes: 2 additions & 2 deletions grype/pkg/cpe_provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ import (
"io"
"strings"

"github.com/anchore/grype/grype/internal"
"github.com/anchore/syft/syft/cpe"
"github.com/anchore/syft/syft/pkg"
cpe_cataloger "github.com/anchore/syft/syft/pkg/cataloger/common/cpe"
"github.com/anchore/syft/syft/sbom"
"github.com/anchore/syft/syft/source"
)
Expand Down Expand Up @@ -83,7 +83,7 @@ func cpeToPackage(rawLine string) (*Package, *pkg.Package, error) {
Name: c.Attributes.Product,
Version: c.Attributes.Version,
CPEs: []cpe.CPE{c},
Type: internal.CPETargetSoftwareToPackageType(c.Attributes.TargetSW),
Type: cpe_cataloger.TargetSoftwareToPackageType(c.Attributes.TargetSW),
}

syftPkg.SetID()
Expand Down
Loading