我的项目依赖于几个依赖项,这些依赖项间接依赖于 Apache Commons Collections 3.2.2。 IntelliJ 警告我有关此库中的a CVE,奇怪的是,它在 maven 存储库 上不可见。例如 Apache Commons BeanUtils 1.9.4,尽管是最后一个可用版本,仍然使用旧版本的 commons-collections,这显然有这个令人讨厌的 CVE。很多库都使用 beanutils
现在,如果我想摆脱这个 CVE,该怎么办?我已经将所有可能的依赖项推送到最后一个可用的依赖项,甚至使用 DependencyManagement 来处理传递依赖项的版本。但是对于commons-collections,他们从4.0版本开始将其pakcages更改为commons-collections4,因此在这种情况下排除/更新依赖项是相当麻烦的。
也许从 commons-collections 到 commons-collections4 的桥接代理可以解决问题。我想不出其他的了,你觉得呢?
首先,包括直接依赖。
<project>
...
<dependencies>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-collections4</artifactId>
<version>4.4</version>
</dependency>
</dependencies>
</project>
现在您需要从依赖于 commons-collections 的所有直接依赖项中排除传递依赖项。
<project>
...
<dependencies>
<dependency>
<groupId>{dependency-group}</groupId>
<artifactId>{dependency-artifact}</artifactId>
<version>{dependency-version}</version>
<scope>compile</scope>
<exclusions>
<exclusion> <!-- declare the exclusion here -->
<groupId>commons-collections</groupId>
<artifactId>commons-collections</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
</project>