Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(java): correctly overwrite version from depManagement if dependency uses project.* props #8050

Merged

Conversation

DmitriyLewen
Copy link
Contributor

Description

We should use resolved dependencies (with replaceable properties) to find dependencies in depManagements.

example:
pom file:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>com.bbb.aaa</groupId>
    <artifactId>aaa</artifactId>
    <version>1.0.0</version>
    <packaging>pom</packaging>
    <name>aaa</name>
    <description>desc</description>

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>3.2.11</version>
        <relativePath />
    </parent>

    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>io.netty</groupId>
                <artifactId>netty-common</artifactId>
                <version>4.1.115.Final</version>
            </dependency>
        </dependencies>
    </dependencyManagement>

    <dependencies>
        <dependency>
            <groupId>io.projectreactor.netty</groupId>
            <artifactId>reactor-netty-core</artifactId>
            <version>1.1.23</version>
            <scope>runtime</scope>
        </dependency>
    </dependencies>
</project>

changes:

➜ diff <(trivy -q fs . --list-all-pkgs -f json | grep '"ID": "io.netty:netty-') <(./trivy -q fs . --list-all-pkgs -f json | grep '"ID": "io.netty:netty-')
6c6
<           "ID": "io.netty:netty-common:4.1.114.Final",
---
>           "ID": "io.netty:netty-common:4.1.115.Final",

Related issues

Checklist

  • I've read the guidelines for contributing to this repository.
  • I've followed the conventions in the PR title.
  • I've added tests that prove my fix is effective or that my feature works.
  • I've updated the documentation with the relevant information (if needed).
  • I've added usage information (if the PR introduces new options)
  • I've included a "before" and "after" example to the description (if the PR is a user interface change).

@DmitriyLewen DmitriyLewen self-assigned this Dec 5, 2024
@DmitriyLewen DmitriyLewen marked this pull request as ready for review December 5, 2024 06:56
@knqyf263 knqyf263 added this pull request to the merge queue Dec 5, 2024
Merged via the queue into aquasecurity:main with commit 9d9f80d Dec 5, 2024
12 checks passed
@DmitriyLewen DmitriyLewen deleted the fix/pom-project-props-dep-menagament branch December 11, 2024 09:29
@DmitriyLewen
Copy link
Contributor Author

@aqua-bot backport release/v0.58

@aqua-bot
Copy link
Contributor

Backport PR created: #8119

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

bug(pom): Trivy doesn't overwrite version from depManagement if dependency uses project.groupId prop
3 participants