是否可以在Gradle中强制使用子依赖项的版本?
场景: 我们正在使用Dozer,它的最大版本是5.5.1,它具有commons-beanutils 1.9.1的依赖关系,不幸的是,我们的Sonatype CLM / IQ服务器检测到它的安全问题编号为CVE-2014-0114 >
描述:(Apache Commons BeanUtils,分布在Apache Struts 1.x至1.3.10的lib / commons-beanutils-1.8.0.jar和其他需要commons-beanutils的产品中1.9.2不会抑制class属性,该属性允许远程攻击者“操纵” ClassLoader并通过class参数执行任意代码,如将此参数传递给Struts 1中的ActionForm对象的getClass方法所证明的。 )
是否可以将其依赖项版本更新为1.9.3,以避免出现此安全漏洞?
代码:
dependencies {
providedCompile(
<other stuff>
[group: 'net.sf.dozer', name: 'dozer', version: '5.5.1']
<other stuff>
)
}
答案 0 :(得分:0)
在您的build.gradle中:
configurations.all {
resolutionStrategy.eachDependency { DependencyResolveDetails details ->
if (details.requested.name == 'commons-beanutils') {
details.useTarget "commons-beanutils:commons-beanutils:1.9.3"
}
}
}
传递依赖项版本控制解决方案有效,仅需要重建和刷新项目以使Sonatype CLM能够检测到更改。