Created
February 2, 2017 21:26
-
-
Save lukedemi/cb79c396596998b604d13384a453b4bc to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def validate_statement_ip_restrictions(statement) | |
errors = [] | |
if statement.ip_restrictions.empty? | |
errors << "IPAddress Condition aws:SourceIP must contain cidr blocks" | |
else | |
for cidr_block in statement.ip_restrictions | |
if !valid_cidr?(cidr_block) | |
errors << "#{cidr_block} is not included in the valid_cidr array for this environment" | |
end | |
end | |
end | |
errors | |
end | |
def valid_cidr?(cidr_block) | |
return true if env.valid_cidr_blocks.flatten.include?(cidr_block) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment