add path validation to implementation specific as well (#9573)
Signed-off-by: James Strong <strong.james.e@gmail.com>
This commit is contained in:
parent
8296f571c3
commit
0cabaddca0
2 changed files with 7 additions and 5 deletions
|
@ -282,9 +282,11 @@ func checkPath(paths []networkingv1.HTTPIngressPath, enablePathTypeValidation bo
|
||||||
|
|
||||||
switch pathType := *path.PathType; pathType {
|
switch pathType := *path.PathType; pathType {
|
||||||
case networkingv1.PathTypeImplementationSpecific:
|
case networkingv1.PathTypeImplementationSpecific:
|
||||||
//only match on regex chars per Ingress spec when path is implementation specific
|
if enablePathTypeValidation {
|
||||||
if !regexSpecificChars.MatchString(path.Path) {
|
//only match on regex chars per Ingress spec when path is implementation specific
|
||||||
return fmt.Errorf("path %s of type %s contains invalid characters", path.Path, *path.PathType)
|
if !regexSpecificChars.MatchString(path.Path) {
|
||||||
|
return fmt.Errorf("path %s of type %s contains invalid characters", path.Path, *path.PathType)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
case networkingv1.PathTypeExact, networkingv1.PathTypePrefix:
|
case networkingv1.PathTypeExact, networkingv1.PathTypePrefix:
|
||||||
|
|
|
@ -272,7 +272,7 @@ func TestValidateIngressPath(t *testing.T) {
|
||||||
name: "should reject path when the allowed additional set does not match",
|
name: "should reject path when the allowed additional set does not match",
|
||||||
wantErr: true,
|
wantErr: true,
|
||||||
additionalChars: "().?",
|
additionalChars: "().?",
|
||||||
EnablePathTypeValidation: false,
|
EnablePathTypeValidation: true,
|
||||||
copyIng: generateDumbIngressforPathTest(&pathTypeImplSpecific, "/foo/bar/(.+)"),
|
copyIng: generateDumbIngressforPathTest(&pathTypeImplSpecific, "/foo/bar/(.+)"),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -291,7 +291,7 @@ func TestValidateIngressPath(t *testing.T) {
|
||||||
{
|
{
|
||||||
name: "should block if at least one path is bad",
|
name: "should block if at least one path is bad",
|
||||||
wantErr: true,
|
wantErr: true,
|
||||||
EnablePathTypeValidation: false,
|
EnablePathTypeValidation: true,
|
||||||
copyIng: generateComplexIngress(generateDumbIngressforPathTest(&pathTypeImplSpecific, "/foo/bar/(.?)")),
|
copyIng: generateComplexIngress(generateDumbIngressforPathTest(&pathTypeImplSpecific, "/foo/bar/(.?)")),
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue