【发布时间】:2022-04-23 00:27:01
【问题描述】:
在 Grails 2.4 项目中更新 log4j 时遇到一些问题(顺便说一句,我认为我还没有完成)
Update log4j in Grails 2.4 results in "Could not transfer artifact from/to grailsCentral"
现在我发现从依赖列表中删除旧 log4j 版本的问题。
有趣的是,Grails 2.4.2 文档解释了如何从全局集中精确排除 log4j:
https://grails.github.io/grails2-doc/2.4.2/guide/conf.html#logging
所以,这是我的依赖解析部分:
grails.project.dependency.resolution = {
inherits("global") {
excludes "grails-plugin-logging", "log4j"
}
log "verbose" // log level of Ivy resolver, either 'error', 'warn', 'info', 'debug' or 'verbose'
checksums true // Whether to verify checksums on resolve
legacyResolve false // whether to do a secondary resolve on plugin installation, not advised and here for backwards compatibility
repositories {
inherits true // Whether to inherit repository definitions from plugins
grailsPlugins()
grailsHome()
mavenLocal()
//grailsCentral()
//mavenCentral()
mavenRepo 'https://repo.grails.org/grails/plugins'
mavenRepo 'https://repo1.maven.org/maven2/'
mavenRepo 'https://repo.maven.apache.org/maven2/'
}
dependencies {
...
compile "org.apache.logging.log4j:log4j-core:2.17.1"
compile "org.apache.logging.log4j:log4j-api:2.17.1"
}
plugins {
// plugins for the build system only
....
}
}
但是,在清理并再次构建我的应用程序后,如果运行依赖项报告,log4j-1.2.17 仍会显示在那里。
更重要的是,正如我之前所说,有些事情表明我既没有使用新版本的 log4j。但我不知道如何测试它。
如果我把这个放在“排除”中:
inherits("global") {
excludes "grails-plugin-log4j", "grails-plugin-logging", "log4j"
}
然后构建失败,因为
[groovyc] groovy.lang.GroovyRuntimeException: Unable to load logging class
我猜这与无数具有这一行的默认 Grails 文件有关:
import groovy.util.logging.Log4j
我开始认为在 Grails 中更新 log4j 版本几乎是不可能的。在我看来,关于 log4j 的最后一个 CVE(即使这个版本没有受到影响),他们应该发布一些文档来解释如何更新到最后一个版本。
有人知道如何正确执行此操作吗?
【问题讨论】:
-
“在我看来,关于 log4j 的最后一个 CVE(即使这个版本没有受到影响),他们应该发布一些解释如何更新到最后一个版本的文档。” - 我们为受 CVE 影响的 Grails 版本做了。我不认为 Grails 2.4 是其中之一。更多信息请访问grails.org/blog/2021-12-14-log4j2-cve.html。
-
不,不是,但可以预料的是,安装了非常旧的 log4j 的管理人员或客户会感到紧张(并且 log4j 1.x 有其自身的漏洞),他们无论如何都想更新。因此,在 Grails 中更新 log4j 这样简单的事情似乎几乎是不可能的。如果你从一开始就告诉我,我会很感激的,至少,它会节省我的时间。
标签: grails dependencies log4j