From e7b6284039c7082c3546d9b2dc15510cb240dd7c Mon Sep 17 00:00:00 2001 From: Laurent Goderre Date: Tue, 7 May 2024 12:06:32 -0400 Subject: [PATCH] Add binary classifier for ArangoDB (#2830) Signed-off-by: Laurent Goderre --- .../cataloger/binary/classifier_cataloger_test.go | 11 +++++++++++ syft/pkg/cataloger/binary/classifiers.go | 9 +++++++++ .../snippets/arangodb/3.11.8/linux-amd64/arangosh | Bin 0 -> 353 bytes .../cataloger/binary/test-fixtures/config.yaml | 7 +++++++ 4 files changed, 27 insertions(+) create mode 100644 syft/pkg/cataloger/binary/test-fixtures/classifiers/snippets/arangodb/3.11.8/linux-amd64/arangosh diff --git a/syft/pkg/cataloger/binary/classifier_cataloger_test.go b/syft/pkg/cataloger/binary/classifier_cataloger_test.go index 64e7074ed..ba87b50d9 100644 --- a/syft/pkg/cataloger/binary/classifier_cataloger_test.go +++ b/syft/pkg/cataloger/binary/classifier_cataloger_test.go @@ -37,6 +37,17 @@ func Test_Cataloger_PositiveCases(t *testing.T) { logicalFixture string expected pkg.Package }{ + { + logicalFixture: "arangodb/3.11.8/linux-amd64", + expected: pkg.Package{ + Name: "arangodb", + Version: "3.11.8", + Type: "binary", + PURL: "pkg:generic/arangodb@3.11.8", + Locations: locations("arangosh"), + Metadata: metadata("arangodb-binary"), + }, + }, { logicalFixture: "postgres/15beta4/linux-amd64", expected: pkg.Package{ diff --git a/syft/pkg/cataloger/binary/classifiers.go b/syft/pkg/cataloger/binary/classifiers.go index d0fb9e309..e8952fbd1 100644 --- a/syft/pkg/cataloger/binary/classifiers.go +++ b/syft/pkg/cataloger/binary/classifiers.go @@ -259,6 +259,15 @@ func DefaultClassifiers() []Classifier { PURL: mustPURL("pkg:generic/traefik@version"), CPEs: singleCPE("cpe:2.3:a:traefik:traefik:*:*:*:*:*:*:*:*"), }, + { + Class: "arangodb-binary", + FileGlob: "**/arangosh", + EvidenceMatcher: FileContentsVersionMatcher( + `(?m)ArangoDB\s\x00*(?P[0-9]+\.[0-9]+\.[0-9]+)\s\[linux\]`), + Package: "arangodb", + PURL: mustPURL("pkg:generic/arangodb@version"), + CPEs: singleCPE("cpe:2.3:a:arangodb:arangodb:*:*:*:*:*:*:*:*"), + }, { Class: "postgresql-binary", FileGlob: "**/postgres", diff --git a/syft/pkg/cataloger/binary/test-fixtures/classifiers/snippets/arangodb/3.11.8/linux-amd64/arangosh b/syft/pkg/cataloger/binary/test-fixtures/classifiers/snippets/arangodb/3.11.8/linux-amd64/arangosh new file mode 100644 index 0000000000000000000000000000000000000000..517f58e450d13c1b0626958bbff6cfc3b12740a6 GIT binary patch literal 353 zcmXv}xlY6|5Otle7-`!j@*QV878*JPf(B98<8cx;8?O?F^Au8ZM=(Mw+_PA3#W6Ez@whP*8m)~{xI~i2Wm-f8{@bBSnL literal 0 HcmV?d00001 diff --git a/syft/pkg/cataloger/binary/test-fixtures/config.yaml b/syft/pkg/cataloger/binary/test-fixtures/config.yaml index 466f0d40f..255843a5e 100644 --- a/syft/pkg/cataloger/binary/test-fixtures/config.yaml +++ b/syft/pkg/cataloger/binary/test-fixtures/config.yaml @@ -270,6 +270,13 @@ from-images: # paths: # - /usr/bin/perl + - name: arangodb + version: 3.11.8 + images: + - ref: arangodb:3.11.8@sha256:16893e767f47d28e3297839637741e5c4023e815adf860dfc674e1a36c7c7db0 + platform: linux/amd64 + paths: + - /usr/bin/arangosh - version: 15.1 images: - ref: postgres:15.1@sha256:b4140dd3a62f364f16a82c1bd88d28b9887ecb47f07dbe2941237d073574d428