mirror of
https://github.com/ansible/awx.git
synced 2026-02-04 11:08:13 -03:30
render survey_spec for display purposes in a safe manner
survey_spec is a nested dict, so if we don't `deepcopy()` it, updates to the individual fields could corrupt the original data structure; this was causing a bug whereby activity stream updates converted encrypted survey password defaults -> `$encrypted$`, but inadvertently modified the originating model due to shared references see: https://github.com/ansible/ansible-tower/issues/7769
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
# Python
|
||||
import json
|
||||
from copy import copy
|
||||
from copy import copy, deepcopy
|
||||
|
||||
# Django
|
||||
from django.db import models
|
||||
@@ -257,7 +257,7 @@ class SurveyJobTemplateMixin(models.Model):
|
||||
'''
|
||||
Hide encrypted default passwords in survey specs
|
||||
'''
|
||||
survey_spec = self.survey_spec.copy() if self.survey_spec else {}
|
||||
survey_spec = deepcopy(self.survey_spec) if self.survey_spec else {}
|
||||
for field in survey_spec.get('spec', []):
|
||||
if field.get('type') == 'password':
|
||||
if 'default' in field and field['default']:
|
||||
|
||||
Reference in New Issue
Block a user