enforce strings for secret password inputs on Credentials

see: https://github.com/ansible/ansible-tower/issues/7898
This commit is contained in:
Ryan Petrello 2018-02-12 16:10:26 -05:00
parent bd2f1568fb
commit 82e41b40bb
No known key found for this signature in database
GPG Key ID: F2AA5F2122351777

View File

@ -499,6 +499,12 @@ class CredentialInputField(JSONSchemaField):
v != '$encrypted$',
model_instance.pk
]):
if not isinstance(getattr(model_instance, k), six.string_types):
raise django_exceptions.ValidationError(
_('secret values must be of type string, not {}').format(type(v).__name__),
code='invalid',
params={'value': v},
)
decrypted_values[k] = utils.decrypt_field(model_instance, k)
else:
decrypted_values[k] = v