Skip to content

Instantly share code, notes, and snippets.

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.
# Any addresses not in this list will be flagged.
whitelist = []
for secgrp in skew.scan('arn:aws:ec2:*:*:security-group/*'):
for ipperms in['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