Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: First pass at a reprodicible env for running under FIPS mode #16939

Draft
wants to merge 3 commits into
base: feature/fedramp-high-8.x
Choose a base branch
from

Conversation

donoghuc
Copy link
Member

This commit adds a dockerfile intended to serve as a portable environment for exploring running logstash in a FIPS compliant manner. The iteration at this commit focuses on running only the tests with the BC provider and trust stores. The same dockerfile has some commented out and unused config for doing manual exploration with LS. Eventually this will be split out into separate concerns.

WIP: DO NOT MERGE

This commit adds a dockerfile intended to serve as a portable environment for
exploring running logstash in a FIPS compliant manner. The iteration at this
commit focuses on running *only* the tests with the BC provider and trust
stores. The same dockerfile has some commented out and unused config for doing
manual exploration with LS. Eventually this will be split out into separate
concerns.
Copy link

Quality Gate passed Quality Gate passed

Issues
0 New issues
0 Accepted issues

Measures
0 Security Hotspots
No data about Coverage
No data about Duplication

See analysis details on SonarQube

Dockerfile Outdated
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤔 is there a place other than the project root for this? Maybe qa/fips/Dockerfile?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, yeah i'll look at moving this away from root.

test-init.gradle Outdated
}
}

gradle.taskGraph.whenReady { graph ->
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we wrap these tasks instead of changing them, or only execute this bit when an environment variable is set (and set that var in our Dockerfile)?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think so. I put up an attempt to do that but its not quite there yet. I do think your suggestion will be the way to go though in the end.

test-init.gradle Outdated
}
dependencies {
classpath files(
'/root/.gradle/caches/modules-2/files-2.1/org.bouncycastle/bc-fips/2.0.0/ee9ac432cf08f9a9ebee35d7cf8a45f94959a7ab/bc-fips-2.0.0.jar',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤔 what happens if we don't have them in the cache?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point. this was a hack I added early on. I was hoping to avoid it or make it more dynamic. I'll continue to work at this, what is in this iteration here is unacceptable.

The major issue i'm running in to now is where exactly to make the tests use the
BC providers. Too early, and I run in to issues not being able to download
dependencies but too late and the tests will fail due to not being able to load.
This iteration looks at moving away from a script wrapping tasks  and instead moving it to the
build.gradle in the tasks directly. At this point its actually regressed in the
java tests. My current thinking is that by not explicitly adding the cached
locations to the classpath i've broken something.

apply plugin: 'jacoco'
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I couldnt figure out a way to avoid downloading these deps at test time. I'll have to circle back to this.

In a previous iteration jvm options were attempted to be configured at the
gradle level. This presented a challeng in rspec loading because webmock was not
being loaded correctly with the fips providers. That initial approach was also
problematic because it introduced a fork in configuration changes between
configuring the JVM via the enviornment variables and files for running logstash
in the container vs in the tests.

This new apprach attempts to separate aout all of the test setup and building in
gradle from a pure "just run the tests" task. The fundamental idea is that we
dont want to use FIPS mode for downloading dependencies and building/preparing
an environment we only want that configured at the very end. This apprach
accomplishes that by teasing out the dependencies that trigger downloads etc in
gradel from tasks that will only run the tests. The dockerfile order will call
all the gradle tasks for setup, then configure FIPS mode and call the tests that
should be run under fips mode.
@donoghuc donoghuc force-pushed the fips-container-exploration branch from 37ac6eb to a7224b0 Compare January 24, 2025 22:38
@elasticmachine
Copy link
Collaborator

elasticmachine commented Jan 24, 2025

@donoghuc
Copy link
Member Author

donoghuc commented Jan 24, 2025

Repro steps as outlined in the doc executed from the container env https://docs.google.com/document/d/1Rmw6rxQ_5KkjBZQLu0e3aVJJrHXZaXf1dZpQi7kmkQI/edit?usp=sharing

[1] pry(#<LogStash::Runner>)> Java::java.security.Security.getProviders.map {|prov| prov.name }
=> 
["BCFIPS", "BCJSSE", "SUN", "SunJSSE", "SunJCE", "SunJGSS", 
"SunSASL", "XMLDSig", "SunPCSC", "JdkLDAP", "JdkSASL", "SunPKCS11"
]

[2] pry(#<LogStash::Runner>)> Java::org.bouncycastle.crypto.CryptoServicesRegistrar.isInApprovedOnlyMode
=> 
true

[3] pry(#<LogStash::Runner>)> Java::java.security.SecureRandom.new.getProvider.getName
=> "BCFIPS"

[4] pry(#<LogStash::Runner>)> Java::org.bouncycastle.crypto.fips.FipsStatus.isReady
=> 
true
[5] pry(#<LogStash::Runner>)> org.jruby.ext.openssl.SecurityHelper.isProviderRegistered
=> 
false

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants