mirror of
https://github.com/Stone-Red-Code/dvc.git
synced 2026-11-02 07:18:25 +01:00
hashing: Add usedforsecurity=False on hashlib calls (#10826)
This commit is contained in:
@@ -9,7 +9,7 @@ from dvc.utils.fs import remove
|
||||
|
||||
|
||||
def digest(text):
|
||||
return hashlib.md5(bytes(text, "utf-8")).hexdigest()
|
||||
return hashlib.md5(bytes(text, "utf-8"), usedforsecurity=False).hexdigest()
|
||||
|
||||
|
||||
def test_no_scm(tmp_dir, dvc):
|
||||
|
||||
@@ -67,7 +67,9 @@ class DVCFixtures:
|
||||
└── 📄 {hashed([0-9])}.txt
|
||||
"""
|
||||
dir_contents = {
|
||||
md5(str(i).encode("utf-8")).hexdigest() + ".txt": str(i) for i in range(10)
|
||||
md5(str(i).encode("utf-8"), usedforsecurity=False).hexdigest()
|
||||
+ ".txt": str(i)
|
||||
for i in range(10)
|
||||
}
|
||||
tmp_dir.dvc_gen({"source": dir_contents}, commit="add source")
|
||||
tmp_dir.scm_gen(".gitignore", "/source", commit="add .gitignore")
|
||||
@@ -751,7 +753,7 @@ class TestDVCFileSystemGet(DVCFixtures):
|
||||
source_files = []
|
||||
destination_files = []
|
||||
for i in range(10):
|
||||
hashed_i = md5(str(i).encode("utf-8")).hexdigest()
|
||||
hashed_i = md5(str(i).encode("utf-8"), usedforsecurity=False).hexdigest()
|
||||
source_files.append(fs_join(source, f"{hashed_i}.txt"))
|
||||
destination_files.append(
|
||||
make_path_posix(local_join(target, f"{hashed_i}.txt"))
|
||||
|
||||
@@ -176,7 +176,7 @@ def test_system_info():
|
||||
)
|
||||
def test_git_remote_hash(mocker, git_remote):
|
||||
m = mocker.patch("dvc.analytics._git_remote_url", return_value=git_remote)
|
||||
expected = hashlib.md5(b"iterative/dvc.git").hexdigest()
|
||||
expected = hashlib.md5(b"iterative/dvc.git", usedforsecurity=False).hexdigest()
|
||||
|
||||
assert analytics._git_remote_path_hash(None) == expected
|
||||
m.assert_called_once_with(None)
|
||||
@@ -194,6 +194,8 @@ def test_git_remote_hash(mocker, git_remote):
|
||||
def test_git_remote_hash_local(mocker, git_remote):
|
||||
m = mocker.patch("dvc.analytics._git_remote_url", return_value=git_remote)
|
||||
|
||||
expected = hashlib.md5(git_remote.encode("utf-8")).hexdigest()
|
||||
expected = hashlib.md5(
|
||||
git_remote.encode("utf-8"), usedforsecurity=False
|
||||
).hexdigest()
|
||||
assert analytics._git_remote_path_hash(None) == expected
|
||||
m.assert_called_once_with(None)
|
||||
|
||||
Reference in New Issue
Block a user