mirror of
https://github.com/ansible/awx.git
synced 2026-01-11 01:57:35 -03:30
Merge pull request #6254 from ryanpetrello/redact-faster
optimize the awx.main.redact SCM URL sanitizer regex Reviewed-by: https://github.com/apps/softwarefactory-project-zuul
This commit is contained in:
commit
0fd9153cf7
@ -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):
|
||||
|
||||
@ -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
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user