-
Notifications
You must be signed in to change notification settings - Fork 183
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[BUG] CIDR Netmasks are strings, not netmasks #182
Comments
Hello @pacohope! Sorry for the very late reply. A lot has changed since 2021 so I figured I'd drop in with a suggestion to remedy this using regex:
When checking locally and applying your suggested reproduce steps I am able to have the test fail as expected. Please let me know if this is a viable solution for you. Thanks! |
This pattern match will accurately pluck off the netmask part of a CIDR range, so it won't be fooled by My point was that CIDR ranges and netmasks are numbers, not strings. So string matching doesn't get it done because string matching doesn't do math. |
Describe the bug
In the example security ingress/egress rules, the only CIDR range that will flag as "open to the world" is the exact string of
0.0.0.0/0
. For example,1.0.0.0/0
is also open to the world, but if I process my template where that's the ingress CIDR, I see:To Reproduce
I am pretty sure if you change the ingress test case to
1.0.0.0/0
it will pass the test when it should fail. EC2/VPC are perfectly happy to accept that as a CIDR, because it is valid syntactically. They will create an ingress CIDR range that, when you dodescribe-security-groups
will show as0.0.0.0/0
.The same is probably true for IPv6 CIDR ranges (I haven't tested) because it looks like string matching on
::0
.Expected behavior
If we must treat IPv4 CIDRs as strings, can we just match strings that end with
/0
? That would be be a wee bit more robust.Ideally we should parse CIDRs as data structures, extract the netmask as an integer, and complain on small numbers like
8
or less.The text was updated successfully, but these errors were encountered: