From 8011c38182c278600cff7590b2905f28ea5b77e7 Mon Sep 17 00:00:00 2001 From: DueViktor Date: Wed, 8 Jan 2025 16:21:44 +0100 Subject: [PATCH 1/5] FIPS compliant --- src/evidently/pydantic_utils.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/evidently/pydantic_utils.py b/src/evidently/pydantic_utils.py index 971935959a..669909abe6 100644 --- a/src/evidently/pydantic_utils.py +++ b/src/evidently/pydantic_utils.py @@ -5,6 +5,7 @@ import json import os import warnings +import sys from abc import ABC from enum import Enum from functools import lru_cache @@ -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,7 @@ 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 +569,5 @@ 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 From a0a533b43107fb275ef13a26fed381a9e9760bce Mon Sep 17 00:00:00 2001 From: Viktor Due <66885944+DueViktor@users.noreply.github.com> Date: Mon, 13 Jan 2025 08:47:26 +0100 Subject: [PATCH 2/5] trailing From 757ad0f31a0e74ec45f8bd2ec3a27064e7d0c4b8 Mon Sep 17 00:00:00 2001 From: DueViktor Date: Tue, 21 Jan 2025 12:16:04 +0100 Subject: [PATCH 3/5] ruff --- src/evidently/pydantic_utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/evidently/pydantic_utils.py b/src/evidently/pydantic_utils.py index 669909abe6..873eb16c28 100644 --- a/src/evidently/pydantic_utils.py +++ b/src/evidently/pydantic_utils.py @@ -4,8 +4,8 @@ import itertools import json import os -import warnings import sys +import warnings from abc import ABC from enum import Enum from functools import lru_cache From eca1ce23e5502bca25e6f557de18db8844e51700 Mon Sep 17 00:00:00 2001 From: DueViktor Date: Thu, 23 Jan 2025 12:48:17 +0100 Subject: [PATCH 4/5] ruff format --- src/evidently/pydantic_utils.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/evidently/pydantic_utils.py b/src/evidently/pydantic_utils.py index 873eb16c28..ddc6c6e8c8 100644 --- a/src/evidently/pydantic_utils.py +++ b/src/evidently/pydantic_utils.py @@ -314,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"), **md5_kwargs).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( @@ -569,5 +571,5 @@ 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"), **md5_kwargs).hexdigest() # nosec: B324 From 7f3c9f03c230024886c54db7914a5156c5f50334 Mon Sep 17 00:00:00 2001 From: DueViktor Date: Thu, 23 Jan 2025 12:52:53 +0100 Subject: [PATCH 5/5] removed unnecessary change --- src/evidently/pydantic_utils.py | 1 - 1 file changed, 1 deletion(-) diff --git a/src/evidently/pydantic_utils.py b/src/evidently/pydantic_utils.py index ddc6c6e8c8..81c20a2d73 100644 --- a/src/evidently/pydantic_utils.py +++ b/src/evidently/pydantic_utils.py @@ -571,5 +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"), **md5_kwargs).hexdigest() # nosec: B324