-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Make use of hashlib.md5() FIPS compliant #6982
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We're getting a bunch of:
def md5(string, charset="utf-8"):
> return hashlib.md5(string.encode(charset), usedforsecurity=False).hexdigest()
E TypeError: openssl_md5() takes no keyword arguments
It looks like that keyword parameter is only supported for Python 3.9 and later, so we'll have to check the python version when making those md5 calls. |
Since I'm not a big Python expert. Do you have a suggestion / pattern for such cases already that I can use? Like checking the Python version and then only supplying the parameter if we run on >3.9? |
I'm guessing something like this should do the trick? def md5(string, charset="utf-8"):
if sys.version_info >= (3, 9):
return hashlib.md5(string.encode(charset), usedforsecurity=False).hexdigest()
else:
return hashlib.md5(string.encode(charset)).hexdigest() |
Signed-off-by: Niels Pardon <[email protected]>
ecd47f9
to
e4c2e49
Compare
Yes, that's the right way to check python versions. |
I updated the PR. Since the I verified on a test system that tests are running fine with Python 3.8 when FIPS is deactivated with the if statement. |
Backporting for inclusion in next v1.4 patch (probably v1.4.3), per reasonable request: #6900 (comment) We shouldn't actually merge the backport PR until final release of v1.4.2 next week. |
Signed-off-by: Niels Pardon <[email protected]>
Signed-off-by: Niels Pardon <[email protected]>
Signed-off-by: Niels Pardon <[email protected]>
Signed-off-by: Niels Pardon <[email protected]>
Signed-off-by: Niels Pardon <[email protected]> Co-authored-by: Niels Pardon <[email protected]> Co-authored-by: leahwicz <[email protected]>
resolves #6900
Description
hashlib.md5()
with calls todbt.utils.md5()
usedforsecurity=False
when callinghashlib.md5()
Previously when running
make test
on a FIPS enabled system there were many test failures. With the changes of this PR bothmake test
andmake integration
run through without errors on a FIPS enabled system.Checklist
changie new
to create a changelog entry