fix: support running in FIPS-enabled environments #3571
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
📝 Summary
Problem
Currently, marimo will fail on FIPS-enabled environments where
md5
hashing is disabled for security purposes. This means thatjs_hash
cannot be calculated inmarimo/_plugins/ui/_impl/from_anywidget.py
.Solution
Since md5 is being used for file integrity checks, this particular use of md5 can be considered FIPS compliant. Since python 3.9, the usedforsecurity flag has been introduced in hashlib functions, which allows for bypassing the FIPS enforcement check. As such, using
usedforsecurity=False
when invokinghashlib.md5
solves the issue.🔍 Description of Changes
Use
usedforsecurity=False
when invokinghashlib.md5
inmarimo._plugins.ui._impl.from_anywidget.anywidget.__init__
.📋 Checklist
I did not add tests because I'm not sure how to go about mocking a FIPS enabled environment, and the change is a noop for non-FIPS environments.
Working to setup an EC2 instance with FIPS enabled to verify the changes work off of my fork, but have not done so yet.
📜 Reviewers
@mscolnick (guessing you as the reviewer, as you've been engaging w previous python questions I've had)