From 7815d8e4d990c9a4d3a23fbb1beaae66ee2429f8 Mon Sep 17 00:00:00 2001 From: Laurent Goderre Date: Mon, 23 Sep 2024 14:21:31 -0400 Subject: [PATCH] feat: classifier for Dart lang binaries (#3265) Signed-off-by: Laurent Goderre --- .../binary/classifier_cataloger_test.go | 22 ++++++++++++++++++ syft/pkg/cataloger/binary/classifiers.go | 10 ++++++++ .../snippets/dart/3.5.2/linux-amd64/dart | Bin 0 -> 348 bytes .../dart/3.6.0-216.1.beta/linux-amd64/dart | Bin 0 -> 348 bytes .../binary/test-fixtures/config.yaml | 14 +++++++++++ 5 files changed, 46 insertions(+) create mode 100644 syft/pkg/cataloger/binary/test-fixtures/classifiers/snippets/dart/3.5.2/linux-amd64/dart create mode 100644 syft/pkg/cataloger/binary/test-fixtures/classifiers/snippets/dart/3.6.0-216.1.beta/linux-amd64/dart diff --git a/syft/pkg/cataloger/binary/classifier_cataloger_test.go b/syft/pkg/cataloger/binary/classifier_cataloger_test.go index 22f59b1b39e..48744a612d7 100644 --- a/syft/pkg/cataloger/binary/classifier_cataloger_test.go +++ b/syft/pkg/cataloger/binary/classifier_cataloger_test.go @@ -961,6 +961,28 @@ func Test_Cataloger_PositiveCases(t *testing.T) { Metadata: metadata("swipl-binary"), }, }, + { + logicalFixture: "dart/3.5.2/linux-amd64", + expected: pkg.Package{ + Name: "dart", + Version: "3.5.2", + Type: "binary", + PURL: "pkg:generic/dart@3.5.2", + Locations: locations("dart"), + Metadata: metadata("dart-binary"), + }, + }, + { + logicalFixture: "dart/3.6.0-216.1.beta/linux-amd64", + expected: pkg.Package{ + Name: "dart", + Version: "3.6.0-216.1.beta", + Type: "binary", + PURL: "pkg:generic/dart@3.6.0-216.1.beta", + Locations: locations("dart"), + Metadata: metadata("dart-binary"), + }, + }, { logicalFixture: "haskell-ghc/9.6.5/linux-amd64", expected: pkg.Package{ diff --git a/syft/pkg/cataloger/binary/classifiers.go b/syft/pkg/cataloger/binary/classifiers.go index 0a2a1a9b856..52dc1549a8b 100644 --- a/syft/pkg/cataloger/binary/classifiers.go +++ b/syft/pkg/cataloger/binary/classifiers.go @@ -447,6 +447,16 @@ func DefaultClassifiers() []Classifier { PURL: mustPURL("pkg:generic/swipl@version"), CPEs: singleCPE("cpe:2.3:a:erlang:erlang\\/otp:*:*:*:*:*:*:*:*", cpe.NVDDictionaryLookupSource), }, + { + Class: "dart-binary", + FileGlob: "**/dart", + EvidenceMatcher: FileContentsVersionMatcher( + `(?m)Dart,GC"\x00(?P[0-9]+\.[0-9]+\.[0-9]+(-[0-9]+(\.[0-9]+)?\.beta)?) `, + ), + Package: "dart", + PURL: mustPURL("pkg:generic/dart@version"), + CPEs: singleCPE("cpe:2.3:a:dart:dart_software_development_kit:*:*:*:*:*:*:*:*", cpe.NVDDictionaryLookupSource), + }, { Class: "haskell-ghc-binary", FileGlob: "**/ghc*", diff --git a/syft/pkg/cataloger/binary/test-fixtures/classifiers/snippets/dart/3.5.2/linux-amd64/dart b/syft/pkg/cataloger/binary/test-fixtures/classifiers/snippets/dart/3.5.2/linux-amd64/dart new file mode 100644 index 0000000000000000000000000000000000000000..226f7c3c4b3868323382f4611f5847c99bb49349 GIT binary patch literal 348 zcmXv}L2AP=5X{-H*f^Jjh9Ipi%QEy(QYgI@dg!sNq?KcEEE6kf^84!0&TV#>nVpHw z+<~V{Dq;u=rw*h>ql_*_p89mk97VBA!#s2PJQ1oUpS&SiV?eH}z?QV2##NO-(~?u9 zr6J>t#fH3*t#1QWZDmz$5ZmC4FTybLe^@|4(i&r#vm3P%h#XWS8|SUYVA(70Or^ES z=FkMCRUKNP9itSrD2mNy1NM;^{@#QXA;fWvKai#3xje@6oEtCu*F1Fpb}U!bK^+jb zOCme+4z^$H;pN%`wjf0(WQPJ!U=2?qV+V19avY}X{rle3(^b literal 0 HcmV?d00001 diff --git a/syft/pkg/cataloger/binary/test-fixtures/classifiers/snippets/dart/3.6.0-216.1.beta/linux-amd64/dart b/syft/pkg/cataloger/binary/test-fixtures/classifiers/snippets/dart/3.6.0-216.1.beta/linux-amd64/dart new file mode 100644 index 0000000000000000000000000000000000000000..7a4f9a5d0b33308922b7454eb1002111cd036dbe GIT binary patch literal 348 zcmXw!y=uci5QJUpDK>HwgDvi7btel_IS|qXT%-(pce}PgmV|Xl?6;2sNi#4E%zQJ@ zgQVhNzQtuwUXK>Ur5*Uf0<1+i74_Cy;WqK!AKMu>r!k8T@n$;PHRk! z>@kY>Y|S2dffP!yDAwyWgnMTA!-PD7jD0_T!x9xw