From cb1fb547e0bfd126741118c2bbf29764f5f03614 Mon Sep 17 00:00:00 2001 From: Keith Zantow Date: Mon, 19 Dec 2022 16:53:49 -0500 Subject: [PATCH] fix: openjdk detection pattern Signed-off-by: Keith Zantow --- syft/pkg/cataloger/binary/cataloger_test.go | 14 ++++++++++++++ syft/pkg/cataloger/binary/default_classifiers.go | 3 ++- .../classifiers/positive/openjdk-lts/java | Bin 0 -> 124 bytes 3 files changed, 16 insertions(+), 1 deletion(-) create mode 100644 syft/pkg/cataloger/binary/test-fixtures/classifiers/positive/openjdk-lts/java diff --git a/syft/pkg/cataloger/binary/cataloger_test.go b/syft/pkg/cataloger/binary/cataloger_test.go index 057f819272a1..91f22aa5cd09 100644 --- a/syft/pkg/cataloger/binary/cataloger_test.go +++ b/syft/pkg/cataloger/binary/cataloger_test.go @@ -116,6 +116,20 @@ func TestClassifierCataloger_DefaultClassifiers_PositiveCases(t *testing.T) { }, }, }, + { + name: "positive-java-openjdk-lts", + fixtureDir: "test-fixtures/classifiers/positive/openjdk-lts", + expected: pkg.Package{ + Name: "java", + Version: "11.0.17+8-LTS", + Type: "binary", + Locations: singleLocation("java"), + Metadata: pkg.BinaryMetadata{ + Classifier: "java-binary-openjdk", + VirtualPath: "java", + }, + }, + }, { name: "positive-java-oracle", fixtureDir: "test-fixtures/classifiers/positive/oracle", diff --git a/syft/pkg/cataloger/binary/default_classifiers.go b/syft/pkg/cataloger/binary/default_classifiers.go index 01066663a855..f1bd5243cab9 100644 --- a/syft/pkg/cataloger/binary/default_classifiers.go +++ b/syft/pkg/cataloger/binary/default_classifiers.go @@ -38,8 +38,9 @@ var defaultClassifiers = []classifier{ Class: "java-binary-openjdk", FileGlob: "**/java", EvidenceMatcher: fileContentsVersionMatcher( + // [NUL]openjdk[NUL]java[NUL]0.0[NUL]11.0.17+8-LTS[NUL] // [NUL]openjdk[NUL]java[NUL]1.8[NUL]1.8.0_352-b08[NUL] - `(?m)\x00openjdk\x00java\x00(?P[0-9]+[.0-9]+)\x00(?P[0-9]+[-._a-zA-Z0-9]+)\x00`), + `(?m)\x00openjdk\x00java\x00(?P[0-9]+[.0-9]*)\x00(?P[0-9]+[^\x00]+)\x00`), Package: "java", // TODO the updates might need to be part of the CPE, like: 1.8.0:update152 CPEs: singleCPE("cpe:2.3:a:oracle:openjdk:*:*:*:*:*:*:*:*"), diff --git a/syft/pkg/cataloger/binary/test-fixtures/classifiers/positive/openjdk-lts/java b/syft/pkg/cataloger/binary/test-fixtures/classifiers/positive/openjdk-lts/java new file mode 100644 index 0000000000000000000000000000000000000000..ff283b3e81530f86a6d80c058c9f8dac0ac561da GIT binary patch literal 124 zcmY#Z$Vx0rRPYH2Rwzg;DM>BLljloIPBF;$2*w zLfsks{6k!=6aq4nvr|(PN(&TJi>-i|A-^CsFDoUR0c0wJft~?_p`o6Eo}sz6g)Yzz S23;@R++vGd21aRSYc2rv(;^N4 literal 0 HcmV?d00001