Skip to content

Commit

Permalink
FIPS compliant (#1411)
Browse files Browse the repository at this point in the history
  • Loading branch information
DueViktor authored Jan 23, 2025
1 parent 113b3b1 commit 70f932f
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/evidently/pydantic_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import itertools
import json
import os
import sys
import warnings
from abc import ABC
from enum import Enum
Expand Down Expand Up @@ -38,6 +39,8 @@
if TYPE_CHECKING:
from evidently._pydantic_compat import DictStrAny

md5_kwargs = {"usedforsecurity": False} if sys.version_info >= (3, 9) else {}


T = TypeVar("T")

Expand Down Expand Up @@ -315,7 +318,9 @@ class Config:
is_base_type = True

def get_fingerprint(self) -> Fingerprint:
return hashlib.md5((self.__get_classpath__() + str(self.get_fingerprint_parts())).encode("utf8")).hexdigest()
return hashlib.md5(
(self.__get_classpath__() + str(self.get_fingerprint_parts())).encode("utf8"), **md5_kwargs
).hexdigest()

def get_fingerprint_parts(self) -> Tuple[FingerprintPart, ...]:
return tuple(
Expand Down Expand Up @@ -570,4 +575,4 @@ def get_object_hash_deprecated(obj: Union[BaseModel, dict]):

if isinstance(obj, BaseModel):
obj = obj.dict()
return hashlib.md5(json.dumps(obj, cls=NumpyEncoder).encode("utf8")).hexdigest() # nosec: B324
return hashlib.md5(json.dumps(obj, cls=NumpyEncoder).encode("utf8"), **md5_kwargs).hexdigest() # nosec: B324

0 comments on commit 70f932f

Please sign in to comment.