Skip to content

Commit

Permalink
Update binding.py
Browse files Browse the repository at this point in the history
- updated keys in SENSITIVE_KEYS list
- masked headers data in logger
  • Loading branch information
akaila-splunk committed Jul 12, 2023
1 parent 95fa079 commit 46bd4cc
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions splunklib/binding.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,10 @@
"HTTPError"
]

SENSITIVE_KEYS = ["password", "token", "Authorization"]
SENSITIVE_KEYS = ['Authorization', 'Cookie', 'action.email.auth_password', 'auth', 'auth_password', 'clear_password', 'clientId',
'crc-salt', 'encr_password', 'oldpassword', 'passAuth', 'password', 'session', 'suppressionKey',
'token']

# If you change these, update the docstring
# on _authority as well.
DEFAULT_HOST = "localhost"
Expand Down Expand Up @@ -90,7 +93,8 @@ def mask_sensitive_data(data):
except Exception as ex:
return data

if not isinstance(data, dict):
# json.loads will return "123"(str) as 123(int), so return the data
if isinstance(data, int):
return data
mdata = {}
for k, v in data.items():
Expand Down Expand Up @@ -863,8 +867,7 @@ def request(self, path_segment, method="GET", headers=None, body={},

all_headers = headers + self.additional_headers + self._auth_headers
logger.debug("%s request to %s (headers: %s, body: %s)",
method, path, str(all_headers), mask_sensitive_data(body))

method, path, str(mask_sensitive_data(dict(all_headers))), mask_sensitive_data(body))
if body:
body = _encode(**body)

Expand Down

0 comments on commit 46bd4cc

Please sign in to comment.