diff --git a/src/evidently/pydantic_utils.py b/src/evidently/pydantic_utils.py index 971935959a..81c20a2d73 100644 --- a/src/evidently/pydantic_utils.py +++ b/src/evidently/pydantic_utils.py @@ -4,6 +4,7 @@ import itertools import json import os +import sys import warnings from abc import ABC from enum import Enum @@ -37,6 +38,8 @@ if TYPE_CHECKING: from evidently._pydantic_compat import DictStrAny +md5_kwargs = {"usedforsecurity": False} if sys.version_info >= (3, 9) else {} + T = TypeVar("T") @@ -311,7 +314,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( @@ -566,4 +571,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