mirror of
https://github.com/ansible/awx.git
synced 2026-04-22 18:25:28 -02:30
Force custom inventory scripts to start with a hashbang
This commit is contained in:
@@ -979,6 +979,12 @@ class CustomInventoryScriptSerializer(BaseSerializer):
|
||||
model = CustomInventoryScript
|
||||
fields = ('*', "script", "organization")
|
||||
|
||||
def validate_script(self, attrs, source):
|
||||
script_contents = attrs.get(source, '')
|
||||
if not script_contents.startswith("#!"):
|
||||
raise serializers.ValidationError('Script must begin with a hashbang sequence: i.e.... #!/usr/bin/env python')
|
||||
return attrs
|
||||
|
||||
def to_native(self, obj):
|
||||
ret = super(CustomInventoryScriptSerializer, self).to_native(obj)
|
||||
if obj is None:
|
||||
|
||||
Reference in New Issue
Block a user