Skip to content
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

Add net.cidr_merge function to produce smallest possible list of subnets #2692

Closed
tsandall opened this issue Sep 11, 2020 · 0 comments · Fixed by #2713
Closed

Add net.cidr_merge function to produce smallest possible list of subnets #2692

tsandall opened this issue Sep 11, 2020 · 0 comments · Fixed by #2713

Comments

@tsandall
Copy link
Member

tsandall commented Sep 11, 2020

Rego has a set of built-in functions for operating on IP addresses and CIDRs. One operation that's missing is merging of IPs and subnets into the smallest possible set. This operation is useful when operating on large numbers of IP/CIDR values (e.g., in the context of firewall rules). An example implementation of this operation can be found in the netaddr Python module.

It should be easy enough to implement this function natively without relying on a thirdparty library.

@tsandall tsandall added this to TODO (Things That Should Be Done) in Open Policy Agent via automation Sep 11, 2020
@tsandall tsandall moved this from TODO (Things That Should Be Done) to Planned (Things We Are Going To Do) in Open Policy Agent Sep 11, 2020
@ashutosh-narkar ashutosh-narkar moved this from Planned (Things We Are Going To Do) to In Progress in Open Policy Agent Sep 21, 2020
@ashutosh-narkar ashutosh-narkar self-assigned this Sep 21, 2020
ashutosh-narkar added a commit to ashutosh-narkar/opa that referenced this issue Sep 25, 2020
…t of CIDRs

This commit adds a new builtin to merge adjacent subnets and return the
smallest possible list of CIDRs.

To help with computing CIDR blocks between two
IP networks, an implemetation from https://github.com/cilium/cilium
is leveraged.

Fixes: open-policy-agent#2692

Signed-off-by: Ashutosh Narkar <anarkar4387@gmail.com>
Open Policy Agent automation moved this from In Progress to Done Sep 25, 2020
ashutosh-narkar added a commit that referenced this issue Sep 25, 2020
…t of CIDRs

This commit adds a new builtin to merge adjacent subnets and return the
smallest possible list of CIDRs.

To help with computing CIDR blocks between two
IP networks, an implemetation from https://github.com/cilium/cilium
is leveraged.

Fixes: #2692

Signed-off-by: Ashutosh Narkar <anarkar4387@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Development

Successfully merging a pull request may close this issue.

2 participants