mirror of
https://github.com/anchore/syft.git
synced 2026-02-12 02:26:42 +01:00
fix: further improve go binary classifier, including windows (#4593)
Signed-off-by: Keith Zantow <kzantow@gmail.com>
This commit is contained in:
parent
d22139ef1a
commit
add2629446
@ -48,7 +48,7 @@ catalogers:
|
||||
type: BinaryPkg
|
||||
- method: glob
|
||||
criteria:
|
||||
- '**/go'
|
||||
- '**/{go,go.exe}'
|
||||
packages:
|
||||
- class: go-binary
|
||||
name: go
|
||||
|
||||
@ -736,6 +736,26 @@ func Test_Cataloger_PositiveCases(t *testing.T) {
|
||||
Metadata: metadata("go-binary"),
|
||||
},
|
||||
},
|
||||
{
|
||||
logicalFixture: "go-version-hint/1.15w/any",
|
||||
expected: pkg.Package{
|
||||
Name: "go",
|
||||
Version: "1.15",
|
||||
PURL: "pkg:generic/go@1.15",
|
||||
Locations: locations("bin/go.exe", "VERSION"),
|
||||
Metadata: metadata("go-binary"),
|
||||
},
|
||||
},
|
||||
{
|
||||
logicalFixture: "go-version-hint/1.21/any",
|
||||
expected: pkg.Package{
|
||||
Name: "go",
|
||||
Version: "1.21",
|
||||
PURL: "pkg:generic/go@1.21",
|
||||
Locations: locations("go", "VERSION"),
|
||||
Metadata: metadata("go-binary"),
|
||||
},
|
||||
},
|
||||
{
|
||||
// note: this is for compatability with dev version of golang tip image, which resolves the issue #3681
|
||||
logicalFixture: "go-version-hint/1.25/any",
|
||||
@ -747,6 +767,16 @@ func Test_Cataloger_PositiveCases(t *testing.T) {
|
||||
Metadata: metadata("go-binary"),
|
||||
},
|
||||
},
|
||||
{
|
||||
logicalFixture: "go-version-hint/1.25w/any",
|
||||
expected: pkg.Package{
|
||||
Name: "go",
|
||||
Version: "1.25-d524e1e",
|
||||
PURL: "pkg:generic/go@1.25-d524e1e",
|
||||
Locations: locations("go.exe", "VERSION"),
|
||||
Metadata: metadata("go-binary"),
|
||||
},
|
||||
},
|
||||
{
|
||||
// note: this is testing BUSYBOX which is typically through a link to "[" (in this case a symlink but in
|
||||
// practice this is often a hard link).
|
||||
|
||||
@ -70,14 +70,16 @@ func DefaultClassifiers() []binutils.Classifier {
|
||||
},
|
||||
{
|
||||
Class: "go-binary",
|
||||
FileGlob: "**/go",
|
||||
FileGlob: "**/{go,go.exe}",
|
||||
EvidenceMatcher: binutils.MatchAny(
|
||||
m.FileContentsVersionMatcher(
|
||||
`(?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`)),
|
||||
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]+)?)\s`)),
|
||||
),
|
||||
Package: "go",
|
||||
PURL: mustPURL("pkg:generic/go@version"),
|
||||
|
||||
@ -0,0 +1 @@
|
||||
go1.15 Fri 2003
|
||||
@ -0,0 +1 @@
|
||||
no version in this binary
|
||||
@ -0,0 +1 @@
|
||||
go1.21 Fri 2003
|
||||
@ -0,0 +1 @@
|
||||
no version in this binary
|
||||
@ -0,0 +1,2 @@
|
||||
devel go1.25-d524e1e Sun Feb 16 07:23:13 2025 -0800
|
||||
3devel go1.25-d524e1e Sun Feb 16 07:23:13 2025 -0800
|
||||
@ -0,0 +1 @@
|
||||
no version in this binary
|
||||
Loading…
x
Reference in New Issue
Block a user