Trim spaces from badword items (#7921)
This commit is contained in:
parent
7d17ff35fa
commit
15567b07c0
3 changed files with 23 additions and 1 deletions
|
|
@ -253,7 +253,7 @@ func (n *NGINXController) CheckIngress(ing *networking.Ingress) error {
|
|||
}
|
||||
if strings.HasPrefix(key, fmt.Sprintf("%s/", parser.AnnotationsPrefix)) {
|
||||
for _, forbiddenvalue := range arraybadWords {
|
||||
if strings.Contains(value, forbiddenvalue) {
|
||||
if strings.Contains(value, strings.TrimSpace(forbiddenvalue)) {
|
||||
return fmt.Errorf("%s annotation contains invalid word %s", key, forbiddenvalue)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -284,6 +284,10 @@ func TestCheckIngress(t *testing.T) {
|
|||
if err := nginx.CheckIngress(ing); err == nil {
|
||||
t.Errorf("with an invalid value in annotation the ingress should be rejected")
|
||||
}
|
||||
ing.ObjectMeta.Annotations["nginx.ingress.kubernetes.io/custom-headers"] = "another_directive"
|
||||
if err := nginx.CheckIngress(ing); err == nil {
|
||||
t.Errorf("with an invalid value in annotation the ingress should be rejected")
|
||||
}
|
||||
})
|
||||
|
||||
t.Run("When a new catch-all ingress is being created despite catch-alls being disabled ", func(t *testing.T) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue