Added OpenSSL binary matcher (#2416)

* Added OpenSSL binary matcher

Signed-off-by: Laurent Goderre <laurent.goderre@docker.com>

* chore: strip binary to smaller detection

Signed-off-by: Christopher Phillips <christopher.phillips@anchore.com>

---------

Signed-off-by: Laurent Goderre <laurent.goderre@docker.com>
Signed-off-by: Christopher Phillips <christopher.phillips@anchore.com>
Co-authored-by: Christopher Phillips <christopher.phillips@anchore.com>
This commit is contained in:
Laurent Goderre 2023-12-22 09:37:09 -05:00 committed by GitHub
parent 04e8c96822
commit 63e7a004cb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 23 additions and 0 deletions

View File

@ -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 {

View File

@ -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<version>[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]