Trivy is miscalculating (some) transitive dependencies as can be verified by the aforementioned materials and the Maven dependency tree for the aforementioned pom:
By comparing which versions are correctly resolved against the ones which are not, we can spot the pattern: all miscalculated versions are resolved from ${project.version}:
Note that both jruby-base and jruby-stdlib have their <version>${project.version}</version> resolved to 7, which, is the end-of-the-line of this inheritance path (jruby > jruby-parent > oss-parent)
The same behavior can be found when resolving the dependencies from zookeeper. Note that zookeeper-jute version is not correctly resolved for the same reasons as jruby dependencies. On the other hand, audience-annotations is correctly resolved as it is declared differently:
Description
Trivy miscalculates the version of transitive dependencies when their version is set to
${project.version}
.This behavior can be easily verified when comparing the output of
mvn dependency:tree
againsttrivy fs --format cyclonedx
.For example, use the pom below, which contains
org.jruby:jruby@9.4.2.0
andorg.apache.zookeeper:zookeeper@3.7.1
.What did you expect to happen?
Trivy should resolve the following dependencies:
What happened instead?
Trivy miscalculates the following transitive dependencies
Output of run with
-debug
:Output of
trivy -v
:note: I have also performed the same test with canary Version: 0.39.0-SNAPSHOT-c42f360f5 and the issue persists
Additional details (base image name, container registry info...):
Trivy is miscalculating (some) transitive dependencies as can be verified by the aforementioned materials and the Maven dependency tree for the aforementioned pom:
By comparing which versions are correctly resolved against the ones which are not, we can spot the pattern: all miscalculated versions are resolved from
${project.version}
:jruby-9.4.2.0.pom (trimmed)
Note that both
jruby-base
andjruby-stdlib
have their<version>${project.version}</version>
resolved to 7, which, is the end-of-the-line of this inheritance path (jruby > jruby-parent > oss-parent)jruby-artifacts-9.4.2.0.pom
jruby-parent-9.4.2.0.pom
oss-parent-7.pom
The same behavior can be found when resolving the dependencies from zookeeper. Note that zookeeper-jute version is not correctly resolved for the same reasons as jruby dependencies. On the other hand, audience-annotations is correctly resolved as it is declared differently:
zookeeper-3.7.1.pom (trimmed)
parent-3.7.1.pom (trimmed)
Possibly related issues
The issues below appear to share some similarities but do not seem to source from the same issue: