-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Open
Labels
kind/bugCategorizes issue or PR as related to a bug.Categorizes issue or PR as related to a bug.
Milestone
Description
Description
There are two problems with the current logic:
mvn
may fill version and scope from multiple dependencyManagement sections (root + parent POMs).
For example, for a child dependency we might:- take the version from the parent, and
- take the scope from the root POM.
- We should not overwrite the test scope from the root (upper) dependencyManagement.
Correct logic
We should use the following order to Resolve dependencies:
- Fill empty fields with values from dependencyManagement.
- Overwrite non-empty fields with values from the root dependencyManagement.
2.1. Exception: if a dependency has thetest
scope (either defined explicitly or inherited from dependencyManagement), we must NOT overwrite itwith the value from the root dependencyManagement.
Tests
Test with different combinations of these fields can be found in this test - https://github.com/DmitriyLewen/trivy/blob/ffaa6a13bf586280fa18f1f21247d8908db53382/pkg/dependency/parser/java/pom/parse_test.go#L2141-L2201
Metadata
Metadata
Assignees
Labels
kind/bugCategorizes issue or PR as related to a bug.Categorizes issue or PR as related to a bug.