-
Notifications
You must be signed in to change notification settings - Fork 39
Fix validation of CIDR fields #324
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
base: main
Are you sure you want to change the base?
Conversation
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: danwinship The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
✅ Deploy Preview for kubernetes-sigs-network-policy-api ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
uh...
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR enhances CIDR validation in Kubernetes Custom Resource Definitions to ensure only "mask-like" CIDRs (e.g., "192.168.0.0/24") are accepted, rejecting "address-like" CIDRs (e.g., "192.168.0.5/24").
- Updated validation rules from
isCIDR(self)
toisCIDR(self) && cidr(self) == cidr(self).masked()
- Applied changes consistently across both standard and experimental CRD files
- Modified Go type definitions to reflect the stricter validation requirements
Reviewed Changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated no comments.
Show a summary per file
File | Description |
---|---|
config/crd/standard/policy.networking.k8s.io_clusternetworkpolicies.yaml | Updated CIDR validation rule to enforce mask-like format |
config/crd/standard/policy.networking.k8s.io_baselineadminnetworkpolicies.yaml | Updated CIDR validation rule to enforce mask-like format |
config/crd/standard/policy.networking.k8s.io_adminnetworkpolicies.yaml | Updated CIDR validation rule to enforce mask-like format |
config/crd/experimental/policy.networking.k8s.io_clusternetworkpolicies.yaml | Updated CIDR validation rule to enforce mask-like format |
config/crd/experimental/policy.networking.k8s.io_baselineadminnetworkpolicies.yaml | Updated CIDR validation rule to enforce mask-like format |
config/crd/experimental/policy.networking.k8s.io_adminnetworkpolicies.yaml | Updated CIDR validation rule to enforce mask-like format |
apis/v1alpha2/clusternetworkpolicy_types.go | Updated CIDR type validation annotation to enforce mask-like format |
apis/v1alpha1/shared_types.go | Updated CIDR type validation annotation to enforce mask-like format |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
this suggests something is unbounded OR if everything is bounded then yea I remember hitting this error before and I had to play around with the maximum numbers to make it reasonable. so see if 20 cidr's or 15 fixes this? I remember I chose 25 cidrs cause back then as well cost exceeded for higher numbers.. :) |
@jpbetz @cici37 any best practices or guidelines we can follow here? |
/lgtm |
isCIDR() accepts both "mask-like" CIDRs and "address-like" CIDRs
56fa774
to
785ec40
Compare
New changes are detected. LGTM label has been removed. |
@danwinship: The following test failed, say
Full PR test history. Your PR dashboard. Please help us cut down on flakes by linking to an open issue when you hit one in your PR. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here. |
will rebasing help since #329 merged? |
re kubernetes/kubernetes#134224;
isCIDR()
allows both "mask-like" CIDRs ("192.168.0.0/24") and "address-like" CIDRs ("192.168.0.5/24"). We only want the former.(If
isCIDR()
gets changed, then the extra clause here will just be a no-op, but we'll have better backward-compatibility this way.)