From 63e7a004cb50b25d04852978bd65b35023d2a03d Mon Sep 17 00:00:00 2001 From: Laurent Goderre Date: Fri, 22 Dec 2023 09:37:09 -0500 Subject: [PATCH] Added OpenSSL binary matcher (#2416) * Added OpenSSL binary matcher Signed-off-by: Laurent Goderre * chore: strip binary to smaller detection Signed-off-by: Christopher Phillips --------- Signed-off-by: Laurent Goderre Signed-off-by: Christopher Phillips Co-authored-by: Christopher Phillips --- syft/pkg/cataloger/binary/cataloger_test.go | 12 ++++++++++++ syft/pkg/cataloger/binary/default_classifiers.go | 11 +++++++++++ .../classifiers/positive/openssl-3.1.4/openssl | Bin 0 -> 1414 bytes 3 files changed, 23 insertions(+) create mode 100755 syft/pkg/cataloger/binary/test-fixtures/classifiers/positive/openssl-3.1.4/openssl diff --git a/syft/pkg/cataloger/binary/cataloger_test.go b/syft/pkg/cataloger/binary/cataloger_test.go index e7aa36cd8..d38de2e41 100644 --- a/syft/pkg/cataloger/binary/cataloger_test.go +++ b/syft/pkg/cataloger/binary/cataloger_test.go @@ -763,6 +763,18 @@ func Test_Cataloger_DefaultClassifiers_PositiveCases(t *testing.T) { Metadata: metadata("bash-binary"), }, }, + { + name: "positive-openssl-3.1.4", + fixtureDir: "test-fixtures/classifiers/positive/openssl-3.1.4", + expected: pkg.Package{ + Name: "openssl", + Version: "3.1.4", + Type: "binary", + PURL: "pkg:generic/openssl@3.1.4", + Locations: locations("openssl"), + Metadata: metadata("openssl-binary"), + }, + }, } for _, test := range tests { diff --git a/syft/pkg/cataloger/binary/default_classifiers.go b/syft/pkg/cataloger/binary/default_classifiers.go index e3ecd58b1..95376052f 100644 --- a/syft/pkg/cataloger/binary/default_classifiers.go +++ b/syft/pkg/cataloger/binary/default_classifiers.go @@ -334,6 +334,17 @@ var defaultClassifiers = []classifier{ PURL: mustPURL("pkg:generic/bash@version"), CPEs: singleCPE("cpe:2.3:a:gnu:bash:*:*:*:*:*:*:*:*"), }, + { + Class: "openssl-binary", + FileGlob: "**/openssl", + EvidenceMatcher: fileContentsVersionMatcher( + // [NUL]OpenSSL 3.1.4' + `\x00OpenSSL (?P[0-9]+\.[0-9]+\.[0-9]+(-alpha[0-9]|-beta[0-9]|-rc[0-9])?)`, + ), + Package: "openssl", + PURL: mustPURL("pkg:generic/openssl@version"), + CPEs: singleCPE("cpe:2.3:a:openssl:openssl:*:*:*:*:*:*:*:*"), + }, } // in both binaries and shared libraries, the version pattern is [NUL]3.11.2[NUL] diff --git a/syft/pkg/cataloger/binary/test-fixtures/classifiers/positive/openssl-3.1.4/openssl b/syft/pkg/cataloger/binary/test-fixtures/classifiers/positive/openssl-3.1.4/openssl new file mode 100755 index 0000000000000000000000000000000000000000..a2fc1b69127e1b5c49759c7b986c0301a30c3344 GIT binary patch literal 1414 zcmbVMO>Yx15Vbh=hJ?g{%UmK-sVQw!kSM)GX_1f$jT(AJ&U$uZ$!o7{Z$tQZ2nmTR zKY$;>g(J+^+a`hZ!X7s3$$Y$d^TtBt2cS1Nd>-g0?6Bnu3s+hF2^AFRqb_wJBSPbh zE|y?rjp2kHqi;jpbP62r;v7AUuP)L_h+a5>v9#7jXamCFHg2Kg90uc2sSWP&M#H{q9Y{zZ@6UVYfO|Ghs)SNuDO*E`xA2y#GI{iD z#BKHUuHMLahyOq0*ZIg@aiSG(t=)z>6{8nTnmH4%ndQRSD7EDwI7_5^sA-a{hNl7g z+QQ`gE#w*QGKugfL$UBkkY<`t1d5LwO&lH3FcsVJDpy@aQ|@s7>3=V+qAdtr@BhS`OdQbY0%gAIXFR#4pcqMDAt^$L2fz9c z5B5%9z8LnNJbom^x%Z^BbOEf3gTy)`eP?md+y@Zmt|cU`pIm NAR{Pj=(6jnoj)=y#8UtO literal 0 HcmV?d00001