mirror of
https://github.com/ansible/awx.git
synced 2024-11-01 16:51:11 +03:00
fix a bug in survey password default validation
see: https://github.com/ansible/ansible-tower/issues/7046 see: https://github.com/ansible/ansible-tower/issues/7764 see: https://github.com/ansible/ansible-tower/issues/7784
This commit is contained in:
parent
5a2ecd25e7
commit
044c047ac6
@ -166,15 +166,19 @@ class SurveyJobTemplateMixin(models.Model):
|
|||||||
# make a copy of the data to break references (so that we don't
|
# make a copy of the data to break references (so that we don't
|
||||||
# inadvertently expose unencrypted default passwords as we validate)
|
# inadvertently expose unencrypted default passwords as we validate)
|
||||||
data = data.copy()
|
data = data.copy()
|
||||||
if all([
|
password_value = data.get(survey_element['variable'])
|
||||||
survey_element['type'] == "password",
|
if (
|
||||||
data.get(survey_element['variable']) == '$encrypted$'
|
survey_element['type'] == "password" and
|
||||||
]):
|
isinstance(password_value, basestring) and
|
||||||
# replace encrypted password defaults so we don't validate on
|
password_value.startswith('$encrypted$')
|
||||||
# $encrypted$
|
):
|
||||||
|
if password_value == '$encrypted$':
|
||||||
|
# replace encrypted password defaults so we don't validate on
|
||||||
|
# $encrypted$
|
||||||
|
password_value = survey_element['default']
|
||||||
data[survey_element['variable']] = decrypt_value(
|
data[survey_element['variable']] = decrypt_value(
|
||||||
get_encryption_key('value', pk=None),
|
get_encryption_key('value', pk=None),
|
||||||
survey_element['default']
|
password_value
|
||||||
)
|
)
|
||||||
if survey_element['variable'] not in data and survey_element['required']:
|
if survey_element['variable'] not in data and survey_element['required']:
|
||||||
errors.append("'%s' value missing" % survey_element['variable'])
|
errors.append("'%s' value missing" % survey_element['variable'])
|
||||||
|
Loading…
Reference in New Issue
Block a user