Conversation
PR Code Analyzer ❗AI-powered 'Code-Diff-Analyzer' found issues on commit d5a4ab4. ⛔ Hard block: Issues at High severity or above will block this PR from merging.
The table above displays the top 10 most important findings. Pull Requests Author(s): Please update your Pull Request according to the report above. Repository Maintainer(s): You can Thanks. |
0251173 to
a95d231
Compare
Introduces gradle/fips.gradle as the single place where FIPS mode is decided and applied to the build's test surface: which test classes exist in each mode and the JVM arguments test workers need to actually be in FIPS mode. Mode is driven by the OPENSEARCH_FIPS_MODE environment variable, surfaced to production code through the new FipsMode enum. BC FIPS artifacts move to compileOnly in both modes (they are provided by OpenSearch core), bctls-fips is added, and the securityadmin standalone bundles now ship the BC FIPS jars in deps/. Because java_test.security registers BouncyCastleFipsProvider in every test JVM -- including non-FIPS runs -- any suite that touches JCA now leaves a "BC FIPS Entropy Daemon" thread behind, which RandomizedRunner reports as a leak. BCFipsEntropyDaemonFilter covers it; the framework's BouncyCastleThreadFilter does not. It is applied to the suites that trip over it here, and reused by later FIPS work. No FIPS variant test classes exist yet, so this otherwise lands inert: the default build is unchanged and fips.gradle currently selects nothing. Signed-off-by: Iwan Igonin <iigonin@sternad.de> Co-authored-by: Benny Goerzig <benny.goerzig@sap.com> Co-authored-by: Karsten Schnitter <k.schnitter@sap.com> Co-authored-by: Kai Sternad <k.sternad@sternad.de>
a95d231 to
d5a4ab4
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #6394 +/- ##
==========================================
+ Coverage 75.90% 75.97% +0.07%
==========================================
Files 461 462 +1
Lines 30942 30970 +28
Branches 4668 4674 +6
==========================================
+ Hits 23485 23530 +45
+ Misses 5295 5270 -25
- Partials 2162 2170 +8
🚀 New features to boost your workflow:
|
PR Reviewer Guide 🔍(Review updated until commit ba9578b)Here are some key observations to aid the review process:
|
PR Code Suggestions ✨Explore these optional code suggestions:
|
cwperks
left a comment
There was a problem hiding this comment.
ty for splitting these up @beanuwave ! This looks like a good place to begin with this series of PRs. Will any of these create any new CI checks to run existing tests in FIPS approved mode as a PR check?
| } | ||
|
|
||
| private FipsMode() { | ||
| throw new UnsupportedOperationException(); |
There was a problem hiding this comment.
Wondering why do we need that? The private constructor prohibits class instantiation (https://docs.oracle.com/javase/specs/jls/se7/html/jls-6.html#d5e8146)
| throw new UnsupportedOperationException(); |
There was a problem hiding this comment.
You are right, it's unnesseccary since java provides Unsafe.allocateInstance and ReflectionFactory.newConstructorForSerialization and the supplier is the actual attack surface.
| @Test | ||
| public void constructor_isNotInstantiable() throws Exception { | ||
| Constructor<FipsMode> constructor = FipsMode.class.getDeclaredConstructor(); | ||
| constructor.setAccessible(true); |
There was a problem hiding this comment.
The code outside the security module should not be able to widen accessibility rules (unless opened explicitly), I think we should be fine without reflection based tests ....
| * FIPS mode is driven by the OPENSEARCH_FIPS_MODE environment variable. | ||
| */ | ||
|
|
||
| ext.fipsTestsEnabled = 'true'.equalsIgnoreCase(System.getenv('OPENSEARCH_FIPS_MODE')) |
There was a problem hiding this comment.
Could we reuse FipsBuildParams from OpenSearch build please:
| ext.fipsTestsEnabled = 'true'.equalsIgnoreCase(System.getenv('OPENSEARCH_FIPS_MODE')) | |
| import org.opensearch.gradle.info.FipsBuildParams | |
| ext.fipsTestsEnabled = FipsBuildParams.isInFipsMode() |
|
Thanks @beanuwave , a few minor comments, looks otherwise, same question as #6394 (review) : do we need update test matrix on CI to run fips / non-fips tests? |
Signed-off-by: Iwan Igonin <iigonin@sternad.de> Co-authored-by: Benny Goerzig <benny.goerzig@sap.com> Co-authored-by: Karsten Schnitter <k.schnitter@sap.com> Co-authored-by: Kai Sternad <k.sternad@sternad.de>
|
Persistent review updated to latest commit ba9578b |
|
@reta @cwperks Thanks for the review! GitHub Actions are not part of this series. Looks like it will be a combined effort of extending The |
| */ | ||
|
|
||
| ext.fipsTestsEnabled = 'true'.equalsIgnoreCase(System.getenv('OPENSEARCH_FIPS_MODE')) | ||
| def fipsBuildParams = rootProject.buildscript.classLoader.loadClass('org.opensearch.gradle.info.FipsBuildParams') |
There was a problem hiding this comment.
Wow, this is unexpected, the security plugin applies OpenSearch build tooling plugins, why we need that?
Description
Category: Enhancement
Establishes how FIPS mode is decided and applied, with no behaviour change to the default build. Nothing in this PR turns FIPS on for users; it makes FIPS a build and test mode the rest of the stack can rely on.
Key changes
FipsMode.isEnabled()(envOPENSEARCH_FIPS_MODE=true) replacesCryptoServicesRegistrar.isInApprovedOnlyMode()as the way the plugin asks "are we in FIPS mode". Intent is decoupled from provider state; later PRs cross-check the two at startup.compileOnlyin both modes (the jars are shipped by core); the compile-timeFipsBuildParamsfork is gone.bctls-fipsis added, and thesecurityadminstandalone bundles ship the BC FIPS jars underdeps/, so that bundle's classpath stays FIPS-capable for a manualjava -cp 'deps/*'launch (its own launcher has not been self-contained since upstream Copy scripts from tools to bin/ directory in assembly and make scripts agnostic to directory #6023).java.security, not code. No provider is registered programmatically. The runtime launcher merges infips_java.securitywhenOPENSEARCH_FIPS_MODE=true; tests swap the file wholesale via-Djava.security.properties==<file>.gradle/fips.gradleis the single place where the mode is decided and applied to the test surface: which classes exist in each mode, and the JVM args the workers need. Keeping both together matters — selecting the FIPS classes without the matching JVM args produces a suite that looks FIPS-shaped but runs on ordinary providers.<Base>FipsTests(unit) or<Base>FipsIT(integration): it extends its baseline, overrides what the FIPS providers change, and adds FIPS-only assertions. The two modes select disjoint sets — outside FIPS the variants are excluded from compilation and from everyTesttask; inside FIPS each baseline that has a variant is excluded so the variant replaces it. Baselines therefore stay free ofFipsMode.isEnabled()branches. This follows core's convention (gradle/fips.gradlethere).BCFipsEntropyDaemonFilter. Becausejava_test.securityregisters BouncyCastleFipsProvider in every test JVM including non-FIPS runs, any suite touching JCA leaves a "BC FIPS Entropy Daemon" thread behind, which RandomizedRunner reports as a leak. The framework'sBouncyCastleThreadFilterdoes not cover it. Applied to the suites that trip over it here and reused by later PRs.Reviewer notes
fips.gradleselects nothing and the default build is unchanged. The machinery is exercised from PR 5 onward.BCFipsEntropyDaemonFilterarguably belongs in core's test framework rather than this plugin — see Core / distribution follow-ups at the end of this document.Testing
Check List
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.