Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
92aa408
Draft to allow run in FIPS compliace mode
iigonin Mar 4, 2024
abdfe72
make tests run without BC (not BCFIPS) libraries.
iigonin Aug 7, 2024
dcffe2b
disable approved-only mode for launch configuration of testcluster
iigonin Aug 8, 2024
cffb257
update all BC libraries to support JAVA 21
iigonin Aug 8, 2024
142068a
try to pass bwc staged build by adding expected version
iigonin Aug 8, 2024
3eccd6e
ensure FIPS-mode can be enabled by fixing existent and creating addit…
iigonin Aug 30, 2024
a4e0e74
fixing additional tests.
iigonin Sep 23, 2024
851f8b4
Configure FIPS mode through global ENV VAR instead of thread-based.
iigonin Oct 18, 2024
e2276e9
write some additional unit tests.
iigonin Oct 24, 2024
25213cb
test SystemJvmOptions.java & replace FIPS-140-2 by FIPS-140-3
iigonin Oct 28, 2024
9b7ea4f
categorize JKS keystore as untrusted
iigonin Nov 8, 2024
2e95da5
general exclusion of keystore binaries and certificates from fobidden…
iigonin Nov 14, 2024
e3a830c
Kerberos, forbiddenApis, SecureRandom, SunJCE, AzureTests
iigonin Nov 19, 2024
bf49295
remove BC libs from 'libs:common'; revert SecureRandomHolder
iigonin Jan 9, 2025
3dd921e
loosen some direct BC dependencies
iigonin Jan 16, 2025
09a7fc1
set default testcluster password for all project modules
iigonin Jan 27, 2025
55d6f6b
build with 'crypto.standard' gradle build parameter
iigonin Jan 31, 2025
96524cf
run REST-tests with JKS & BCFKS keystores
iigonin Feb 4, 2025
0a4a81a
merge with main
Feb 28, 2025
1da3c64
Merge branch 'main' into fips_compliance2
Mar 13, 2025
b79f303
Migrate from BC to BCFIPS libraries
Mar 4, 2025
aa11b27
reduce footprint of BC libraries
iigonin Mar 19, 2025
cad0454
Merge branch 'bc_to_bcfips_migration' into fips_compliance2
iigonin Mar 20, 2025
8edda48
reduce footprint of BC libs
iigonin Mar 19, 2025
458f2c0
Merge branch 'bc_to_bcfips_migration' into fips_compliance2
iigonin Mar 20, 2025
9a88327
Merge branch 'main' into fips_compliance2
iigonin Mar 24, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
### Changed
- Migrate BC libs to their FIPS counterparts ([#14912](https://github.com/opensearch-project/OpenSearch/pull/14912))

### Changed
- Migrate BC libs to their FIPS counterparts ([#3420](https://github.com/opensearch-project/OpenSearch/pull/14912))

### Dependencies
- Bump `com.nimbusds:nimbus-jose-jwt` from 9.41.1 to 10.0.2 ([#17607](https://github.com/opensearch-project/OpenSearch/pull/17607))
- Bump `com.google.api:api-common` from 1.8.1 to 2.46.1 ([#17604](https://github.com/opensearch-project/OpenSearch/pull/17604))
Expand Down
19 changes: 17 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ apply from: 'gradle/ide.gradle'
apply from: 'gradle/forbidden-dependencies.gradle'
apply from: 'gradle/formatting.gradle'
apply from: 'gradle/local-distribution.gradle'
apply from: 'gradle/fips.gradle'
apply from: 'gradle/run.gradle'
apply from: 'gradle/missing-javadoc.gradle'
apply from: 'gradle/code-coverage.gradle'
Expand Down Expand Up @@ -472,8 +471,8 @@ gradle.projectsEvaluated {
}
}

// test retry configuration
subprojects {
// test retry configuration
tasks.withType(Test).configureEach {
develocity.testRetry {
if (BuildParams.isCi()) {
Expand Down Expand Up @@ -559,6 +558,22 @@ subprojects {
}
}
}

// test with FIPS-140-3 enabled
plugins.withType(JavaPlugin).configureEach {
tasks.withType(Test).configureEach { testTask ->
if (BuildParams.inFipsJvm) {
testTask.jvmArgs += "-Dorg.bouncycastle.fips.approved_only=true"
}
}
}
plugins.withId('opensearch.testclusters') {
testClusters.configureEach {
if (BuildParams.inFipsJvm) {
keystorePassword 'notarealpasswordphrase'
}
}
}
}

// eclipse configuration
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ public void execute(Task t) {
test.systemProperty("tests.seed", BuildParams.getTestSeed());
}

var securityFile = "java.security";
var securityFile = BuildParams.isInFipsJvm() ? "fips_java.security" : "java.security";
test.systemProperty(
"java.security.properties",
project.getRootProject().getLayout().getProjectDirectory() + "/distribution/src/config/" + securityFile
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@

package org.opensearch.gradle.http;

import de.thetaphi.forbiddenapis.SuppressForbidden;

import org.gradle.api.logging.Logger;
import org.gradle.api.logging.Logging;

Expand Down Expand Up @@ -216,15 +218,15 @@ KeyStore buildTrustStore() throws GeneralSecurityException, IOException {
}

private KeyStore buildTrustStoreFromFile() throws GeneralSecurityException, IOException {
KeyStore keyStore = KeyStore.getInstance(trustStoreFile.getName().endsWith(".jks") ? "JKS" : "PKCS12");
var keyStore = getKeyStoreInstance(trustStoreFile.getName().endsWith(".jks") ? "JKS" : "PKCS12");
try (InputStream input = new FileInputStream(trustStoreFile)) {
keyStore.load(input, trustStorePassword == null ? null : trustStorePassword.toCharArray());
}
return keyStore;
}

private KeyStore buildTrustStoreFromCA() throws GeneralSecurityException, IOException {
final KeyStore store = KeyStore.getInstance(KeyStore.getDefaultType());
var store = getKeyStoreInstance(KeyStore.getDefaultType());
store.load(null, null);
final CertificateFactory certFactory = CertificateFactory.getInstance("X.509");
int counter = 0;
Expand All @@ -239,6 +241,11 @@ private KeyStore buildTrustStoreFromCA() throws GeneralSecurityException, IOExce
return store;
}

@SuppressForbidden
private KeyStore getKeyStoreInstance(String type) throws KeyStoreException {
return KeyStore.getInstance(type);
}

private SSLContext createSslContext(KeyStore trustStore) throws GeneralSecurityException {
checkForTrustEntry(trustStore);
TrustManagerFactory tmf = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm());
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/*
* SPDX-License-Identifier: Apache-2.0
*
* The OpenSearch Contributors require contributions made to
* this file be licensed under the Apache-2.0 license or a
* compatible open source license.
*/

package org.opensearch.gradle.info;

import java.util.function.Function;

public class FipsBuildParams {

public static final String FIPS_BUILD_PARAM = "crypto.standard";

public static final String FIPS_ENV_VAR = "OPENSEARCH_CRYPTO_STANDARD";

private static String fipsMode;

public static void init(Function<String, Object> fipsValue) {
fipsMode = (String) fipsValue.apply(FIPS_BUILD_PARAM);
}

private FipsBuildParams() {}

public static boolean isInFipsMode() {
return "FIPS-140-3".equals(fipsMode);
}

public static String getFipsMode() {
return fipsMode;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,8 @@ public void apply(Project project) {
File rootDir = project.getRootDir();
GitInfo gitInfo = gitInfo(rootDir);

FipsBuildParams.init(project::findProperty);

BuildParams.init(params -> {
// Initialize global build parameters
boolean isInternal = GlobalBuildInfoPlugin.class.getResource("/buildSrc.marker") != null;
Expand All @@ -129,7 +131,7 @@ public void apply(Project project) {
params.setIsCi(System.getenv("JENKINS_URL") != null);
params.setIsInternal(isInternal);
params.setDefaultParallel(findDefaultParallel(project));
params.setInFipsJvm(Util.getBooleanProperty("tests.fips.enabled", false));
params.setInFipsJvm(FipsBuildParams.isInFipsMode());
params.setIsSnapshotBuild(Util.getBooleanProperty("build.snapshot", true));
if (isInternal) {
params.setBwcVersions(resolveBwcVersions(rootDir));
Expand Down Expand Up @@ -179,7 +181,11 @@ private void logGlobalBuildInfo() {
LOGGER.quiet(" JAVA_HOME : " + gradleJvm.getJavaHome());
}
LOGGER.quiet(" Random Testing Seed : " + BuildParams.getTestSeed());
LOGGER.quiet(" In FIPS 140 mode : " + BuildParams.isInFipsJvm());
if (FipsBuildParams.isInFipsMode()) {
LOGGER.quiet(" Crypto Standard : " + FipsBuildParams.getFipsMode());
} else {
LOGGER.quiet(" Crypto Standard : any-supported");
}
LOGGER.quiet("=======================================");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
import org.gradle.api.NamedDomainObjectContainer;
import org.gradle.api.Project;
import org.gradle.api.Task;
import org.gradle.api.file.ConfigurableFileCollection;
import org.gradle.api.file.FileCollection;
import org.gradle.api.file.FileTree;
import org.gradle.api.plugins.jvm.JvmTestSuite;
Expand Down Expand Up @@ -87,6 +88,7 @@ public class TestingConventionsTasks extends DefaultTask {

private final NamedDomainObjectContainer<TestingConventionRule> naming;
private final Project project;
private final ConfigurableFileCollection extraClassPath = getProject().files();

@Inject
public TestingConventionsTasks(Project project) {
Expand Down Expand Up @@ -398,7 +400,16 @@ private boolean isAnnotated(Method method, Class<?> annotation) {

@Classpath
public FileCollection getTestsClassPath() {
return Util.getJavaTestSourceSet(project).get().getRuntimeClasspath();
return Util.getJavaTestSourceSet(project).get().getRuntimeClasspath().plus(extraClassPath);
}

@Classpath
public ConfigurableFileCollection getExtraClassPath() {
return extraClassPath;
}

public void addExtraClassPath(Object... paths) {
extraClassPath.from(paths);
}

private Map<String, File> walkPathAndLoadClasses(File testRoot) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
import org.opensearch.gradle.Version;
import org.opensearch.gradle.VersionProperties;
import org.opensearch.gradle.info.BuildParams;
import org.opensearch.gradle.info.FipsBuildParams;
import org.gradle.api.Action;
import org.gradle.api.Named;
import org.gradle.api.NamedDomainObjectContainer;
Expand Down Expand Up @@ -546,6 +547,10 @@ public synchronized void start() {
logToProcessStdout("installed plugins");
}

if (FipsBuildParams.isInFipsMode() && keystorePassword.isEmpty()) {
throw new TestClustersException("Can not start " + this + " in FIPS JVM, missing keystore password");
}

logToProcessStdout("Creating opensearch keystore with password set to [" + keystorePassword + "]");
if (keystorePassword.length() > 0) {
runOpenSearchBinScriptWithInput(keystorePassword + "\n" + keystorePassword + "\n", "opensearch-keystore", "create", "-p");
Expand Down Expand Up @@ -791,6 +796,9 @@ private Map<String, String> getOpenSearchEnvironment() {
// Override the system hostname variables for testing
defaultEnv.put("HOSTNAME", HOSTNAME_OVERRIDE);
defaultEnv.put("COMPUTERNAME", COMPUTERNAME_OVERRIDE);
if (FipsBuildParams.isInFipsMode()) {
defaultEnv.put(FipsBuildParams.FIPS_ENV_VAR, FipsBuildParams.getFipsMode());
}

Set<String> commonKeys = new HashSet<>(environment.keySet());
commonKeys.retainAll(defaultEnv.keySet());
Expand Down
Binary file removed buildSrc/src/main/resources/cacerts.bcfks
Binary file not shown.
29 changes: 0 additions & 29 deletions buildSrc/src/main/resources/fips_java_bcjsse_11.policy

This file was deleted.

34 changes: 0 additions & 34 deletions buildSrc/src/main/resources/fips_java_bcjsse_8.policy

This file was deleted.

Loading
Loading