Ensure heuristic_log_sanitize returns correct data if no password found (#75570)

* Ensure heuristic_log_sanitize returns correct data if no password found. See #75542

* Need to allow code to flow through
This commit is contained in:
Matt Martz
2021-08-26 12:13:51 -07:00
committed by GitHub
parent d83acc1c4c
commit 74f5367673
3 changed files with 7 additions and 1 deletions
@@ -0,0 +1,3 @@
bugfixes:
- >
``heuristic_log_sanitize`` - Return the full string if there is no password (https://github.com/ansible/ansible/issues/75542)
+1 -1
View File
@@ -350,7 +350,7 @@ def heuristic_log_sanitize(data, no_log_values=None):
if begin == 0:
# Searched the whole string so there's no password
# here. Return the remaining data
output.insert(0, data[0:begin])
output.insert(0, data[0:prev_begin])
break
# Search for a different beginning of the password field.
sep_search_end = begin
@@ -87,3 +87,6 @@ class TestHeuristicLogSanitize(unittest.TestCase):
def test_hides_parameter_secrets(self):
output = heuristic_log_sanitize('token="secret", user="person", token_entry="test=secret"', frozenset(['secret']))
self.assertNotIn('secret', output)
def test_no_password(self):
self.assertEqual(heuristic_log_sanitize('foo@bar'), 'foo@bar')