Skip to content

Commit

Permalink
Fix 3YOURMIND#292 Run in FIPS enabled environment with python3.10
Browse files Browse the repository at this point in the history
Python 3.10 and later versions rely on OpenSSL 1.1.1 or newer, which includes FIPS-compliance checks.

MD5 is not an approved algorithm in FIPS mode, so attempting to instantiate hashlib.md5() will fail when the system is running in FIPS mode.
Since MD5 is used in a non-security context, the change adds the [_usedforsecurity_](https://docs.python.org/3/library/hashlib.html) flag.

The same issue in Django django/django@d10c7bf
  • Loading branch information
markesha authored and markesha committed Nov 15, 2024
1 parent 183bdd5 commit b39e047
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/django_migration_linter/migration_linter.py
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ def lint_migration(self, migration: Migration) -> None:

@staticmethod
def get_migration_hash(app_label: str, migration_name: str) -> str:
hash_md5 = hashlib.md5()
hash_md5 = hashlib.md5(usedforsecurity=False)
with open(get_migration_abspath(app_label, migration_name), "rb") as f:
for chunk in iter(lambda: f.read(4096), b""):
hash_md5.update(chunk)
Expand Down

0 comments on commit b39e047

Please sign in to comment.