fix: release package collection lock in Ubuntu ESM detection (#5336)

Signed-off-by: Sverrir Sigurðsson <svesig@gmail.com>
This commit is contained in:
Sverrir Sigurdsson
2026-09-28 17:10:55 +00:00
committed by GitHub
parent fb55856e33
commit ff45b9ea63
2 changed files with 32 additions and 6 deletions
+4 -6
View File
@@ -6,6 +6,7 @@ import (
"errors"
"fmt"
"regexp"
"slices"
"github.com/anchore/syft/internal"
"github.com/anchore/syft/internal/log"
@@ -191,12 +192,9 @@ func hasInstalledESMPackage(packages *pkg.Collection) bool {
if packages == nil {
return false
}
for p := range packages.Enumerate(pkg.DebPkg) {
if esmVersionPattern.MatchString(p.Version) {
return true
}
}
return false
return slices.ContainsFunc(packages.Sorted(pkg.DebPkg), func(p pkg.Package) bool {
return esmVersionPattern.MatchString(p.Version)
})
}
func fileMatchesAny(resolver file.Resolver, location file.Location, patterns ...*regexp.Regexp) (bool, error) {