mirror of
https://github.com/ZwareBear/awx.git
synced 2026-04-30 03:41:50 -05:00
Added API validation of instance filter names. Fixes https://trello.com/c/VH9Vnd8z
This commit is contained in:
@@ -744,6 +744,89 @@ class InventorySourceOptions(BaseModel):
|
||||
('custom', _('Custom Script')),
|
||||
]
|
||||
|
||||
# Use tools/scripts/get_ec2_filter_names.py to build this list.
|
||||
INSTANCE_FILTER_NAMES = [
|
||||
"architecture",
|
||||
"association.allocation-id",
|
||||
"association.association-id",
|
||||
"association.ip-owner-id",
|
||||
"association.public-ip",
|
||||
"availability-zone",
|
||||
"block-device-mapping.attach-time",
|
||||
"block-device-mapping.delete-on-termination",
|
||||
"block-device-mapping.device-name",
|
||||
"block-device-mapping.status",
|
||||
"block-device-mapping.volume-id",
|
||||
"client-token",
|
||||
"dns-name",
|
||||
"group-id",
|
||||
"group-name",
|
||||
"hypervisor",
|
||||
"iam-instance-profile.arn",
|
||||
"image-id",
|
||||
"instance-id",
|
||||
"instance-lifecycle",
|
||||
"instance-state-code",
|
||||
"instance-state-name",
|
||||
"instance-type",
|
||||
"instance.group-id",
|
||||
"instance.group-name",
|
||||
"ip-address",
|
||||
"kernel-id",
|
||||
"key-name",
|
||||
"launch-index",
|
||||
"launch-time",
|
||||
"monitoring-state",
|
||||
"network-interface-private-dns-name",
|
||||
"network-interface.addresses.association.ip-owner-id",
|
||||
"network-interface.addresses.association.public-ip",
|
||||
"network-interface.addresses.primary",
|
||||
"network-interface.addresses.private-ip-address",
|
||||
"network-interface.attachment.attach-time",
|
||||
"network-interface.attachment.attachment-id",
|
||||
"network-interface.attachment.delete-on-termination",
|
||||
"network-interface.attachment.device-index",
|
||||
"network-interface.attachment.instance-id",
|
||||
"network-interface.attachment.instance-owner-id",
|
||||
"network-interface.attachment.status",
|
||||
"network-interface.availability-zone",
|
||||
"network-interface.description",
|
||||
"network-interface.group-id",
|
||||
"network-interface.group-name",
|
||||
"network-interface.mac-address",
|
||||
"network-interface.network-interface.id",
|
||||
"network-interface.owner-id",
|
||||
"network-interface.requester-id",
|
||||
"network-interface.requester-managed",
|
||||
"network-interface.source-destination-check",
|
||||
"network-interface.status",
|
||||
"network-interface.subnet-id",
|
||||
"network-interface.vpc-id",
|
||||
"owner-id",
|
||||
"placement-group-name",
|
||||
"platform",
|
||||
"private-dns-name",
|
||||
"private-ip-address",
|
||||
"product-code",
|
||||
"product-code.type",
|
||||
"ramdisk-id",
|
||||
"reason",
|
||||
"requester-id",
|
||||
"reservation-id",
|
||||
"root-device-name",
|
||||
"root-device-type",
|
||||
"source-dest-check",
|
||||
"spot-instance-request-id",
|
||||
"state-reason-code",
|
||||
"state-reason-message",
|
||||
"subnet-id",
|
||||
"tag-key",
|
||||
"tag-value",
|
||||
"tenancy",
|
||||
"virtualization-type",
|
||||
"vpc-id"
|
||||
]
|
||||
|
||||
class Meta:
|
||||
abstract = True
|
||||
|
||||
@@ -938,6 +1021,10 @@ class InventorySourceOptions(BaseModel):
|
||||
continue
|
||||
if not instance_filter_re.match(instance_filter):
|
||||
invalid_filters.append(instance_filter)
|
||||
continue
|
||||
instance_filter_name = instance_filter.split('=', 1)[0]
|
||||
if instance_filter_name not in self.INSTANCE_FILTER_NAMES:
|
||||
invalid_filters.append(instance_filter)
|
||||
if invalid_filters:
|
||||
raise ValidationError('Invalid filter expression%s: %s' %
|
||||
('' if len(invalid_filters) == 1 else 's',
|
||||
|
||||
Reference in New Issue
Block a user