From b9348a6b8ba4ef277db67aa4cf64c249f10f8ef8 Mon Sep 17 00:00:00 2001 From: Andreas Maier Date: Thu, 28 Nov 2024 20:02:39 +0100 Subject: [PATCH] Fixed incorrect blanked-out password-like properties Details: * The previous fix that blanked out clear-text password-like properties had the issue that by mistake it added all possible password-like properties with blanked-out values ot the API entry log and HMC request log. This change reduces that again to only the properties that exist for the resource type. Signed-off-by: Andreas Maier --- changes/noissue.5.fix.rst | 2 ++ zhmcclient/_logging.py | 8 +++----- zhmcclient/_session.py | 8 +++----- 3 files changed, 8 insertions(+), 10 deletions(-) create mode 100644 changes/noissue.5.fix.rst diff --git a/changes/noissue.5.fix.rst b/changes/noissue.5.fix.rst new file mode 100644 index 00000000..af388d4e --- /dev/null +++ b/changes/noissue.5.fix.rst @@ -0,0 +1,2 @@ +Fixed that incorrect password-like properties were added with blanked-out values +to the API and HMC log. diff --git a/zhmcclient/_logging.py b/zhmcclient/_logging.py index 80ed92c3..7c3a1771 100644 --- a/zhmcclient/_logging.py +++ b/zhmcclient/_logging.py @@ -255,11 +255,9 @@ def blanked_dict(properties): # properties may also be a DictView (subclass of Mapping) assert isinstance(properties, Mapping) copied_properties = dict(properties) - for pn in blanked_properties: - try: - copied_properties[pn] = BLANKED_OUT_STRING - except KeyError: - pass + for pname in blanked_properties: + if pname in copied_properties: + copied_properties[pname] = BLANKED_OUT_STRING return copied_properties def blanked_args(args, kwargs): diff --git a/zhmcclient/_session.py b/zhmcclient/_session.py index 500d569f..1b748ab1 100644 --- a/zhmcclient/_session.py +++ b/zhmcclient/_session.py @@ -967,11 +967,9 @@ def _log_http_request( # structured data such as a password or session IDs. pass else: - for prop in BLANKED_OUT_PROPERTIES: - try: - content_dict[prop] = BLANKED_OUT_STRING - except KeyError: - pass + for pname in BLANKED_OUT_PROPERTIES: + if pname in content_dict: + content_dict[pname] = BLANKED_OUT_STRING content = dict2json(content_dict) trunc = 30000 if content_len > trunc: