fix: golang version file regex (#4694)

Signed-off-by: Keith Zantow <kzantow@gmail.com>
This commit is contained in:
Keith Zantow 2026-03-23 15:56:29 -04:00 committed by GitHub
parent f5d318d934
commit 834ddcb1c0
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 15 additions and 3 deletions

View File

@ -727,6 +727,16 @@ func Test_Cataloger_PositiveCases(t *testing.T) {
{
// TODO: find original binary...
// note: cannot find the original binary, using a custom snippet based on the original snippet in the repo
logicalFixture: "go-version-hint/1.15-dev/any",
expected: pkg.Package{
Name: "go",
Version: "1.15",
PURL: "pkg:generic/go@1.15",
Locations: locations("bin/go", "VERSION"),
Metadata: metadata("go-binary"),
},
},
{
logicalFixture: "go-version-hint/1.15/any",
expected: pkg.Package{
Name: "go",

View File

@ -76,10 +76,10 @@ func DefaultClassifiers() []binutils.Classifier {
`(?m)go(?P<version>[0-9]+\.[0-9]+(\.[0-9]+|beta[0-9]+|alpha[0-9]+|rc[0-9]+)?)\x00`),
binutils.SupportingEvidenceMatcher("VERSION*",
m.FileContentsVersionMatcher(
`(?m)go(?P<version>[0-9]+\.[0-9]+(\.[0-9]+|beta[0-9]+|alpha[0-9]+|rc[0-9]+|-[_0-9a-z]+)?)\s`)),
`(?m)go(?P<version>[0-9]+\.[0-9]+(\.[0-9]+|beta[0-9]+|alpha[0-9]+|rc[0-9]+|-[_0-9a-z]+)?)`)),
binutils.SupportingEvidenceMatcher("../VERSION*",
m.FileContentsVersionMatcher(
`(?m)go(?P<version>[0-9]+\.[0-9]+(\.[0-9]+|beta[0-9]+|alpha[0-9]+|rc[0-9]+|-[_0-9a-z]+)?)\s`)),
`(?m)go(?P<version>[0-9]+\.[0-9]+(\.[0-9]+|beta[0-9]+|alpha[0-9]+|rc[0-9]+|-[_0-9a-z]+)?)`)),
),
Package: "go",
PURL: mustPURL("pkg:generic/go@version"),

View File

@ -0,0 +1 @@
go1.15 Fri 2003

View File

@ -0,0 +1 @@
no version in this binary