mirror of
https://github.com/anchore/grype
synced 2024-11-10 06:34:13 +00:00
remove jvm matcher
Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com>
This commit is contained in:
parent
8f38ac0528
commit
d997b31f77
7 changed files with 5 additions and 76 deletions
|
@ -22,7 +22,6 @@ import (
|
||||||
"github.com/anchore/grype/grype/matcher/golang"
|
"github.com/anchore/grype/grype/matcher/golang"
|
||||||
"github.com/anchore/grype/grype/matcher/java"
|
"github.com/anchore/grype/grype/matcher/java"
|
||||||
"github.com/anchore/grype/grype/matcher/javascript"
|
"github.com/anchore/grype/grype/matcher/javascript"
|
||||||
"github.com/anchore/grype/grype/matcher/jvm"
|
|
||||||
"github.com/anchore/grype/grype/matcher/python"
|
"github.com/anchore/grype/grype/matcher/python"
|
||||||
"github.com/anchore/grype/grype/matcher/ruby"
|
"github.com/anchore/grype/grype/matcher/ruby"
|
||||||
"github.com/anchore/grype/grype/matcher/stock"
|
"github.com/anchore/grype/grype/matcher/stock"
|
||||||
|
@ -286,9 +285,6 @@ func getMatchers(opts *options.Grype) []matcher.Matcher {
|
||||||
ExternalSearchConfig: opts.ExternalSources.ToJavaMatcherConfig(),
|
ExternalSearchConfig: opts.ExternalSources.ToJavaMatcherConfig(),
|
||||||
UseCPEs: opts.Match.Java.UseCPEs,
|
UseCPEs: opts.Match.Java.UseCPEs,
|
||||||
},
|
},
|
||||||
JVM: jvm.MatcherConfig{
|
|
||||||
UseCPEs: opts.Match.JVM.UseCPEs,
|
|
||||||
},
|
|
||||||
Ruby: ruby.MatcherConfig(opts.Match.Ruby),
|
Ruby: ruby.MatcherConfig(opts.Match.Ruby),
|
||||||
Python: python.MatcherConfig(opts.Match.Python),
|
Python: python.MatcherConfig(opts.Match.Python),
|
||||||
Dotnet: dotnet.MatcherConfig(opts.Match.Dotnet),
|
Dotnet: dotnet.MatcherConfig(opts.Match.Dotnet),
|
||||||
|
|
|
@ -16,7 +16,6 @@ const (
|
||||||
GoModuleMatcher MatcherType = "go-module-matcher"
|
GoModuleMatcher MatcherType = "go-module-matcher"
|
||||||
OpenVexMatcher MatcherType = "openvex-matcher"
|
OpenVexMatcher MatcherType = "openvex-matcher"
|
||||||
RustMatcher MatcherType = "rust-matcher"
|
RustMatcher MatcherType = "rust-matcher"
|
||||||
JVMMatcher MatcherType = "jvm-matcher"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
var AllMatcherTypes = []MatcherType{
|
var AllMatcherTypes = []MatcherType{
|
||||||
|
@ -33,7 +32,6 @@ var AllMatcherTypes = []MatcherType{
|
||||||
GoModuleMatcher,
|
GoModuleMatcher,
|
||||||
OpenVexMatcher,
|
OpenVexMatcher,
|
||||||
RustMatcher,
|
RustMatcher,
|
||||||
JVMMatcher,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type MatcherType string
|
type MatcherType string
|
||||||
|
|
|
@ -1,51 +0,0 @@
|
||||||
package jvm
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
|
|
||||||
"github.com/anchore/grype/grype/distro"
|
|
||||||
"github.com/anchore/grype/grype/match"
|
|
||||||
"github.com/anchore/grype/grype/pkg"
|
|
||||||
"github.com/anchore/grype/grype/search"
|
|
||||||
"github.com/anchore/grype/grype/vulnerability"
|
|
||||||
syftPkg "github.com/anchore/syft/syft/pkg"
|
|
||||||
)
|
|
||||||
|
|
||||||
type MatcherConfig struct {
|
|
||||||
UseCPEs bool
|
|
||||||
}
|
|
||||||
|
|
||||||
type Matcher struct {
|
|
||||||
cfg MatcherConfig
|
|
||||||
}
|
|
||||||
|
|
||||||
func NewJVMMatcher(cfg MatcherConfig) *Matcher {
|
|
||||||
return &Matcher{
|
|
||||||
cfg: cfg,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (m *Matcher) PackageTypes() []syftPkg.Type {
|
|
||||||
return []syftPkg.Type{syftPkg.BinaryPkg}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (m *Matcher) Type() match.MatcherType {
|
|
||||||
return match.JVMMatcher
|
|
||||||
}
|
|
||||||
|
|
||||||
func (m *Matcher) Match(store vulnerability.Provider, d *distro.Distro, p pkg.Package) ([]match.Match, error) {
|
|
||||||
if !pkg.IsJvmPackage(p) {
|
|
||||||
return nil, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
criteria := search.CommonCriteria
|
|
||||||
if m.cfg.UseCPEs {
|
|
||||||
criteria = append(criteria, search.ByCPE)
|
|
||||||
}
|
|
||||||
matches, err := search.ByCriteria(store, d, p, m.Type(), criteria...)
|
|
||||||
if err != nil {
|
|
||||||
return nil, fmt.Errorf("failed to match by exact package: %w", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
return matches, nil
|
|
||||||
}
|
|
|
@ -7,7 +7,6 @@ import (
|
||||||
"github.com/anchore/grype/grype/matcher/golang"
|
"github.com/anchore/grype/grype/matcher/golang"
|
||||||
"github.com/anchore/grype/grype/matcher/java"
|
"github.com/anchore/grype/grype/matcher/java"
|
||||||
"github.com/anchore/grype/grype/matcher/javascript"
|
"github.com/anchore/grype/grype/matcher/javascript"
|
||||||
"github.com/anchore/grype/grype/matcher/jvm"
|
|
||||||
"github.com/anchore/grype/grype/matcher/msrc"
|
"github.com/anchore/grype/grype/matcher/msrc"
|
||||||
"github.com/anchore/grype/grype/matcher/portage"
|
"github.com/anchore/grype/grype/matcher/portage"
|
||||||
"github.com/anchore/grype/grype/matcher/python"
|
"github.com/anchore/grype/grype/matcher/python"
|
||||||
|
@ -20,7 +19,6 @@ import (
|
||||||
// Config contains values used by individual matcher structs for advanced configuration
|
// Config contains values used by individual matcher structs for advanced configuration
|
||||||
type Config struct {
|
type Config struct {
|
||||||
Java java.MatcherConfig
|
Java java.MatcherConfig
|
||||||
JVM jvm.MatcherConfig
|
|
||||||
Ruby ruby.MatcherConfig
|
Ruby ruby.MatcherConfig
|
||||||
Python python.MatcherConfig
|
Python python.MatcherConfig
|
||||||
Dotnet dotnet.MatcherConfig
|
Dotnet dotnet.MatcherConfig
|
||||||
|
@ -38,7 +36,6 @@ func NewDefaultMatchers(mc Config) []Matcher {
|
||||||
dotnet.NewDotnetMatcher(mc.Dotnet),
|
dotnet.NewDotnetMatcher(mc.Dotnet),
|
||||||
&rpm.Matcher{},
|
&rpm.Matcher{},
|
||||||
java.NewJavaMatcher(mc.Java),
|
java.NewJavaMatcher(mc.Java),
|
||||||
jvm.NewJVMMatcher(mc.JVM),
|
|
||||||
javascript.NewJavascriptMatcher(mc.Javascript),
|
javascript.NewJavascriptMatcher(mc.Javascript),
|
||||||
&apk.Matcher{},
|
&apk.Matcher{},
|
||||||
golang.NewGolangMatcher(mc.Golang),
|
golang.NewGolangMatcher(mc.Golang),
|
||||||
|
|
|
@ -32,17 +32,9 @@ func (m *Matcher) Type() match.MatcherType {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *Matcher) Match(store vulnerability.Provider, d *distro.Distro, p pkg.Package) ([]match.Match, error) {
|
func (m *Matcher) Match(store vulnerability.Provider, d *distro.Distro, p pkg.Package) ([]match.Match, error) {
|
||||||
if !inboundsForMatcher(p) {
|
|
||||||
return nil, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
criteria := search.CommonCriteria
|
criteria := search.CommonCriteria
|
||||||
if m.cfg.UseCPEs {
|
if m.cfg.UseCPEs {
|
||||||
criteria = append(criteria, search.ByCPE)
|
criteria = append(criteria, search.ByCPE)
|
||||||
}
|
}
|
||||||
return search.ByCriteria(store, d, p, m.Type(), criteria...)
|
return search.ByCriteria(store, d, p, m.Type(), criteria...)
|
||||||
}
|
}
|
||||||
|
|
||||||
func inboundsForMatcher(p pkg.Package) bool {
|
|
||||||
return !pkg.IsJvmPackage(p)
|
|
||||||
}
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
package jvm
|
package stock
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"testing"
|
"testing"
|
||||||
|
@ -17,7 +17,7 @@ import (
|
||||||
syftPkg "github.com/anchore/syft/syft/pkg"
|
syftPkg "github.com/anchore/syft/syft/pkg"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestMatcher(t *testing.T) {
|
func TestMatcher_JVMPackage(t *testing.T) {
|
||||||
p := pkg.Package{
|
p := pkg.Package{
|
||||||
ID: pkg.ID(uuid.NewString()),
|
ID: pkg.ID(uuid.NewString()),
|
||||||
Name: "java_se",
|
Name: "java_se",
|
||||||
|
@ -33,7 +33,8 @@ func TestMatcher(t *testing.T) {
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
store := newMockProvider()
|
store := newMockProvider()
|
||||||
actual, _ := matcher.Match(store, nil, p)
|
actual, err := matcher.Match(store, nil, p)
|
||||||
|
require.NoError(t, err)
|
||||||
|
|
||||||
foundCVEs := strset.New()
|
foundCVEs := strset.New()
|
||||||
for _, v := range actual {
|
for _, v := range actual {
|
|
@ -18,7 +18,6 @@ import (
|
||||||
"github.com/anchore/grype/grype/matcher/golang"
|
"github.com/anchore/grype/grype/matcher/golang"
|
||||||
"github.com/anchore/grype/grype/matcher/java"
|
"github.com/anchore/grype/grype/matcher/java"
|
||||||
"github.com/anchore/grype/grype/matcher/javascript"
|
"github.com/anchore/grype/grype/matcher/javascript"
|
||||||
"github.com/anchore/grype/grype/matcher/jvm"
|
|
||||||
"github.com/anchore/grype/grype/matcher/python"
|
"github.com/anchore/grype/grype/matcher/python"
|
||||||
"github.com/anchore/grype/grype/matcher/ruby"
|
"github.com/anchore/grype/grype/matcher/ruby"
|
||||||
"github.com/anchore/grype/grype/matcher/rust"
|
"github.com/anchore/grype/grype/matcher/rust"
|
||||||
|
@ -588,7 +587,7 @@ func addJvmMatches(t *testing.T, theSource source.Source, catalog *syftPkg.Colle
|
||||||
"cpe:2.3:a:oracle:jdk:*:*:*:*:*:*:*:*",
|
"cpe:2.3:a:oracle:jdk:*:*:*:*:*:*:*:*",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
Matcher: match.JVMMatcher,
|
Matcher: match.StockMatcher,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
@ -738,9 +737,6 @@ func TestMatchByImage(t *testing.T) {
|
||||||
Java: java.MatcherConfig{
|
Java: java.MatcherConfig{
|
||||||
UseCPEs: true,
|
UseCPEs: true,
|
||||||
},
|
},
|
||||||
JVM: jvm.MatcherConfig{
|
|
||||||
UseCPEs: true,
|
|
||||||
},
|
|
||||||
Ruby: ruby.MatcherConfig{
|
Ruby: ruby.MatcherConfig{
|
||||||
UseCPEs: true,
|
UseCPEs: true,
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in a new issue