-
Notifications
You must be signed in to change notification settings - Fork 536
Pattern validation for HTTP header values according to RFC 7230 #3774
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
Signed-off-by: Norwin Schnyder <[email protected]>
Hi @snorwin. Thanks for your PR. I'm waiting for a kubernetes-sigs member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. 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. |
3ff6e20
to
722ac23
Compare
apis/v1/httproute_types.go
Outdated
// | ||
// +kubebuilder:validation:MinLength=1 | ||
// +kubebuilder:validation:MaxLength=4096 | ||
// <gateway:experimental:validation:XValidation:message="must only contain printable ASCII characters, optionally separated by single tabs or spaces",rule="self.matches('^[!-~]+([\\t ]?[!-~]+)*$')"> |
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.
While a CEL would offer a cleaner approach with meaningful error messages, the complexity appears to be too high.
Signed-off-by: Norwin Schnyder <[email protected]>
722ac23
to
0a5580a
Compare
/ok-to-test I think that @robscott should check this out as well though. |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: snorwin, youngnick 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 |
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.
Thanks @snorwin! I'm very hesitant to ever tighten validation on a GA API, but as long as we can have complete confidence that all configuration that would fail this validation would have been useless/invalid before this validation, this does seem like a net improvement.
/cc @htuch @mkosieradzki
// | ||
// +kubebuilder:validation:MinLength=1 | ||
// +kubebuilder:validation:MaxLength=4096 | ||
// <gateway:experimental:validation:Pattern=`^[!-~]+([\t ]?[!-~]+)*$`> |
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.
Can you add some invalid and valid examples to https://github.com/kubernetes-sigs/gateway-api/tree/main/hack/invalid-examples/experimental and https://github.com/kubernetes-sigs/gateway-api/tree/main/examples/experimental respectively to confirm this is working as intended?
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.
One note - this is a header value matcher that supports two types of matches - exact and regex. I believe all forms of regex matcher used here would also be contained within US-ASCII characters, but would appreciate another confirmation of that.
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.
That's a valid point. AFAIK, non-printable characters aren't used as meta characters in regex patterns.
@robscott: GitHub didn't allow me to request PR reviews from the following users: htuch, mkosieradzki. Note that only kubernetes-sigs members and repo collaborators can review this PR, and authors cannot review their own PRs. In 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. |
4ff9eda
to
2066f7d
Compare
Signed-off-by: Norwin Schnyder <[email protected]>
2066f7d
to
b7ab3ab
Compare
What type of PR is this?
/kind bug
What this PR does / why we need it:
This PR adds an experimental pattern validation to ensure that HTTP header values consist only of printable US-ASCII characters, optionally separated by spaces or tabs, as required by RFC 7230.
Which issue(s) this PR fixes:
Fixes #3669
Does this PR introduce a user-facing change?: