mirror of
https://github.com/ansible/awx.git
synced 2026-03-11 22:49:32 -02: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:
@@ -8,7 +8,7 @@ REPLACE_STR = '$encrypted$'
|
|||||||
|
|
||||||
class UriCleaner(object):
|
class UriCleaner(object):
|
||||||
REPLACE_STR = REPLACE_STR
|
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
|
@staticmethod
|
||||||
def remove_sensitive(cleartext):
|
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
|
# Ensure the host didn't get redacted
|
||||||
assert redacted_str.count(uri.host) == test_data['host_occurrences']
|
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
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user