mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Adapt sanitize_output to log messages instead of assuming properly formatted key-value pairs
Fixes #10332
This commit is contained in:
parent
2d74bd4891
commit
8a5067d628
1 changed files with 12 additions and 6 deletions
|
@ -938,20 +938,26 @@ def getch():
|
||||||
termios.tcsetattr(fd, termios.TCSADRAIN, old_settings)
|
termios.tcsetattr(fd, termios.TCSADRAIN, old_settings)
|
||||||
return ch
|
return ch
|
||||||
|
|
||||||
def sanitize_output(str):
|
def sanitize_output(arg_string):
|
||||||
''' strips private info out of a string '''
|
''' strips private info out of a string '''
|
||||||
|
|
||||||
private_keys = ['password', 'login_password']
|
private_keys = ('password', 'login_password')
|
||||||
|
|
||||||
parts = parse_kv(str)
|
|
||||||
output = []
|
output = []
|
||||||
for (k, v) in parts.items():
|
for part in arg_string.split():
|
||||||
if k in private_keys:
|
try:
|
||||||
output.append("%s=VALUE_HIDDEN" % k)
|
(k, v) = part.split('=', 1)
|
||||||
|
except ValueError:
|
||||||
|
v = heuristic_log_sanitize(part)
|
||||||
|
output.append(v)
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
if k in private_keys:
|
||||||
|
v = 'VALUE_HIDDEN'
|
||||||
else:
|
else:
|
||||||
v = heuristic_log_sanitize(v)
|
v = heuristic_log_sanitize(v)
|
||||||
output.append('%s=%s' % (k, v))
|
output.append('%s=%s' % (k, v))
|
||||||
|
|
||||||
output = ' '.join(output)
|
output = ' '.join(output)
|
||||||
return output
|
return output
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue