-
Notifications
You must be signed in to change notification settings - Fork 259
OCPBUGS-47773: Add API validation to reject # or whitespace in spec.path #1958
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
Conversation
|
@Thealisyed: This pull request references Jira Issue OCPBUGS-47773, which is invalid:
Comment The bug has been updated to refer to the pull request using the external bug tracker. DetailsIn response to this:
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 openshift-eng/jira-lifecycle-plugin repository. |
|
/test unit |
5400853 to
f269da7
Compare
80f0f67 to
f53aaa9
Compare
|
/jira refresh |
|
@Thealisyed: This pull request references Jira Issue OCPBUGS-47773, which is valid. The bug has been moved to the POST state. 3 validation(s) were run on this bug
Requesting review from QA contact: The bug has been updated to refer to the pull request using the external bug tracker. DetailsIn response to this:
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 openshift-eng/jira-lifecycle-plugin repository. |
|
Please add test cases in |
|
I've addressed all the review comments and added the corresponding test cases in |
|
tested it with 4.19.0-0-2025-05-07-031421-test-ci-ln-0yn4242-latest |
|
/label qe-approved |
| hostnameUpdated := route.Spec.Host != older.Spec.Host | ||
| allErrs = append(allErrs, validateRoute(ctx, route, hostnameUpdated && validLabels(older.Spec.Host), sarc, secrets, opts)...) | ||
| if route.Spec.Path != older.Spec.Path { | ||
| pathFieldPath := field.NewPath("spec", "path") |
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.
nit: Ideally this pathFieldPath would be specified within validatePath instead of passed as a parameter, since it would always be the same value. I can live with it unless you need to make other changes.
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.
The convention is that if validateFoo is validating field foo and uses validateBar to validate sub-field foo.bar, then validateFoo passes the path foo.bar to validateBar. This keeps the validation functions well scoped and reusable. For example, if you also have a validateBaz that needs to validate baz.bar, it can re-use validateBar and just pass the path baz.bar to validateBar.
| func ValidateRoute(ctx context.Context, route *routev1.Route, sarCreator routecommon.SubjectAccessReviewCreator, secretsGetter corev1client.SecretsGetter, opts routecommon.RouteValidationOptions) field.ErrorList { | ||
| return validateRoute(ctx, route, true, sarCreator, secretsGetter, opts) | ||
| allErrs := field.ErrorList{} | ||
| pathFieldPath := field.NewPath("spec", "path") |
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.
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.
Almost there. Looks like you removed too much in the last change. Also, please update your commit message to include the fact that we allow old routes that had the invalid value to be updated without an error.
This commit introduces api validation to reject # or whitespace in the spec.path. This is becaause it causes HaProxy error and the inress to become degraded. The validation will reject any new route that tries to create with whitespace or # in spec.path. It will allow for ratcheting. Test cases are also introduced in the validation_test.go file Related bug: https://issues.redhat.com/browse/OCPBUGS-47773
|
Updated the commit message to be more detailed |
|
Need this ART bump to be merged as there is currently golang and k8s version differences |
For main/master branch, we have one pr openshift/openshift-apiserver#486, openshift/openshift-apiserver#521 is for 4.19 branch. |
| name: "spec.path should not contain whitespace in the spec.path", | ||
| route: routeWithPath("/new path"), | ||
| expectedErrors: 1, | ||
| }, |
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.
Sorry I didn't notice this before, but can you also test input with tabs?
|
/lgtm |
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: candita, Thealisyed 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 |
|
@Thealisyed: all tests passed! Full PR test history. Your PR dashboard. 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. I understand the commands that are listed here. |
|
@Thealisyed: Jira Issue OCPBUGS-47773: All pull requests linked via external trackers have merged: Jira Issue OCPBUGS-47773 has been moved to the MODIFIED state. DetailsIn response to this:
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 openshift-eng/jira-lifecycle-plugin repository. |
|
/cherry-pick release-4.19 |
|
@Thealisyed: new pull request created: #2012 DetailsIn response to this:
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. |
|
/cherry-pick release-4.18 |
|
@Thealisyed: new pull request created: #2083 DetailsIn response to this:
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. |
Api validation was added to library-go in order to reject any router that is created with a '#' or whitespace in the route spec.path # as this causes HaProxy error and the ingress to become degraded