Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
A skew script to audit all security groups for non-whitelisted IP addresses
import skew
# Add whitelisted CIDR blocks here, e.g. 192.168.1.1/32.
# Any addresses not in this list will be flagged.
whitelist = []
for secgrp in skew.scan('arn:aws:ec2:*:*:security-group/*'):
for ipperms in secgrp.data['IpPermissions']:
for ip in ipperms['IpRanges']:
if ip['CidrIp'] not in whitelist:
print('%s: %s is not whitelisted' % (sg.arn, ip['CidrIp']))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment