Patch log4j JAR to remove JndiLookup class (#81629)

This commit is contained in:
Mark Vieira 2021-12-10 15:51:38 -08:00 committed by GitHub
parent ef64808caf
commit 9a3422e1a6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 33 additions and 1 deletions

View file

@ -275,6 +275,10 @@ configure(subprojects.findAll { ['archives', 'packages'].contains(it.name) }) {
}
}
}
all {
resolutionStrategy.dependencySubstitution {
substitute module("org.apache.logging.log4j:log4j-core") using project(":libs:elasticsearch-log4j") because "patched to remove JndiLookup clas"}
}
}
dependencies {

View file

@ -6,7 +6,7 @@
* Side Public License, v 1.
*/
subprojects {
configure(subprojects - project('elasticsearch-log4j')) {
/*
* All subprojects are java projects using Elasticsearch's standard build
* tools.

28
libs/log4j/build.gradle Normal file
View file

@ -0,0 +1,28 @@
plugins {
id 'base'
id 'elasticsearch.repositories'
}
configurations {
log4j {
transitive = false
}
}
dependencies {
log4j "org.apache.logging.log4j:log4j-core:${versions.log4j}"
}
// Strip out JndiLookup class to avoid any possibility of exploitation of CVE-2021-44228
// See: https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2021-44228
// See: https://issues.apache.org/jira/browse/LOG4J2-3201
def patchLog4j = tasks.register('patchLog4j', Zip) {
archiveExtension = 'jar'
from({ zipTree(configurations.log4j.singleFile) }) {
exclude '**/JndiLookup.class'
}
}
artifacts {
'default'(patchLog4j)
}