Fix validation of CIDR fields#324
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 DetailsNeeds 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.
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 |
56fa774 to
785ec40
Compare
|
New changes are detected. LGTM label has been removed. |
|
will rebasing help since #329 merged? |
785ec40 to
e6300dc
Compare
|
The Kubernetes project currently lacks enough contributors to adequately respond to all PRs. This bot triages PRs according to the following rules:
You can:
Please send feedback to sig-contributor-experience at kubernetes/community. /lifecycle stale |
isCIDR() accepts both "mask-like" CIDRs and "address-like" CIDRs
|
/retest |
e6300dc to
08624fc
Compare
Something apparently changed in CRD CEL cost validation in the last few releases; the test fails with kind 0.25 / k8s 1.31, but passes with kind 0.31 / k8s 1.35.
32c4e75 to
f4c54cc
Compare
not sure if that helped at all or not, but it seems that something about CEL cost computation changed in the last few releases, and updating the e2e test to test against a newer apiserver fixes things. (Just #329 without the new apiserver does not fix it.) Oh, although that doesn't actually help, because that would mean the new CRDs won't work with older k8s releases. |
|
/hold removing this from the v1alpha2 milestone. we'll have to figure this out later. |
|
The Kubernetes project currently lacks enough contributors to adequately respond to all PRs. This bot triages PRs according to the following rules:
You can:
Please send feedback to sig-contributor-experience at kubernetes/community. /lifecycle stale |
|
PR needs rebase. DetailsInstructions 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. |
|
The Kubernetes project currently lacks enough active contributors to adequately respond to all PRs. This bot triages PRs according to the following rules:
You can:
Please send feedback to sig-contributor-experience at kubernetes/community. /lifecycle rotten |
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.)