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 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
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:Pattern=`^[!-~]+([\t ]?[!-~]+)*$`>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

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.

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:Pattern=`^[!-~]+([\t ]?[!-~]+)*$`>
Value string `json:"value"`
}

Expand Down
64 changes: 48 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