@@ -10,8 +10,9 @@ import (
1010 "github.com/aquasecurity/trivy/pkg/detector/library/compare/pep440"
1111)
1212
13- // echoLocalSegmentRe matches the Echo-specific PEP 440 local version segment,
14- // e.g. "+echo.1" in "2.14.2+echo.1".
13+ // echoLocalSegmentRe matches the Echo-specific version segment "+echo.N",
14+ // e.g. "+echo.1" in "2.14.2+echo.1". This appears both as a PEP 440 local
15+ // version (pip) and as a Maven build suffix (maven).
1516var echoLocalSegmentRe = regexp .MustCompile (`\+echo\.\d+` )
1617
1718func init () {
@@ -20,10 +21,10 @@ func init() {
2021 })
2122}
2223
23- // echoVendor matches pip packages patched by Echo.
24- // Echo provides patched versions of Python packages with their own vulnerability
25- // advisories. Their packages are identified by a PEP 440 local version suffix
26- // of the form "+echo.N" (e.g. "2.14.2+echo.1").
24+ // echoVendor matches language packages patched by Echo.
25+ // Echo provides patched versions of Python (pip) and Java (maven) packages with
26+ // their own vulnerability advisories. Their packages are identified by a version
27+ // suffix of the form "+echo.N" (e.g. "2.14.2+echo.1").
2728type echoVendor struct {
2829 pipComparer compare.Comparer
2930}
@@ -35,12 +36,15 @@ func (echoVendor) Name() string {
3536// Match determines whether a package is provided by Echo.
3637// It expects a normalized package name (see vulnerability.NormalizePkgName).
3738// Echo packages are identified by a "+echo.N" segment in the version string,
38- // where N is a numeric revision (e.g. "2.14.2+echo.1").
39+ // where N is a numeric revision (e.g. "2.14.2+echo.1"). Echo patches both
40+ // Python (pip) and Java (maven) packages using this same suffix convention.
3941func (echoVendor ) Match (eco ecosystem.Type , _ , pkgVer string ) bool {
40- if eco != ecosystem .Pip {
42+ switch eco {
43+ case ecosystem .Pip , ecosystem .Maven :
44+ return echoLocalSegmentRe .MatchString (pkgVer )
45+ default :
4146 return false
4247 }
43- return echoLocalSegmentRe .MatchString (pkgVer )
4448}
4549
4650// BucketPrefix returns the vendor-specific advisory bucket prefix.
@@ -49,9 +53,10 @@ func (e echoVendor) BucketPrefix(eco ecosystem.Type) string {
4953}
5054
5155// Comparer returns a version comparer for the given ecosystem.
52- // For pip (Python), it enables local version specifiers to correctly handle
53- // Echo version suffixes (e.g. "2.14.2+echo.1").
54- // For other ecosystems, it returns the default comparer unchanged.
56+ // For pip (Python), it enables local version specifiers so PEP 440 ordering
57+ // keeps the Echo suffix (e.g. "2.14.2+echo.1") instead of discarding it.
58+ // For maven (and other ecosystems) the default comparer already orders the
59+ // "+echo.N" suffix correctly, so it is returned unchanged.
5560func (e echoVendor ) Comparer (eco ecosystem.Type , defaultComparer compare.Comparer ) compare.Comparer {
5661 if eco == ecosystem .Pip {
5762 return e .pipComparer
0 commit comments