Skip to content

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

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions apis/v1/httproute_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -612,9 +612,14 @@ type HTTPHeaderMatch struct {
Name HTTPHeaderName `json:"name"`

// Value is the value of HTTP Header to be matched.
// <gateway:experimental:description>
// Must consist of printable US-ASCII characters, optionally separated
// by single tabs or spaces. See: https://tools.ietf.org/html/rfc7230#section-3.2
// </gateway:experimental:description>
//
// +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 ]?[!-~]+)*$')">
Copy link
Member Author

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.

Value string `json:"value"`
}

Expand Down Expand Up @@ -981,9 +986,14 @@ type HTTPHeader struct {
Name HTTPHeaderName `json:"name"`

// Value is the value of HTTP Header to be matched.
// <gateway:experimental:description>
// Must consist of printable US-ASCII characters, optionally separated
// by single tabs or spaces. See: https://tools.ietf.org/html/rfc7230#section-3.2
// </gateway:experimental:description>
//
// +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 ]?[!-~]+)*$')">
Value string `json:"value"`
}

Expand Down
96 changes: 80 additions & 16 deletions config/crd/experimental/gateway.networking.k8s.io_grpcroutes.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading