mirror of
https://github.com/anchore/syft.git
synced 2025-11-17 16:33:21 +01:00
fix: improve node classifier version matching (#3284)
Signed-off-by: witchcraze <witchcraze@gmail.com>
This commit is contained in:
parent
1a746b2c05
commit
2a3d171c10
@ -625,6 +625,36 @@ func Test_Cataloger_PositiveCases(t *testing.T) {
|
|||||||
Metadata: metadata("go-binary"),
|
Metadata: metadata("go-binary"),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
logicalFixture: "node/0.10.48/linux-amd64",
|
||||||
|
expected: pkg.Package{
|
||||||
|
Name: "node",
|
||||||
|
Version: "0.10.48",
|
||||||
|
PURL: "pkg:generic/node@0.10.48",
|
||||||
|
Locations: locations("node"),
|
||||||
|
Metadata: metadata("nodejs-binary"),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
logicalFixture: "node/0.12.18/linux-amd64",
|
||||||
|
expected: pkg.Package{
|
||||||
|
Name: "node",
|
||||||
|
Version: "0.12.18",
|
||||||
|
PURL: "pkg:generic/node@0.12.18",
|
||||||
|
Locations: locations("node"),
|
||||||
|
Metadata: metadata("nodejs-binary"),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
logicalFixture: "node/4.9.1/linux-amd64",
|
||||||
|
expected: pkg.Package{
|
||||||
|
Name: "node",
|
||||||
|
Version: "4.9.1",
|
||||||
|
PURL: "pkg:generic/node@4.9.1",
|
||||||
|
Locations: locations("node"),
|
||||||
|
Metadata: metadata("nodejs-binary"),
|
||||||
|
},
|
||||||
|
},
|
||||||
{
|
{
|
||||||
logicalFixture: "node/19.2.0/linux-amd64",
|
logicalFixture: "node/19.2.0/linux-amd64",
|
||||||
expected: pkg.Package{
|
expected: pkg.Package{
|
||||||
|
|||||||
@ -153,8 +153,14 @@ func DefaultClassifiers() []Classifier {
|
|||||||
{
|
{
|
||||||
Class: "nodejs-binary",
|
Class: "nodejs-binary",
|
||||||
FileGlob: "**/node",
|
FileGlob: "**/node",
|
||||||
EvidenceMatcher: FileContentsVersionMatcher(
|
EvidenceMatcher: evidenceMatchers(
|
||||||
`(?m)node\.js\/v(?P<version>[0-9]+\.[0-9]+\.[0-9]+)`),
|
// [NUL]node v0.10.48[NUL]
|
||||||
|
// [NUL]v0.12.18[NUL]
|
||||||
|
// [NUL]v4.9.1[NUL]
|
||||||
|
// node.js/v22.9.0
|
||||||
|
FileContentsVersionMatcher(`(?m)\x00(node )?v(?P<version>(0|4|5)\.[0-9]+\.[0-9]+)\x00`),
|
||||||
|
FileContentsVersionMatcher(`(?m)node\.js\/v(?P<version>[0-9]+\.[0-9]+\.[0-9]+)`),
|
||||||
|
),
|
||||||
Package: "node",
|
Package: "node",
|
||||||
PURL: mustPURL("pkg:generic/node@version"),
|
PURL: mustPURL("pkg:generic/node@version"),
|
||||||
CPEs: singleCPE("cpe:2.3:a:nodejs:node.js:*:*:*:*:*:*:*:*", cpe.NVDDictionaryLookupSource),
|
CPEs: singleCPE("cpe:2.3:a:nodejs:node.js:*:*:*:*:*:*:*:*", cpe.NVDDictionaryLookupSource),
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -256,6 +256,27 @@ from-images:
|
|||||||
paths:
|
paths:
|
||||||
- /usr/local/openresty/nginx/sbin/nginx
|
- /usr/local/openresty/nginx/sbin/nginx
|
||||||
|
|
||||||
|
- version: 0.10.48
|
||||||
|
images:
|
||||||
|
- ref: node:0.10.48@sha256:c32b4d56f05c69df6e87d06bf7d5f6a5c6a0e7bcdb8e5ffab0e7a1853a90008f
|
||||||
|
platform: linux/amd64
|
||||||
|
paths:
|
||||||
|
- /usr/local/bin/node
|
||||||
|
|
||||||
|
- version: 0.12.18
|
||||||
|
images:
|
||||||
|
- ref: node:0.12.18@sha256:02e8e9903c8d974e8874d0144413d398a41d62f54bafec4d2cf3ac2a8501dd28
|
||||||
|
platform: linux/amd64
|
||||||
|
paths:
|
||||||
|
- /usr/local/bin/node
|
||||||
|
|
||||||
|
- version: 4.9.1
|
||||||
|
images:
|
||||||
|
- ref: node:4.9.1@sha256:41d0ad2557ea2a9e57e1a458c1d659e92f601586e07dcffef74c9cef542f6f6e
|
||||||
|
platform: linux/amd64
|
||||||
|
paths:
|
||||||
|
- /usr/local/bin/node
|
||||||
|
|
||||||
- version: 19.2.0
|
- version: 19.2.0
|
||||||
images:
|
images:
|
||||||
- ref: node:19.2.0@sha256:9bf5846b28f63acab0ccb0a39a245fbc414e6b7ecd467282f58016537c06e159
|
- ref: node:19.2.0@sha256:9bf5846b28f63acab0ccb0a39a245fbc414e6b7ecd467282f58016537c06e159
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user