Skip to content

Commit 44a5aaa

Browse files
committed
Conditionally install bcfips jars when building for observabilitySRE
This commit implements a pattern for performing specific gradle tasks based on a newly named "fedrampHighMode" option. This option is used to configure tests to run with additional configuration specific to the observabilitySRE use case. Similarly the additional jar dependencies for bouncycastle fips providers are conditionally installed gated on the "fedrampHighMode" option.
1 parent c8992ce commit 44a5aaa

File tree

7 files changed

+25
-16
lines changed

7 files changed

+25
-16
lines changed

.buildkite/pull_request_pipeline.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ steps:
5454
set -euo pipefail
5555
5656
docker build -t test-runner-image -f x-pack/distributions/internal/observabilitySRE/docker/Dockerfile .
57-
docker run test-runner-image ./gradlew --info --stacktrace -PrunTestsInFIPSMode=true rubyTests
57+
docker run test-runner-image ./gradlew --info --stacktrace -PfedrampHighMode=true rubyTests
5858
artifact_paths:
5959
- "coverage/coverage.json"
6060

@@ -96,7 +96,7 @@ steps:
9696
set -euo pipefail
9797
9898
docker build -t test-runner-image -f x-pack/distributions/internal/observabilitySRE/docker/Dockerfile .
99-
docker run test-runner-image ./gradlew --info --stacktrace -PrunTestsInFIPSMode=true javaTests
99+
docker run test-runner-image ./gradlew --info --stacktrace -PfedrampHighMode=true javaTests
100100
artifact_paths:
101101
- "**/build/test-results/javaTests/TEST-*.xml"
102102
- "**/jacocoTestReport.xml"

ci/run-fips-integration-tests.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@
66
half_number=$1
77
source ci/get-test-half.sh
88
specs=$(get_test_half "$half_number")
9-
./gradlew --info --stacktrace -PrunTestsInFIPSMode=true runIntegrationTests -PrubyIntegrationSpecs="$specs"
9+
./gradlew --info --stacktrace -PfedrampHighMode=true runIntegrationTests -PrubyIntegrationSpecs="$specs"

logstash-core/build.gradle

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -235,11 +235,6 @@ dependencies {
235235
runtimeOnly 'commons-logging:commons-logging:1.3.1'
236236
// also handle libraries relying on log4j 1.x to redirect their logs
237237
runtimeOnly "org.apache.logging.log4j:log4j-1.2-api:${log4jVersion}"
238-
// FIPS deps. TODO: figure out how to actually manage these
239-
runtimeOnly("org.bouncycastle:bc-fips:2.0.0")
240-
runtimeOnly("org.bouncycastle:bcpkix-fips:2.0.7")
241-
runtimeOnly("org.bouncycastle:bctls-fips:2.0.19")
242-
runtimeOnly("org.bouncycastle:bcutil-fips:2.0.3")
243238
implementation('org.reflections:reflections:0.10.2') {
244239
exclude group: 'com.google.guava', module: 'guava'
245240
}

x-pack/ci/integration_tests.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ if [ -n "$BUILD_JAVA_HOME" ]; then
1818
fi
1919

2020
if [ -n "$FIPS_MODE" ]; then
21-
./gradlew runXPackIntegrationTests -PrunTestsInFIPSMode=true
21+
./gradlew runXPackIntegrationTests -PfedrampHighMode=true
2222
else
2323
./gradlew runXPackIntegrationTests
2424
fi

x-pack/ci/unit_tests.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ if [ -n "$BUILD_JAVA_HOME" ]; then
1717
fi
1818

1919
if [ -n "$FIPS_MODE" ]; then
20-
./gradlew runXPackUnitTests -PrunTestsInFIPSMode=true
20+
./gradlew runXPackUnitTests -PfedrampHighMode=true
2121
else
2222
./gradlew runXPackUnitTests
2323
fi

x-pack/distributions/internal/observabilitySRE/build-ext.gradle

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
ext {
2-
runTestsInFIPSMode = project.hasProperty('runTestsInFIPSMode') ? project.property('runTestsInFIPSMode').toBoolean() : false
2+
fedrampHighMode = project.hasProperty('fedrampHighMode') ? project.property('fedrampHighMode').toBoolean() : false
33
}
44

55
subprojects {
66
ext {
7-
runTestsInFIPSMode = rootProject.runTestsInFIPSMode
7+
fedrampHighMode = rootProject.fedrampHighMode
88
}
99
}
1010

1111
allprojects {
1212
afterEvaluate {
1313
tasks.withType(Test) {
14-
if (runTestsInFIPSMode) {
14+
if (rootProject.fedrampHighMode) {
1515
logger.debug("configuring ${it} to run in FIPSMode ")
1616
systemProperty "java.security.properties", System.getenv("JAVA_SECURITY_PROPERTIES")
1717
systemProperty "javax.net.ssl.keyStore", "/etc/java/security/keystore.bcfks"
@@ -28,4 +28,18 @@ allprojects {
2828
}
2929
}
3030
}
31-
}
31+
}
32+
33+
project(':logstash-core') {
34+
afterEvaluate {
35+
if (rootProject.fedrampHighMode) {
36+
logger.lifecycle("Adding BouncyCastle FIPS dependencies to logstash-core")
37+
dependencies {
38+
implementation "org.bouncycastle:bc-fips:2.0.0"
39+
implementation "org.bouncycastle:bcpkix-fips:2.0.7"
40+
implementation "org.bouncycastle:bctls-fips:2.0.19"
41+
implementation "org.bouncycastle:bcutil-fips:2.0.3"
42+
}
43+
}
44+
}
45+
}

x-pack/distributions/internal/observabilitySRE/docker/Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ ENV JAVA_HOME=/usr/lib/jvm/java-21-openjdk
4343
ENV PATH="${JAVA_HOME}/bin:${PATH}"
4444

4545
# Initial build using JKS truststore
46-
RUN ./gradlew clean bootstrap assemble installDefaultGems
46+
RUN ./gradlew clean bootstrap assemble installDefaultGems -PfedrampHighMode=true
4747

4848
# Convert JKS to BCFKS for truststore and keystore
4949
RUN keytool -importkeystore \
@@ -87,4 +87,4 @@ ENV LS_JAVA_OPTS="\
8787
-Dorg.bouncycastle.fips.approved_only=true"
8888

8989
# Example test run, most use cases will override this
90-
CMD ["./gradlew", "--info", "--stacktrace", "-PrunTestsInFIPSMode=true", "runIntegrationTests"]
90+
CMD ["./gradlew", "--info", "--stacktrace", "-PfedrampHighMode=true", "runIntegrationTests"]

0 commit comments

Comments
 (0)