Replies: 1 comment
-
|
Hi @askoog, thank you for the detailed report with a clear reproduction case! We investigated this and here's what's happening. How Maven handles thisMaven uses a two-phase approach for multi-module projects. In the first phase, it collects all reactor module POMs and registers their coordinates in an in-memory pool ( How Trivy handles thisTrivy performs static analysis of Implementing a reactor-like mechanism in Trivy would require significant changes to the POM parsing logic, which is already one of the more complex parts of the codebase. WorkaroundFor now, please install the BOM module into your local Maven repository before running Trivy: # Install just the BOM module
mvn install -pl bom
# Now Trivy will correctly resolve the BOM import
trivy fs .Feedback welcomeWe'd like to understand how common this scenario is before committing to the implementation effort. If you or others are frequently hitting this limitation, please let us know — it will help us prioritize this work. Feel free to upvote this discussion as well. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Description
In a maven multimodule project where one module is a
bomcontaining only<dependencyManagement>trivy fails to use it correctly for sub modules without any built artifacts in maven local repo. Trivy fails to find the managed dependencies, rendering erroneous output.Example project structure:
root pom:
bom/pom.xml:
project/pom.xml:
The
io.grpc:grpc-netty:1.77.1dependency provides (among others) transitive dependencies toio.netty:netty-codec-http:4.1.127.Finalandio.netty:netty-codec-http2:4.1.127.Final. These artifacts have reported CVEs that are fixed in the4.1.132.Finalversion which is managed in the bom module.Running
trivy fs .generatesWhich is not correct, the transitive dependencies in
project/pom.xmlare managed to versions that doesn't contain the CVE:S.See output from
mvn dependency:tree -Dverbose=trueHowever, if I first build the code with
mvn install, the output fromtrivy fs .is:which is correct. (note that
mvn installis required,mvn packageis not sufficient)Note also that running trivy with
--debugwithout first installing the artifacts prints an error row indicating that the bom is not used:Desired Behavior
Running
trivy fs .without first installing the maven artifacts should render the second output with no warningsActual Behavior
trivy reported findings that are incorrect, not using the managed version
Reproduction Steps
1. run "trivy fs ." on a project structure like the one described aboveTarget
Filesystem
Scanner
Vulnerability
Output Format
Table
Mode
Standalone
Debug Output
Operating System
mac os and linux
Version
Checklist
trivy clean --allBeta Was this translation helpful? Give feedback.
All reactions