From d1e4ecba4260e6b552f42c883e0c76a2826440b4 Mon Sep 17 00:00:00 2001 From: Laurent Goderre Date: Wed, 10 Jan 2024 10:59:25 -0500 Subject: [PATCH] feat: binary classifier for pypy (#2474) Signed-off-by: Laurent Goderre --- syft/pkg/cataloger/binary/cataloger_test.go | 10 ++++++++++ syft/pkg/cataloger/binary/default_classifiers.go | 8 ++++++++ .../7.3.14/linux-amd64/libpypy3.9-c.so | Bin 0 -> 360 bytes .../cataloger/binary/test-fixtures/config.yaml | 8 ++++++++ 4 files changed, 26 insertions(+) create mode 100644 syft/pkg/cataloger/binary/test-fixtures/classifiers/snippets/pypy-shared-lib/7.3.14/linux-amd64/libpypy3.9-c.so diff --git a/syft/pkg/cataloger/binary/cataloger_test.go b/syft/pkg/cataloger/binary/cataloger_test.go index 879617bce..6724e6d80 100644 --- a/syft/pkg/cataloger/binary/cataloger_test.go +++ b/syft/pkg/cataloger/binary/cataloger_test.go @@ -513,6 +513,16 @@ func Test_Cataloger_PositiveCases(t *testing.T) { }, }, }, + { + logicalFixture: "pypy-shared-lib/7.3.14/linux-amd64", + expected: pkg.Package{ + Name: "pypy", + Version: "7.3.14", + PURL: "pkg:generic/pypy@7.3.14", + Locations: locations("libpypy3.9-c.so"), + Metadata: metadata("pypy-binary-lib"), + }, + }, { logicalFixture: "go/1.21.3/linux-amd64", expected: pkg.Package{ diff --git a/syft/pkg/cataloger/binary/default_classifiers.go b/syft/pkg/cataloger/binary/default_classifiers.go index 8f54fd899..6adc136fb 100644 --- a/syft/pkg/cataloger/binary/default_classifiers.go +++ b/syft/pkg/cataloger/binary/default_classifiers.go @@ -38,6 +38,14 @@ func DefaultClassifiers() []Classifier { cpe.Must("cpe:2.3:a:python:python:*:*:*:*:*:*:*:*"), }, }, + { + Class: "pypy-binary-lib", + FileGlob: "**/libpypy*.so*", + EvidenceMatcher: FileContentsVersionMatcher( + `(?m)\[PyPy (?P[0-9]+\.[0-9]+\.[0-9]+)`), + Package: "pypy", + PURL: mustPURL("pkg:generic/pypy@version"), + }, { Class: "go-binary", FileGlob: "**/go", diff --git a/syft/pkg/cataloger/binary/test-fixtures/classifiers/snippets/pypy-shared-lib/7.3.14/linux-amd64/libpypy3.9-c.so b/syft/pkg/cataloger/binary/test-fixtures/classifiers/snippets/pypy-shared-lib/7.3.14/linux-amd64/libpypy3.9-c.so new file mode 100644 index 0000000000000000000000000000000000000000..1a53577dba0a2c0dafb90ab7e5bac79f960c154a GIT binary patch literal 360 zcmZWj%WA|h3@r5K{)8Z>LK|$^k>h+pj|)BaQ2dZLfiww?Vaeaulr01*#4wU(1}*-J z2bia@9owN>_Zr)M6>H8rmjR429U63E=H*((0TfEHFVnVhc^^G?Gyqa`Jy)QVB}JQj zH7Vshc@CK<_Si*hG)uYAs6 z@h(X0Z4AjON9?jDl8S