fix(rootio): check full version to detect root.io packages [backport: release/v0.64] (#9120)

Co-authored-by: DmitriyLewen <91113035+DmitriyLewen@users.noreply.github.com>
This commit is contained in:
Aqua Security automated builds
2025-07-02 04:29:38 -06:00
committed by GitHub
parent 8cf1bf9f6f
commit 53adfba3c2
3 changed files with 4 additions and 2 deletions

View File

@@ -67,6 +67,7 @@ jobs:
distroless
windows
minimos
rootio
# Languages
ruby

View File

@@ -5,6 +5,7 @@ import (
"github.com/aquasecurity/trivy/pkg/detector/ospkg/driver"
ftypes "github.com/aquasecurity/trivy/pkg/fanal/types"
"github.com/aquasecurity/trivy/pkg/scan/utils"
)
var (
@@ -37,7 +38,7 @@ func isRootIOEnvironment(osFamily ftypes.OSType, pkgs []ftypes.Package) bool {
// hasPackageWithPattern checks if any package version matches the specified pattern
func hasPackageWithPattern(pkgs []ftypes.Package, pattern *regexp.Regexp) bool {
for _, pkg := range pkgs {
if pattern.MatchString(pkg.Version) {
if pattern.MatchString(utils.FormatVersion(pkg)) {
return true
}
}

View File

@@ -21,7 +21,7 @@ func TestProvider(t *testing.T) {
name: "Debian with .root.io package",
osFamily: ftypes.Debian,
pkgs: []ftypes.Package{
{Name: "libc6", Version: "2.31-13+deb11u4.root.io"},
{Name: "libc6", Version: "2.31", Release: "13+deb11u4.root.io"},
{Name: "bash", Version: "5.1-2+deb11u1"},
},
want: true,