Skip to content

Commit 4b08b59

Browse files
authored
Pattern validation for HTTP header values according to RFC 7230 (#3774)
* CEL for HTTP header values Signed-off-by: Norwin Schnyder <norwin.schnyder+github@gmail.com> * Use a pattern instead of a CEL to validate HTTP header values Signed-off-by: Norwin Schnyder <norwin.schnyder+github@gmail.com> * Add examples with valid and invalid header values Signed-off-by: Norwin Schnyder <norwin.schnyder+github@gmail.com> --------- Signed-off-by: Norwin Schnyder <norwin.schnyder+github@gmail.com>
1 parent 94655a1 commit 4b08b59

File tree

7 files changed

+194
-54
lines changed

7 files changed

+194
-54
lines changed

apis/v1/httproute_types.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -621,10 +621,15 @@ type HTTPHeaderMatch struct {
621621
Name HTTPHeaderName `json:"name"`
622622

623623
// Value is the value of HTTP Header to be matched.
624+
// <gateway:experimental:description>
625+
// Must consist of printable US-ASCII characters, optionally separated
626+
// by single tabs or spaces. See: https://tools.ietf.org/html/rfc7230#section-3.2
627+
// </gateway:experimental:description>
624628
//
625629
// +kubebuilder:validation:MinLength=1
626630
// +kubebuilder:validation:MaxLength=4096
627631
// +required
632+
// <gateway:experimental:validation:Pattern=`^[!-~]+([\t ]?[!-~]+)*$`>
628633
Value string `json:"value"`
629634
}
630635

@@ -1022,10 +1027,15 @@ type HTTPHeader struct {
10221027
Name HTTPHeaderName `json:"name"`
10231028

10241029
// Value is the value of HTTP Header to be matched.
1030+
// <gateway:experimental:description>
1031+
// Must consist of printable US-ASCII characters, optionally separated
1032+
// by single tabs or spaces. See: https://tools.ietf.org/html/rfc7230#section-3.2
1033+
// </gateway:experimental:description>
10251034
//
10261035
// +kubebuilder:validation:MinLength=1
10271036
// +kubebuilder:validation:MaxLength=4096
10281037
// +required
1038+
// <gateway:experimental:validation:Pattern=`^[!-~]+([\t ]?[!-~]+)*$`>
10291039
Value string `json:"value"`
10301040
}
10311041

config/crd/experimental/gateway.networking.k8s.io_grpcroutes.yaml

Lines changed: 48 additions & 16 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)