Skip to content

Commit

Permalink
Fixed incorrect blanked-out password-like properties
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
andy-maier committed Nov 28, 2024
1 parent 966d994 commit b9348a6
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 10 deletions.
2 changes: 2 additions & 0 deletions changes/noissue.5.fix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Fixed that incorrect password-like properties were added with blanked-out values
to the API and HMC log.
8 changes: 3 additions & 5 deletions zhmcclient/_logging.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
8 changes: 3 additions & 5 deletions zhmcclient/_session.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit b9348a6

Please sign in to comment.