Skip to content

Commit

Permalink
fix: openjdk detection pattern (#1415)
Browse files Browse the repository at this point in the history
  • Loading branch information
kzantow authored Dec 20, 2022
1 parent 0f1e8fc commit b1d6dae
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
14 changes: 14 additions & 0 deletions syft/pkg/cataloger/binary/cataloger_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
3 changes: 2 additions & 1 deletion syft/pkg/cataloger/binary/default_classifiers.go
Original file line number Diff line number Diff line change
Expand Up @@ -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<release>[0-9]+[.0-9]+)\x00(?P<version>[0-9]+[-._a-zA-Z0-9]+)\x00`),
`(?m)\x00openjdk\x00java\x00(?P<release>[0-9]+[.0-9]*)\x00(?P<version>[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:*:*:*:*:*:*:*:*"),
Expand Down
Binary file not shown.

0 comments on commit b1d6dae

Please sign in to comment.