Skip to content

Commit 62358ae

Browse files
committed
refactor(seal): replace magic index with strings.CutPrefix and unicode.IsDigit
1 parent 4675276 commit 62358ae

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

pkg/detector/library/seal/seal.go

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

78
"github.com/aquasecurity/trivy-db/pkg/ecosystem"
89
"github.com/aquasecurity/trivy/pkg/detector/library"
@@ -41,7 +42,8 @@ func (sealSecurity) Match(eco ecosystem.Type, pkgName, _ string) bool {
4142
switch eco {
4243
case ecosystem.Maven:
4344
// e.g. seal.sp1.org.eclipse.jetty:jetty-http
44-
return len(pkgName) > 7 && strings.HasPrefix(pkgName, "seal.sp") && pkgName[7] >= '0' && pkgName[7] <= '9'
45+
rest, ok := strings.CutPrefix(pkgName, "seal.sp")
46+
return ok && len(rest) > 0 && unicode.IsDigit(rune(rest[0]))
4547
case ecosystem.Npm:
4648
// e.g. @seal-security/ejs
4749
return strings.HasPrefix(pkgName, "@seal-security/")

0 commit comments

Comments
 (0)