Skip to content

Commit 6c41f19

Browse files
authored
add path validation to implementation specific as well (#9573)
Signed-off-by: James Strong <[email protected]>
1 parent 254b814 commit 6c41f19

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

pkg/util/ingress/ingress.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -282,9 +282,11 @@ func checkPath(paths []networkingv1.HTTPIngressPath, enablePathTypeValidation bo
282282

283283
switch pathType := *path.PathType; pathType {
284284
case networkingv1.PathTypeImplementationSpecific:
285-
//only match on regex chars per Ingress spec when path is implementation specific
286-
if !regexSpecificChars.MatchString(path.Path) {
287-
return fmt.Errorf("path %s of type %s contains invalid characters", path.Path, *path.PathType)
285+
if enablePathTypeValidation {
286+
//only match on regex chars per Ingress spec when path is implementation specific
287+
if !regexSpecificChars.MatchString(path.Path) {
288+
return fmt.Errorf("path %s of type %s contains invalid characters", path.Path, *path.PathType)
289+
}
288290
}
289291

290292
case networkingv1.PathTypeExact, networkingv1.PathTypePrefix:

pkg/util/ingress/ingress_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,7 @@ func TestValidateIngressPath(t *testing.T) {
272272
name: "should reject path when the allowed additional set does not match",
273273
wantErr: true,
274274
additionalChars: "().?",
275-
EnablePathTypeValidation: false,
275+
EnablePathTypeValidation: true,
276276
copyIng: generateDumbIngressforPathTest(&pathTypeImplSpecific, "/foo/bar/(.+)"),
277277
},
278278
{
@@ -291,7 +291,7 @@ func TestValidateIngressPath(t *testing.T) {
291291
{
292292
name: "should block if at least one path is bad",
293293
wantErr: true,
294-
EnablePathTypeValidation: false,
294+
EnablePathTypeValidation: true,
295295
copyIng: generateComplexIngress(generateDumbIngressforPathTest(&pathTypeImplSpecific, "/foo/bar/(.?)")),
296296
},
297297
}

0 commit comments

Comments
 (0)