From 43126b11573ffff22f3c84be0f419e6fb38b4edb Mon Sep 17 00:00:00 2001 From: Scott Hazelhurst Date: Wed, 3 Apr 2024 09:25:08 +0200 Subject: [PATCH] md5 changes to make it FIPS compliant --- repo_utils/test_files/external/fake_mafft/mafft | 2 +- .../test_files/external/fake_mafft/make_fake_mafft_results.py | 2 +- truvari/phab.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/repo_utils/test_files/external/fake_mafft/mafft b/repo_utils/test_files/external/fake_mafft/mafft index 4e757f7..fbc47f9 100755 --- a/repo_utils/test_files/external/fake_mafft/mafft +++ b/repo_utils/test_files/external/fake_mafft/mafft @@ -11,7 +11,7 @@ sys.stderr.write(f"Running fake MAFFT\n") m_dir = os.path.dirname(os.path.realpath(__file__)) stdin = sys.stdin.read() -md5sum = hashlib.md5(stdin.encode()).hexdigest() +md5sum = hashlib.md5(stdin.encode(),usedforsecurity=False).hexdigest() fn = os.path.join(m_dir, f"lookup/fm_{md5sum}.msa") #if not os.path.exists(fn): diff --git a/repo_utils/test_files/external/fake_mafft/make_fake_mafft_results.py b/repo_utils/test_files/external/fake_mafft/make_fake_mafft_results.py index 2d799e0..cdb8dea 100644 --- a/repo_utils/test_files/external/fake_mafft/make_fake_mafft_results.py +++ b/repo_utils/test_files/external/fake_mafft/make_fake_mafft_results.py @@ -16,7 +16,7 @@ for haps in all_haps: # For every haps.fa, read it in, get a hash key, save hash key to file's msa.fa with open(haps, 'r') as fh: data = fh.read() - m_key = hashlib.md5(data.encode('utf-8')).hexdigest() + m_key = hashlib.md5(data.encode('utf-8'),usedforsecurity=False).hexdigest() if m_key in lookup: sys.stderr.write("!!WARN!! Conflicting key %s on %s with %s\n" % (m_key, haps, lookup[m_key])) lookup[m_key] = os.path.join(os.path.dirname(haps), 'msa.fa') diff --git a/truvari/phab.py b/truvari/phab.py index e17f336..a6e2920 100644 --- a/truvari/phab.py +++ b/truvari/phab.py @@ -285,7 +285,7 @@ def run_mafft(seq_bytes, params=DEFAULT_MAFFT_PARAM): dev_name = None if "PHAB_WRITE_MAFFT" in os.environ and os.environ["PHAB_WRITE_MAFFT"] == "1": import hashlib # pylint: disable=import-outside-toplevel - dev_name = hashlib.md5(seq_bytes).hexdigest() + dev_name = hashlib.md5(seq_bytes,usedforsecurity=False).hexdigest() ret = truvari.cmd_exe(f"mafft --quiet {params} -", stdin=seq_bytes) if ret.ret_code != 0: -- 2.39.3