Validate ingress path fields (#9309)
* Validate characters in path fields * Add e2e tests for path validation * Fix review comments
This commit is contained in:
parent
b6c6305523
commit
c1413e6079
4 changed files with 249 additions and 0 deletions
|
|
@ -59,6 +59,7 @@ import (
|
|||
"k8s.io/ingress-nginx/internal/ingress/resolver"
|
||||
"k8s.io/ingress-nginx/internal/k8s"
|
||||
"k8s.io/ingress-nginx/pkg/apis/ingress"
|
||||
ingressutils "k8s.io/ingress-nginx/pkg/util/ingress"
|
||||
)
|
||||
|
||||
// IngressFilterFunc decides if an Ingress should be omitted or not
|
||||
|
|
@ -861,6 +862,10 @@ func (s *k8sStore) syncIngress(ing *networkingv1.Ingress) {
|
|||
if path.Path == "" {
|
||||
copyIng.Spec.Rules[ri].HTTP.Paths[pi].Path = "/"
|
||||
}
|
||||
if !ingressutils.IsSafePath(copyIng, path.Path) {
|
||||
klog.Warningf("ingress %s contains invalid path %s", key, path.Path)
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue