Skip to content

Commit 01c32a3

Browse files
committed
perf(echo): fast-path Match before regex
Signed-off-by: Laiza Angrest <laiza.angrest@echo.ai>
1 parent 31c46fe commit 01c32a3

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

pkg/detector/library/echo/echo.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package echo
33
import (
44
"fmt"
55
"regexp"
6+
"strings"
67

78
"github.com/aquasecurity/trivy-db/pkg/ecosystem"
89
"github.com/aquasecurity/trivy/pkg/detector/library"
@@ -41,7 +42,7 @@ func (echoVendor) Name() string {
4142
func (echoVendor) Match(eco ecosystem.Type, _, pkgVer string) bool {
4243
switch eco {
4344
case ecosystem.Pip, ecosystem.Maven:
44-
return echoLocalSegmentRe.MatchString(pkgVer)
45+
return strings.Contains(pkgVer, "+echo.") && echoLocalSegmentRe.MatchString(pkgVer)
4546
default:
4647
return false
4748
}

0 commit comments

Comments
 (0)