Hi there, i'm trying to expand on the classic "
0.0.0.0/0" security group removal, and was hoping I could do this with regex. It doesn't appear to work, but i'm also fairly new to this and struggling with syntax. Any help would be appreciated.
vars:
tag-actions: &tag-actions
- type: tag
key: ToDelete
value: "Yes"
policies:
- name: high-risk-security-groups-remediate
resource: security-group
description: |
Remove any rule from a security group that allows
0.0.0.0/0 or any other CIDR block in the 0-12 range, excluding
10.0.0.0/8 mode:
role: arn:aws:iam::XXXXXXXXXXXXX:role/XXX-XXXXXXXXXXXXX
type: cloudtrail
events:
event: AuthorizeSecurityGroupIngress
ids: "requestParameters.groupId"
event: AuthorizeSecurityGroupEgress
ids: "requestParameters.groupId"
event: RevokeSecurityGroupEgress
ids: "requestParameters.groupId"
event: RevokeSecurityGroupIngress
ids: "requestParameters.groupId"
filters:
- type: ingress
key: cidr
op: regex
value: "^(?!.*10.0.0.0\/8)([0-9]{1,3}\.){3}[0-9]{1,3}(\/([0-9]|[1][0]|[1][1]|[1][2]))?$"
actions:
*tag-actions
# - type: remove-permissions
# ingress: matched