fix: go version not properly identified in binary (#1384)

This commit is contained in:
Keith Zantow 2022-12-02 13:24:36 -05:00 committed by GitHub
parent 247b054ab5
commit 614ea00905
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 17 additions and 5 deletions

View File

@ -1,9 +1,9 @@
// Code generated by go generate; DO NOT EDIT.
// This file was generated by robots at 2022-10-14 11:46:16.097525 -0400 EDT m=+0.276930979
// This file was generated by robots at 2022-12-02 12:51:33.814385 -0500 EST m=+1.688731869
// using data from https://spdx.org/licenses/licenses.json
package spdxlicense
const Version = "3.18"
const Version = "3.19"
var licenseIDs = map[string]string{
"0bsd": "0BSD",
@ -372,6 +372,7 @@ var licenseIDs = map[string]string{
"cern-ohl-w-2": "CERN-OHL-W-2.0",
"cern-ohl-w-2.0": "CERN-OHL-W-2.0",
"cern-ohl-w-2.0.0": "CERN-OHL-W-2.0",
"checkmk": "checkmk",
"clartistic": "ClArtistic",
"cnri-jython": "CNRI-Jython",
"cnri-python": "CNRI-Python",
@ -470,6 +471,7 @@ var licenseIDs = map[string]string{
"fsfap": "FSFAP",
"fsful": "FSFUL",
"fsfullr": "FSFULLR",
"fsfullrwd": "FSFULLRWD",
"ftl": "FTL",
"gd": "GD",
"gfdl-1": "GFDL-1.1-only",
@ -617,6 +619,7 @@ var licenseIDs = map[string]string{
"jasper-2.0.0": "JasPer-2.0",
"jpnic": "JPNIC",
"json": "JSON",
"knuth-ctan": "Knuth-CTAN",
"lal-1": "LAL-1.2",
"lal-1.2": "LAL-1.2",
"lal-1.2.0": "LAL-1.2",
@ -665,6 +668,7 @@ var licenseIDs = map[string]string{
"libselinux-1.0": "libselinux-1.0",
"libselinux-1.0.0": "libselinux-1.0",
"libtiff": "libtiff",
"libutil-david-nugent": "libutil-David-Nugent",
"liliq-p-1": "LiLiQ-P-1.1",
"liliq-p-1.1": "LiLiQ-P-1.1",
"liliq-p-1.1.0": "LiLiQ-P-1.1",
@ -984,7 +988,7 @@ var licenseIDs = map[string]string{
"sspl-1": "SSPL-1.0",
"sspl-1.0": "SSPL-1.0",
"sspl-1.0.0": "SSPL-1.0",
"standardml-nj": "StandardML-NJ",
"standardml-nj": "SMLNJ",
"sugarcrm-1": "SugarCRM-1.1.3",
"sugarcrm-1.1": "SugarCRM-1.1.3",
"sugarcrm-1.1.3": "SugarCRM-1.1.3",

View File

@ -91,6 +91,12 @@ func fileNameTemplateVersionMatcher(fileNamePattern string, contentTemplate stri
}
}
func patternEndingWithNull(pattern string) string {
bytes := []byte(pattern)
bytes = append(bytes, 0)
return string(bytes)
}
func fileContentsVersionMatcher(pattern string) evidenceMatcher {
pat := regexp.MustCompile(pattern)
return func(classifier classifier, reader source.LocationReadCloser) ([]pkg.Package, error) {
@ -130,6 +136,7 @@ func singlePackage(classifier classifier, reader source.LocationReadCloser, vers
Locations: source.NewLocationSet(reader.Location),
Type: pkg.BinaryPkg,
CPEs: cpes,
FoundBy: catalogerName,
MetadataType: pkg.BinaryMetadataType,
Metadata: pkg.BinaryMetadata{
Classifier: classifier.Class,

View File

@ -29,9 +29,10 @@ var defaultClassifiers = []classifier{
{
Class: "go-binary",
FileGlob: "**/go",
EvidenceMatcher: fileContentsVersionMatcher(
`(?m)go(?P<version>[0-9]+\.[0-9]+(\.[0-9]+|beta[0-9]+|alpha[0-9]+|rc[0-9]+)?)`),
EvidenceMatcher: fileContentsVersionMatcher(patternEndingWithNull(
`(?m)go(?P<version>[0-9]+\.[0-9]+(\.[0-9]+|beta[0-9]+|alpha[0-9]+|rc[0-9]+)?)`)),
Package: "go",
CPEs: singleCPE("cpe:2.3:a:golang:go:*:*:*:*:*:*:*:*"),
},
{
Class: "nodejs-binary",