Pom.xml中的特定依赖未覆盖传递依赖
我正在使用 awssdk 这个依赖
<dependency>
<groupId>software.amazon.awssdk</groupId>
<artifactId>s3</artifactId>
<version>2.46.9</version>
</dependency>
通过 software.amazon.awssdk:netty-nio-client:jar:2.46.9:runtime 引入的 io.netty 依赖,版本为 4.1.132。
我们的Twistlock扫描针对该IO-Netty版本的漏洞提出警告(codec、handler、transport),我需要将这些模块升级到 4.1.133。
按照Google AI的建议:
要强制把升级推进到
4.1.132之上,你必须在你自己的<dependencyManagement>部分显式声明具体的Netty产物,或者如果你的AWS SDK版本支持,就使用Maven属性。
我按原样复制了Google提供的规格,如下:
<!-- Force the exact Netty versions to override AWS SDK -->
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-handler</artifactId>
<version>4.1.133.Final</version>
</dependency>
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-codec</artifactId>
<version>4.1.133.Final</version>
</dependency>
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-transport</artifactId>
<version>4.1.133.Final</version>
</dependency>
不过,在构建完成后,mvn-dependency:tree 表示这没有效果,子依赖仍然如下所示:
[INFO] | \- software.amazon.awssdk:netty-nio-client:jar:2.46.9:runtime
[INFO] | +- io.netty:netty-codec-http:jar:4.1.132.Final:runtime
[INFO] | +- io.netty:netty-codec-http2:jar:4.1.132.Final:runtime
[INFO] | +- io.netty:netty-codec:jar:4.1.132.Final:runtime
[INFO] | +- io.netty:netty-transport:jar:4.1.132.Final:runtime
[INFO] | +- io.netty:netty-common:jar:4.1.132.Final:runtime
[INFO] | +- io.netty:netty-buffer:jar:4.1.132.Final:runtime
[INFO] | +- io.netty:netty-handler:jar:4.1.132.Final:runtime
[INFO] | | \- io.netty:netty-transport-native-unix-common:jar:4.1.132.Final:runtime
[INFO] | +- io.netty:netty-transport-classes-epoll:jar:4.1.132.Final:runtime
[INFO] | \- io.netty:netty-resolver:jar:4.1.132.Final:runtime
虽然这对 awssdk:netty-nio-client 没有作用,但我看到它在 pom.xml 中独立地添加了这行:
[INFO] +- io.netty:netty-bom:pom:4.1.133.Final:import
但我需要它替换所有与 software.amazon.awssdk:netty-nio-client:jar:2.46.9:runtime 相应的子依赖,这现在还没有发生。
解决方案
将Netty依赖添加到
站内所有文章版权归属LeftHeroAI导航站,无授权禁止任何主体转载、抄袭、复制内容,亦不得私自架设镜像站点。一经侵权,本站将通过法律途径追责。