mirror of
https://github.com/ZwareBear/awx.git
synced 2026-04-28 02:41:49 -05:00
Validate against ansible variables on ad hoc launch
Share code between this check for ad hoc and JT callback
This commit is contained in:
@@ -45,7 +45,7 @@ from awx.main.fields import ImplicitRoleField
|
||||
from awx.main.utils import (
|
||||
get_type_for_model, get_model_for_type, timestamp_apiformat,
|
||||
camelcase_to_underscore, getattrd, parse_yaml_or_json,
|
||||
has_model_field_prefetched)
|
||||
has_model_field_prefetched, extract_ansible_vars)
|
||||
from awx.main.utils.filters import SmartFilter
|
||||
|
||||
from awx.main.validators import vars_validate_or_raise
|
||||
@@ -2759,6 +2759,14 @@ class AdHocCommandSerializer(UnifiedJobSerializer):
|
||||
ret['name'] = obj.module_name
|
||||
return ret
|
||||
|
||||
def validate_extra_vars(self, value):
|
||||
redacted_extra_vars, removed_vars = extract_ansible_vars(value)
|
||||
if removed_vars:
|
||||
raise serializers.ValidationError(_(
|
||||
"Variables {} are prohibited from use in ad hoc commands."
|
||||
).format(",".join(removed_vars)))
|
||||
return vars_validate_or_raise(value)
|
||||
|
||||
|
||||
class AdHocCommandCancelSerializer(AdHocCommandSerializer):
|
||||
|
||||
|
||||
Reference in New Issue
Block a user