Skip to content

Commit b5345b0

Browse files
committed
Fix forbidden apis on FIPS (#33202)
- third party audit detects jar hell with JDK so we disable it - jdk non portable in forbiddenapis detects classes being used from the JDK ( for fips ) that are not portable, this is intended so we don't scan for it on fips. - different exclusion rules for third party audit on fips Closes #33179
1 parent 3a50095 commit b5345b0

File tree

4 files changed

+32
-3
lines changed

4 files changed

+32
-3
lines changed

distribution/tools/plugin-cli/build.gradle

+6
Original file line numberDiff line numberDiff line change
@@ -39,3 +39,9 @@ test {
3939
// TODO: find a way to add permissions for the tests in this module
4040
systemProperty 'tests.security.manager', 'false'
4141
}
42+
43+
if (project.inFipsJvm) {
44+
// FIPS JVM includes manny classes from bouncycastle which count as jar hell for the third party audit,
45+
// rather than provide a long list of exclusions, disable the check on FIPS.
46+
thirdPartyAudit.enabled = false
47+
}

modules/transport-netty4/build.gradle

+8-1
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,6 @@ thirdPartyAudit.excludes = [
8383
'io.netty.internal.tcnative.SSLContext',
8484

8585
// from io.netty.handler.ssl.util.BouncyCastleSelfSignedCertGenerator (netty)
86-
'org.bouncycastle.asn1.x500.X500Name',
8786
'org.bouncycastle.cert.X509v3CertificateBuilder',
8887
'org.bouncycastle.cert.jcajce.JcaX509CertificateConverter',
8988
'org.bouncycastle.cert.jcajce.JcaX509v3CertificateBuilder',
@@ -164,3 +163,11 @@ thirdPartyAudit.excludes = [
164163
'org.conscrypt.Conscrypt$Engines',
165164
'org.conscrypt.HandshakeListener'
166165
]
166+
167+
if (project.inFipsJvm == false) {
168+
// BouncyCastleFIPS provides this class, so the exclusion is invalid when running CI in
169+
// a FIPS JVM with BouncyCastleFIPS Provider
170+
thirdPartyAudit.excludes += [
171+
'org.bouncycastle.asn1.x500.X500Name'
172+
]
173+
}

plugins/ingest-attachment/build.gradle

+6
Original file line numberDiff line numberDiff line change
@@ -2141,3 +2141,9 @@ if (project.runtimeJavaVersion > JavaVersion.VERSION_1_8) {
21412141
'javax.xml.bind.Unmarshaller'
21422142
]
21432143
}
2144+
2145+
if (project.inFipsJvm) {
2146+
// FIPS JVM includes manny classes from bouncycastle which count as jar hell for the third party audit,
2147+
// rather than provide a long list of exclusions, disable the check on FIPS.
2148+
thirdPartyAudit.enabled = false
2149+
}

x-pack/plugin/security/cli/build.gradle

+12-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import org.elasticsearch.gradle.precommit.ForbiddenApisCliTask
2+
13
apply plugin: 'elasticsearch.build'
24

35
archivesBaseName = 'elasticsearch-security-cli'
@@ -6,8 +8,8 @@ dependencies {
68
compileOnly "org.elasticsearch:elasticsearch:${version}"
79
// "org.elasticsearch.plugin:x-pack-core:${version}" doesn't work with idea because the testArtifacts are also here
810
compileOnly project(path: xpackModule('core'), configuration: 'default')
9-
compile 'org.bouncycastle:bcprov-jdk15on:1.59'
1011
compile 'org.bouncycastle:bcpkix-jdk15on:1.59'
12+
compile 'org.bouncycastle:bcprov-jdk15on:1.59'
1113
testImplementation 'com.google.jimfs:jimfs:1.1'
1214
testCompile "junit:junit:${versions.junit}"
1315
testCompile "org.hamcrest:hamcrest-all:${versions.hamcrest}"
@@ -20,6 +22,14 @@ dependencyLicenses {
2022
mapping from: /bc.*/, to: 'bouncycastle'
2123
}
2224

23-
if (inFipsJvm) {
25+
if (project.inFipsJvm) {
2426
test.enabled = false
27+
// Forbiden APIs non-portable checks fail because bouncy castle classes being used from the FIPS JDK since those are
28+
// not part of the Java specification - all of this is as designed, so we have to relax this check for FIPS.
29+
tasks.withType(ForbiddenApisCliTask) {
30+
bundledSignatures -= "jdk-non-portable"
31+
}
32+
// FIPS JVM includes manny classes from bouncycastle which count as jar hell for the third party audit,
33+
// rather than provide a long list of exclusions, disable the check on FIPS.
34+
thirdPartyAudit.enabled = false
2535
}

0 commit comments

Comments
 (0)