test ip_ranges when authorizing security group ingress rules
This commit is contained in:
parent
b82507e41b
commit
b9f747fb4f
4 changed files with 33 additions and 4 deletions
|
|
@ -362,7 +362,6 @@ def get_prefix(resource_id):
|
|||
if after.startswith('attach'):
|
||||
resource_id_prefix = EC2_RESOURCE_TO_PREFIX['network-interface-attachment']
|
||||
if not resource_id_prefix in EC2_RESOURCE_TO_PREFIX.values():
|
||||
import re
|
||||
uuid4hex = re.compile('[0-9a-f]{12}4[0-9a-f]{3}[89ab][0-9a-f]{15}\Z', re.I)
|
||||
if uuid4hex.match(resource_id) is not None:
|
||||
resource_id_prefix = EC2_RESOURCE_TO_PREFIX['reserved-instance']
|
||||
|
|
@ -372,7 +371,6 @@ def get_prefix(resource_id):
|
|||
|
||||
|
||||
def is_valid_resource_id(resource_id):
|
||||
import re
|
||||
valid_prefixes = EC2_RESOURCE_TO_PREFIX.values()
|
||||
resource_id_prefix = get_prefix(resource_id)
|
||||
if not resource_id_prefix in valid_prefixes:
|
||||
|
|
@ -380,3 +378,9 @@ def is_valid_resource_id(resource_id):
|
|||
resource_id_pattern = resource_id_prefix + '-[0-9a-f]{8}'
|
||||
resource_pattern_re = re.compile(resource_id_pattern)
|
||||
return resource_pattern_re.match(resource_id) is not None
|
||||
|
||||
|
||||
def is_valid_cidr(cird):
|
||||
cidr_pattern = '^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])(\/(\d|[1-2]\d|3[0-2]))$'
|
||||
cidr_pattern_re = re.compile(cidr_pattern)
|
||||
return cidr_pattern_re.match(cird) is not None
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue