mirror of
https://github.com/ansible/awx.git
synced 2026-05-08 01:47:35 -02:30
deal with case that can cause memory errors
This commit is contained in:
@@ -609,6 +609,8 @@ class Job(UnifiedJob, JobOptions, SurveyJobMixin, JobNotificationMixin):
|
|||||||
if k in job_extra_vars]
|
if k in job_extra_vars]
|
||||||
return_content = content
|
return_content = content
|
||||||
for val in password_list:
|
for val in password_list:
|
||||||
|
if len(val) == 0:
|
||||||
|
continue # avoids memory errors
|
||||||
return_content = PlainTextCleaner.remove_sensitive(return_content, val)
|
return_content = PlainTextCleaner.remove_sensitive(return_content, val)
|
||||||
return return_content
|
return return_content
|
||||||
|
|
||||||
|
|||||||
@@ -58,4 +58,6 @@ class PlainTextCleaner(object):
|
|||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def remove_sensitive(cleartext, sensitive):
|
def remove_sensitive(cleartext, sensitive):
|
||||||
|
if sensitive == '':
|
||||||
|
return cleartext
|
||||||
return re.sub(r'%s' % re.escape(sensitive), '$encrypted$', cleartext)
|
return re.sub(r'%s' % re.escape(sensitive), '$encrypted$', cleartext)
|
||||||
|
|||||||
@@ -61,6 +61,11 @@ def test_survey_passwords_not_in_extra_vars():
|
|||||||
|
|
||||||
@pytest.mark.survey
|
@pytest.mark.survey
|
||||||
def test_survey_passwords_not_in_stdout(job_with_survey):
|
def test_survey_passwords_not_in_stdout(job_with_survey):
|
||||||
|
job_with_survey.survey_passwords['has_blank_value'] = '$encrypted$'
|
||||||
|
job_with_survey.extra_vars = json.dumps({
|
||||||
|
'has_blank_value': '',
|
||||||
|
'secret_key': '6kQngg3h8lgiSTvIEb21',
|
||||||
|
'SSN': '123-45-6789'})
|
||||||
example_stdout = '''
|
example_stdout = '''
|
||||||
PLAY [all] *********************************************************************
|
PLAY [all] *********************************************************************
|
||||||
|
|
||||||
@@ -77,6 +82,7 @@ TASK [debug] *******************************************************************
|
|||||||
display_stdout = job_with_survey._survey_search_and_replace(example_stdout)
|
display_stdout = job_with_survey._survey_search_and_replace(example_stdout)
|
||||||
assert display_stdout == example_stdout.replace(
|
assert display_stdout == example_stdout.replace(
|
||||||
'6kQngg3h8lgiSTvIEb21', '$encrypted$').replace('123-45-6789', '$encrypted$')
|
'6kQngg3h8lgiSTvIEb21', '$encrypted$').replace('123-45-6789', '$encrypted$')
|
||||||
|
assert type(display_stdout) == type(example_stdout)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user