-
Notifications
You must be signed in to change notification settings - Fork 605
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Alex Goodman <[email protected]>
- Loading branch information
Showing
21 changed files
with
779 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
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 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.