diff --git a/awx/main/redact.py b/awx/main/redact.py index 77fc062135..4c286eb9a8 100644 --- a/awx/main/redact.py +++ b/awx/main/redact.py @@ -8,7 +8,7 @@ REPLACE_STR = '$encrypted$' class UriCleaner(object): REPLACE_STR = REPLACE_STR - SENSITIVE_URI_PATTERN = re.compile(r'(\w+:(\/?\/?)[^\s]+)', re.MULTILINE) # NOQA + SENSITIVE_URI_PATTERN = re.compile(r'(\w{1,20}:(\/?\/?)[^\s]+)', re.MULTILINE) # NOQA @staticmethod def remove_sensitive(cleartext): diff --git a/awx/main/tests/unit/test_redact.py b/awx/main/tests/unit/test_redact.py index fa59ca43d7..d240ccb9ce 100644 --- a/awx/main/tests/unit/test_redact.py +++ b/awx/main/tests/unit/test_redact.py @@ -152,3 +152,10 @@ def test_uri_scm_cleartext_redact_and_replace(test_data): # Ensure the host didn't get redacted assert redacted_str.count(uri.host) == test_data['host_occurrences'] + +@pytest.mark.timeout(1) +def test_large_string_performance(): + length = 100000 + redacted = UriCleaner.remove_sensitive('x' * length) + assert len(redacted) == length +