8000 fix: use package language to search when type is unknown by willmurphyscode · Pull Request #2610 · anchore/grype · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

fix: use package language to search when type is unknown #2610

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

Merged
merged 1 commit into from
Apr 23, 2025
Merged
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
2 changes: 1 addition & 1 deletion grype/db/v6/vulnerability_provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ func (vp vulnerabilityProvider) FindVulnerabilities(criteria ...vulnerability.Cr
pkgSpec = &PackageSpecifier{}
}
// the v6 store normalizes ecosystems around the syft package type, so that field is preferred
if c.PackageType != "" {
if c.PackageType != "" && c.PackageType != syftPkg.UnknownPkg {
pkgSpec.Ecosystem = string(c.PackageType)
pkgType = c.PackageType
} else {
Expand Down
7 changes: 7 additions & 0 deletions grype/db/v6/vulnerability_provider_mocks_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,13 @@ func testVulnerabilityProvider(t *testing.T) vulnerability.Provider {
"cpe:2.3:*:awesome:awesome:*:*:*:*:*:*:*:*", // shouldn't match on this
},
},
{
PackageName: "Newtonsoft.Json",
Namespace: "github:language:dotnet",
ID: "GHSA-5crp-9r3c-p9vr",
VersionFormat: "unknown",
VersionConstraint: "<13.0.1",
},
// poison the well! this is not a valid entry, but we want the matching process to survive and find other good results...
{
PackageName: "activerecord",
Expand Down
9 changes: 9 additions & 0 deletions grype/db/v6/vulnerability_provider_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import (
"github.com/anchore/grype/grype/version"
"github.com/anchore/grype/grype/vulnerability"
"github.com/anchore/syft/syft/cpe"
syftPkg "github.com/anchore/syft/syft/pkg"
)

func Test_FindVulnerabilitiesByDistro(t *testing.T) {
Expand Down Expand Up @@ -303,6 +304,14 @@ func Test_FindVulnerabilitiesByByID(t *testing.T) {
require.Empty(t, actual)
}

func Test_FindVulnerabilitiesByEcosystem_UnknownPackageType(t *testing.T) {
provider := testVulnerabilityProvider(t)
actual, err := provider.FindVulnerabilities(search.ByEcosystem(syftPkg.Dotnet, syftPkg.UnknownPkg))
require.NoError(t, err)
require.NotEmpty(t, actual)
require.Equal(t, actual[0].Reference.ID, "GHSA-5crp-9r3c-p9vr")
}

func Test_DataSource(t *testing.T) {
tests := []struct {
name string
Expand Down
Loading
0