This project demonstrates how to fix vulnerable transitive dependencies in a Java Maven project, specifically focusing on log4j vulnerabilities.
Your task is to update log4j-core to get rid of the vulnerabilities in this packages bill of materials. First review the vulnerabilities, then update the package.
- Fork and clone the repository:
git clone https://github.com/endorlabs/fixme-transitive-java.git
cd fixme-transitive-java- Build the project:
mvn clean install- View the dependency tree:
mvn dependency:treeKey findings:
anteros-coreis a direct dependency- It brings in potentially vulnerable
log4jversions as transitive dependencies
We'll use endorctl to scan the project for known vulnerabilities.
-
Initialize Endor Labs
Run the following command to authenticate with Endor Labs and set up your environment:./endorctl init --auth-mode <mode> --headless-mode
Replace
<mode>with your preferred authentication mode (e.g.,google,github, etc.). -
Authenticate via Portal
The command will output a URL. You can command-click (⌘+click) the link in your terminal to open the authentication portal.
Log in and copy the generated token. -
Complete Setup
Paste the token back into your terminal.
You'll then be prompted to select a tenant—choose the one you just created. -
Run the Vulnerability Scan
Once authenticated and configured, scan your codebase:./endorctl scan
This will analyze your project for security vulnerabilities.
- Update
anteros-coreversion inpom.xml:
<dependency>
<groupId>com.anteros</groupId>
<artifactId>anteros-core</artifactId>
<version>INSERT_LATEST_VERSION</version>
</dependency>- Rebuild and verify:
mvn clean install
mvn dependency:treeIf Option 1 doesn't resolve the issue, add this to your pom.xml inside of the <dependencies> section:
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<version>2.17.2</version>
</dependency>- Rebuild the project:
mvn clean install- Check the dependency tree again:
mvn dependency:tree- Run vulnerability scan:
./endorctl scanEnsure that log4j now appears with the safe version you specified.