fix(analyzer): detect OpenSSL 3.x in OpenSSLAnalyzer#8484
Conversation
There was a problem hiding this comment.
Pull request overview
This PR updates OpenSSLAnalyzer so it can correctly extract versions from OpenSSL 3.x source headers, where OPENSSL_VERSION_NUMBER is no longer a literal hex constant and therefore doesn’t match the legacy regex. This ensures OpenSSL 3.x scans produce version evidence and identifiers (e.g., CPE/PURL), enabling NVD CVE matching.
Changes:
- Add detection for OpenSSL 3.x by parsing
OPENSSL_VERSION_STR "X.Y.Z"before falling back to the legacyOPENSSL_VERSION_NUMBERpattern. - Add an OpenSSL 3.5.6
opensslv.htest fixture undercoretest resources. - Add a new unit test asserting
3.5.6is extracted from the OpenSSL 3.x header.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| core/src/main/java/org/owasp/dependencycheck/analyzer/OpenSSLAnalyzer.java | Adds a new regex path to extract OpenSSL 3.x versions via OPENSSL_VERSION_STR, preserving the existing 1.x detection fallback. |
| core/src/test/java/org/owasp/dependencycheck/analyzer/OpenSSLAnalyzerTest.java | Adds a unit test covering OpenSSL 3.x header parsing (3.5.6). |
| core/src/test/resources/openssl-3x/opensslv.h | Introduces a real-world OpenSSL 3.5.6 opensslv.h fixture for regression coverage. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
This analyzer is super curious to me given how specific it is. I wonder how many people use it - are you a user? 😅 |
OpenSSL 3.x defines OPENSSL_VERSION_NUMBER as a macro expression rather than a literal hex constant, so the existing regex never matches and the analyzer drops the dependency. As a result, 3.x source trees produce no CPE and never match NVD CVEs. Add a second pattern that captures OPENSSL_VERSION_STR "X.Y.Z" (introduced in 3.0); fall back to the legacy NUMBER pattern for 1.x and earlier. Adds a test fixture/case using opensslv.h from OpenSSL 3.5.6.
089d77b to
a3ae98f
Compare
Yes. 💯 |
Summary
OpenSSLAnalyzercannot detect OpenSSL 3.x sources today: 3.x definesOPENSSL_VERSION_NUMBERas a macro expression (not a literal hex constant), the existing regex never matches, and the dependency is dropped viaengine.removeDependency(). As a result a scan over an OpenSSL 3.x source tree produces no CPE and never matches NVD CVEs.OPENSSL_VERSION_STR "X.Y.Z"(introduced in OpenSSL 3.0) and tries it before falling back to the legacyOPENSSL_VERSION_NUMBERhex pattern, so 1.x detection is preserved.core/src/test/resources/openssl-3x/opensslv.hfrom OpenSSL 3.5.6) and a parallel test case asserting3.5.6is extracted.Reproducer (before this change)
Scan an OpenSSL 3.5.6 source tree:
The resulting JSON has no dependency for
opensslv.hand nocpe:2.3:a:openssl:openssl:3.5.6:*identifier. After this change the same scan produces:Test plan
mvn -pl core -am test -Dtest=OpenSSLAnalyzerTest -Dsurefire.failIfNoSpecifiedTests=false— 5/5 pass (existing 4 + newtestOpenSSL3xVersionHeaderFile)cpe:2.3:a:openssl:openssl:3.5.6is now attached to theopensslv.hdependency