Skip to content

Commit c9c452b

Browse files
authored
fix: setup hashlib for fips compliance (#123)
Signed-off-by: Michele Dolfi <[email protected]>
1 parent 4bd9434 commit c9c452b

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

docling_parse/pdf_parser.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -455,7 +455,7 @@ def load(
455455
success = self._load_document(key=key, filename=str(path_or_stream))
456456

457457
elif isinstance(path_or_stream, BytesIO):
458-
hasher = hashlib.md5()
458+
hasher = hashlib.sha256(usedforsecurity=False)
459459

460460
while chunk := path_or_stream.read(8192):
461461
hasher.update(chunk)

docling_parse/processing_dir.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ def fetch_files_from_disk(directory, recursive, task_queue):
7373

7474
file_name = str(Path(filename).resolve())
7575

76-
hash_object = hashlib.sha256(filename.encode())
76+
hash_object = hashlib.sha256(filename.encode(), usedforsecurity=False)
7777
file_hash = hash_object.hexdigest()
7878

7979
# Create a FileTask object

docling_parse/processing_s3.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ def fetch_files_from_s3(
171171
data = response["Body"].read()
172172
173173
# Generate a hash (e.g., SHA-256)
174-
hash_object = hashlib.sha256(data)
174+
hash_object = hashlib.sha256(data, usedforsecurity=False)
175175
file_hash = hash_object.hexdigest()
176176
177177
local_file = os.path.join(local_dir, f"{file_hash}.pdf")
@@ -248,7 +248,7 @@ def retrieve_file(s3_client, task):
248248
task.data = BytesIO(response["Body"].read()) # response["Body"].read()
249249

250250
# Generate a hash (e.g., SHA-256)
251-
hash_object = hashlib.sha256(task.data.read())
251+
hash_object = hashlib.sha256(task.data.read(), usedforsecurity=False)
252252
task.file_hash = str(hash_object.hexdigest())
253253

254254
return task

0 commit comments

Comments
 (0)