Skip to content

Commit

Permalink
remove jvm matcher
Browse files Browse the repository at this point in the history
Signed-off-by: Alex Goodman <[email protected]>
  • Loading branch information
wagoodman committed Sep 18, 2024
1 parent 8f38ac0 commit d997b31
Show file tree
Hide file tree
Showing 7 changed files with 5 additions and 76 deletions.
4 changes: 0 additions & 4 deletions cmd/grype/cli/commands/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import (
"github.com/anchore/grype/grype/matcher/golang"
"github.com/anchore/grype/grype/matcher/java"
"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/ruby"
"github.com/anchore/grype/grype/matcher/stock"
Expand Down Expand Up @@ -286,9 +285,6 @@ func getMatchers(opts *options.Grype) []matcher.Matcher {
ExternalSearchConfig: opts.ExternalSources.ToJavaMatcherConfig(),
UseCPEs: opts.Match.Java.UseCPEs,
},
JVM: jvm.MatcherConfig{
UseCPEs: opts.Match.JVM.UseCPEs,
},
Ruby: ruby.MatcherConfig(opts.Match.Ruby),
Python: python.MatcherConfig(opts.Match.Python),
Dotnet: dotnet.MatcherConfig(opts.Match.Dotnet),
Expand Down
2 changes: 0 additions & 2 deletions grype/match/matcher_type.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ const (
GoModuleMatcher MatcherType = "go-module-matcher"
OpenVexMatcher MatcherType = "openvex-matcher"
RustMatcher MatcherType = "rust-matcher"
JVMMatcher MatcherType = "jvm-matcher"
)

var AllMatcherTypes = []MatcherType{
Expand All @@ -33,7 +32,6 @@ var AllMatcherTypes = []MatcherType{
GoModuleMatcher,
OpenVexMatcher,
RustMatcher,
JVMMatcher,
}

type MatcherType string
51 changes: 0 additions & 51 deletions grype/matcher/jvm/matcher.go

This file was deleted.

3 changes: 0 additions & 3 deletions grype/matcher/matchers.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import (
"github.com/anchore/grype/grype/matcher/golang"
"github.com/anchore/grype/grype/matcher/java"
"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/portage"
"github.com/anchore/grype/grype/matcher/python"
Expand All @@ -20,7 +19,6 @@ import (
// Config contains values used by individual matcher structs for advanced configuration
type Config struct {
Java java.MatcherConfig
JVM jvm.MatcherConfig
Ruby ruby.MatcherConfig
Python python.MatcherConfig
Dotnet dotnet.MatcherConfig
Expand All @@ -38,7 +36,6 @@ func NewDefaultMatchers(mc Config) []Matcher {
dotnet.NewDotnetMatcher(mc.Dotnet),
&rpm.Matcher{},
java.NewJavaMatcher(mc.Java),
jvm.NewJVMMatcher(mc.JVM),
javascript.NewJavascriptMatcher(mc.Javascript),
&apk.Matcher{},
golang.NewGolangMatcher(mc.Golang),
Expand Down
8 changes: 0 additions & 8 deletions grype/matcher/stock/matcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
if !inboundsForMatcher(p) {
return nil, nil
}

criteria := search.CommonCriteria
if m.cfg.UseCPEs {
criteria = append(criteria, search.ByCPE)
}
return search.ByCriteria(store, d, p, m.Type(), criteria...)
}

func inboundsForMatcher(p pkg.Package) bool {
return !pkg.IsJvmPackage(p)
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package jvm
package stock

import (
"testing"
Expand All @@ -17,7 +17,7 @@ import (
syftPkg "github.com/anchore/syft/syft/pkg"
)

func TestMatcher(t *testing.T) {
func TestMatcher_JVMPackage(t *testing.T) {
p := pkg.Package{
ID: pkg.ID(uuid.NewString()),
Name: "java_se",
Expand All @@ -33,7 +33,8 @@ func TestMatcher(t *testing.T) {
},
}
store := newMockProvider()
actual, _ := matcher.Match(store, nil, p)
actual, err := matcher.Match(store, nil, p)
require.NoError(t, err)

foundCVEs := strset.New()
for _, v := range actual {
Expand Down
6 changes: 1 addition & 5 deletions test/integration/match_by_image_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import (
"github.com/anchore/grype/grype/matcher/golang"
"github.com/anchore/grype/grype/matcher/java"
"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/ruby"
"github.com/anchore/grype/grype/matcher/rust"
Expand Down Expand Up @@ -588,7 +587,7 @@ func addJvmMatches(t *testing.T, theSource source.Source, catalog *syftPkg.Colle
"cpe:2.3:a:oracle:jdk:*:*:*:*:*:*:*:*",
},
},
Matcher: match.JVMMatcher,
Matcher: match.StockMatcher,
},
},
})
Expand Down Expand Up @@ -738,9 +737,6 @@ func TestMatchByImage(t *testing.T) {
Java: java.MatcherConfig{
UseCPEs: true,
},
JVM: jvm.MatcherConfig{
UseCPEs: true,
},
Ruby: ruby.MatcherConfig{
UseCPEs: true,
},
Expand Down

0 comments on commit d997b31

Please sign in to comment.