diff --git a/syft/pkg/cataloger/binary/classifier_cataloger_test.go b/syft/pkg/cataloger/binary/classifier_cataloger_test.go index b9c28a51f..fab2acce7 100644 --- a/syft/pkg/cataloger/binary/classifier_cataloger_test.go +++ b/syft/pkg/cataloger/binary/classifier_cataloger_test.go @@ -625,6 +625,36 @@ func Test_Cataloger_PositiveCases(t *testing.T) { 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", expected: pkg.Package{ diff --git a/syft/pkg/cataloger/binary/classifiers.go b/syft/pkg/cataloger/binary/classifiers.go index f12998069..fa4fcd870 100644 --- a/syft/pkg/cataloger/binary/classifiers.go +++ b/syft/pkg/cataloger/binary/classifiers.go @@ -153,8 +153,14 @@ func DefaultClassifiers() []Classifier { { Class: "nodejs-binary", FileGlob: "**/node", - EvidenceMatcher: FileContentsVersionMatcher( - `(?m)node\.js\/v(?P[0-9]+\.[0-9]+\.[0-9]+)`), + EvidenceMatcher: evidenceMatchers( + // [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(0|4|5)\.[0-9]+\.[0-9]+)\x00`), + FileContentsVersionMatcher(`(?m)node\.js\/v(?P[0-9]+\.[0-9]+\.[0-9]+)`), + ), Package: "node", PURL: mustPURL("pkg:generic/node@version"), CPEs: singleCPE("cpe:2.3:a:nodejs:node.js:*:*:*:*:*:*:*:*", cpe.NVDDictionaryLookupSource), diff --git a/syft/pkg/cataloger/binary/test-fixtures/classifiers/snippets/node/0.10.48/linux-amd64/node b/syft/pkg/cataloger/binary/test-fixtures/classifiers/snippets/node/0.10.48/linux-amd64/node new file mode 100644 index 000000000..c26292bba Binary files /dev/null and b/syft/pkg/cataloger/binary/test-fixtures/classifiers/snippets/node/0.10.48/linux-amd64/node differ diff --git a/syft/pkg/cataloger/binary/test-fixtures/classifiers/snippets/node/0.12.18/linux-amd64/node b/syft/pkg/cataloger/binary/test-fixtures/classifiers/snippets/node/0.12.18/linux-amd64/node new file mode 100644 index 000000000..24e280dcb Binary files /dev/null and b/syft/pkg/cataloger/binary/test-fixtures/classifiers/snippets/node/0.12.18/linux-amd64/node differ diff --git a/syft/pkg/cataloger/binary/test-fixtures/classifiers/snippets/node/4.9.1/linux-amd64/node b/syft/pkg/cataloger/binary/test-fixtures/classifiers/snippets/node/4.9.1/linux-amd64/node new file mode 100644 index 000000000..d4ccbf963 Binary files /dev/null and b/syft/pkg/cataloger/binary/test-fixtures/classifiers/snippets/node/4.9.1/linux-amd64/node differ diff --git a/syft/pkg/cataloger/binary/test-fixtures/config.yaml b/syft/pkg/cataloger/binary/test-fixtures/config.yaml index 36c1c0425..61db2433d 100644 --- a/syft/pkg/cataloger/binary/test-fixtures/config.yaml +++ b/syft/pkg/cataloger/binary/test-fixtures/config.yaml @@ -256,6 +256,27 @@ from-images: paths: - /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 images: - ref: node:19.2.0@sha256:9bf5846b28f63acab0ccb0a39a245fbc414e6b7ecd467282f58016537c06e159