From 8a5067d628755e2f0ebefdca6a88ecd90e0242a3 Mon Sep 17 00:00:00 2001 From: Toshio Kuratomi Date: Thu, 26 Feb 2015 12:28:02 -0800 Subject: [PATCH] Adapt sanitize_output to log messages instead of assuming properly formatted key-value pairs Fixes #10332 --- lib/ansible/utils/__init__.py | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/lib/ansible/utils/__init__.py b/lib/ansible/utils/__init__.py index 6ed01266b3..433c30db6a 100644 --- a/lib/ansible/utils/__init__.py +++ b/lib/ansible/utils/__init__.py @@ -938,20 +938,26 @@ def getch(): termios.tcsetattr(fd, termios.TCSADRAIN, old_settings) return ch -def sanitize_output(str): +def sanitize_output(arg_string): ''' strips private info out of a string ''' - private_keys = ['password', 'login_password'] + private_keys = ('password', 'login_password') - parts = parse_kv(str) output = [] - for (k, v) in parts.items(): - if k in private_keys: - output.append("%s=VALUE_HIDDEN" % k) + for part in arg_string.split(): + try: + (k, v) = part.split('=', 1) + except ValueError: + v = heuristic_log_sanitize(part) + output.append(v) continue + + if k in private_keys: + v = 'VALUE_HIDDEN' else: v = heuristic_log_sanitize(v) output.append('%s=%s' % (k, v)) + output = ' '.join(output) return output