disallow new survey spec with password default $encrypted$

This commit is contained in:
Chris Meyers
2017-07-12 15:16:51 -04:00
parent 7435162b87
commit d3e4be66dd

View File

@@ -2907,6 +2907,10 @@ class JobTemplateSurveySpec(GenericAPIView):
if survey_item["type"] == "password": if survey_item["type"] == "password":
if survey_item.get("default") and survey_item["default"].startswith('$encrypted$'): if survey_item.get("default") and survey_item["default"].startswith('$encrypted$'):
if not obj.survey_spec:
return Response(dict(error=_("$encrypted$ is reserved keyword and may not be used as a default for password {}.".format(str(idx)))),
status=status.HTTP_400_BAD_REQUEST)
else:
old_spec = obj.survey_spec old_spec = obj.survey_spec
for old_item in old_spec['spec']: for old_item in old_spec['spec']:
if old_item['variable'] == survey_item['variable']: if old_item['variable'] == survey_item['variable']: