【问题标题】:Can i make a Gradle dependencies' dependency to force a version?我可以制作 Gradle 依赖项的依赖项来强制一个版本吗?
【发布时间】:2018-10-31 23:22:33
【问题描述】:

是否可以在 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,不抑制类属性,允许远程攻击者通过类参数“操纵”ClassLoader并执行任意代码,如在Struts 1中将此参数传递给ActionForm对象的getClass方法所示。 )

是否可以将其依赖版本更新为 1.9.3 以避免出现此安全漏洞?

代码:

dependencies {
  providedCompile(
     <other stuff>
     [group: 'net.sf.dozer', name: 'dozer', version: '5.5.1']
     <other stuff>
  )
}

【问题讨论】:

    标签: gradle dozer sonatype


    【解决方案1】:

    在你的 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 重建和刷新项目以检测更改。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-04-18
      • 2019-12-29
      • 1970-01-01
      • 2011-11-18
      • 2014-10-13
      • 2014-08-03
      • 1970-01-01
      • 2016-07-29
      相关资源
      最近更新 更多