Skip to content

fix: improve PEAnalyzer reliability by migrating to maintained PE/COFF 4J library fork#8245

Merged
jeremylong merged 2 commits intodependency-check:mainfrom
chadlwilson:improve-pe-analyzer
Jan 25, 2026
Merged

fix: improve PEAnalyzer reliability by migrating to maintained PE/COFF 4J library fork#8245
jeremylong merged 2 commits intodependency-check:mainfrom
chadlwilson:improve-pe-analyzer

Conversation

@chadlwilson
Copy link
Copy Markdown
Collaborator

@chadlwilson chadlwilson commented Jan 24, 2026

Description of Change

  • Migrates to the semi-maintained fork at https://github.com/kichik/pecoff4j (already used for some minor fixes in-lined in code I believe) which fixes scanning on all of the failed DLLs I can find from reports.
    • avoided copy+pasting as much code as possible; which is easier due to some refactoring with the library.
    • reviewed the diff to the originally copied PEParser to find all changes to the upstream - only the lenient handling is missing
    • Fixes a file descriptor leak from not closing streams correctly
  • Adds the CLI arg to disable the PE analyzer.

Related issues

Scanning problems

CLI arg

Have test cases been added to cover the new functionality?

kinda.

@boring-cyborg boring-cyborg Bot added core changes to core tests test cases labels Jan 24, 2026
@chadlwilson chadlwilson requested a review from Copilot January 24, 2026 09:13
@boring-cyborg boring-cyborg Bot added cli changes to the cli documentation site documentation labels Jan 24, 2026
Comment on lines +51 to +56
/**
* Duplicates {@link PE#read(IDataReader)} with added error handling to swallow EOFExceptions to be more lenient
* for certain file sections.
* @see PE#read(IDataReader)
*/
private static PE read(IDataReader dr, String context) throws IOException {
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment on lines +104 to +108
/**
* Duplicates {@link PE#readDebugRawData(PE, DataEntry, IDataReader)} since it is private.
* @see PE#readDebugRawData(PE, DataEntry, IDataReader)
*/
private static void readDebugRawData(PE pe, DataEntry entry, IDataReader dr) throws IOException {
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR migrates the PEAnalyzer from the unmaintained org.whitesource:pecoff4j library (version 0.0.2.1) to a semi-maintained fork at com.kichik.pecoff4j (version 0.4.1). The primary goal is to fix EOFException errors that occur when scanning certain DLL files, making the analyzer more resilient to partially corrupt or non-standard PE files.

Changes:

  • Migrated dependency from org.whitesource:pecoff4j to com.kichik.pecoff4j fork (version 0.4.1)
  • Refactored PEParser to use the new library's API with enhanced EOFException handling for lenient parsing
  • Fixed resource leak by implementing proper try-with-resources for file streams
  • Added test case for jnidispatch.dll to verify parsing of files with partially broken image data
  • Fixed logger class reference and improved logging practices in PEAnalyzer

Reviewed changes

Copilot reviewed 9 out of 10 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
pom.xml Updated pecoff4j dependency groupId and version in dependency management
core/pom.xml Updated pecoff4j dependency groupId to match new fork
core/src/main/java/org/owasp/dependencycheck/utils/PEParser.java Simplified parser by delegating to library methods, added EOFException swallowing for lenient parsing, and fixed resource leak with try-with-resources
core/src/main/java/org/owasp/dependencycheck/analyzer/PEAnalyzer.java Updated imports to new library, migrated to new API methods (StringPair iteration, VersionInfo.read), fixed logger class, improved string checks, and updated logging to use parameterized format
core/src/test/java/org/owasp/dependencycheck/analyzer/PEAnalyzerTest.java Removed unused imports and added test for jnidispatch.dll parsing

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread pom.xml
Comment thread core/src/main/java/org/owasp/dependencycheck/analyzer/PEAnalyzer.java Outdated
Comment thread core/src/main/java/org/owasp/dependencycheck/utils/PEParser.java
Comment thread pom.xml
Comment on lines +1016 to +1018
<groupId>com.kichik.pecoff4j</groupId>
<artifactId>pecoff4j</artifactId>
<version>0.0.2.1</version>
<version>0.4.1</version>
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Whitesource seemed to originally fork from this repo; which imported from sourceforge/CVS anyway, according to https://github.com/whitesource/pecoff4j-maven so this shouldn't be a big concern.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 9 out of 10 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@chadlwilson chadlwilson changed the title fix: improve PEAnalyzer reliability by migrating to maintained(ish) fork fix: improve PEAnalyzer reliability by migrating to maintained fork Jan 24, 2026
@chadlwilson chadlwilson requested a review from Copilot January 24, 2026 09:30
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 9 out of 10 changed files in this pull request and generated no new comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@chadlwilson chadlwilson changed the title fix: improve PEAnalyzer reliability by migrating to maintained fork fix: improve PEAnalyzer reliability by migrating to maintained PE/COFF 4J library fork Jan 24, 2026
Copy link
Copy Markdown
Collaborator

@jeremylong jeremylong left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@jeremylong jeremylong merged commit 169bc44 into dependency-check:main Jan 25, 2026
14 of 15 checks passed
@jeremylong jeremylong added this to the 12.2.1 milestone Jan 25, 2026
@chadlwilson chadlwilson deleted the improve-pe-analyzer branch January 25, 2026 15:24
@github-actions github-actions Bot locked as resolved and limited conversation to collaborators Feb 25, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

cli changes to the cli core changes to core documentation site documentation tests test cases

Projects

None yet

3 participants