how to compare ip address(ipv4 and ipv6) in rego ? #459
Replies: 5 comments 4 replies
-
Hi there! There's a bunch of built-in functions for dealing with IP addresses included in Rego: https://www.openpolicyagent.org/docs/latest/policy-reference/#net I'm not sure about "greater than" comparison though, as I don't think a use case for that has been presented before. Could you help me understand when that is useful? |
Beta Was this translation helpful? Give feedback.
-
Hi , |
Beta Was this translation helpful? Give feedback.
-
when i try to do this : package ip_validation import strconv ipv4_valid(address) { ipv6_valid(address) { valid_range(begin, end) { input_validation { compare_ipv4(begin, end) { ip_to_number(ip) = n { ipv4_pattern = |
Beta Was this translation helpful? Give feedback.
-
Seeing this error : 1 error occurred: policy.rego:4: rego_parse_error: unexpected import path, must begin with one of: {data, future, input}, got: strconv |
Beta Was this translation helpful? Give feedback.
-
package ip_validation default input_validation = false valid_range(begin, end) { input_validation { compare_ipv4(begin, end) { ip_to_number(ip) = n { |
Beta Was this translation helpful? Give feedback.
-
how to compare ip address(ipv4 and ipv6) in rego ?
string comparsion is not working.
valid_range {
"192.1.2.27" > "192.1.2.220"
}
this results in TRUE.
Is there any built-in function for comparing ip-address.
I dnot want to convert ip into integer and then compare.
Beta Was this translation helpful? Give feedback.
All reactions