Legacy cherrypick (#7965)
* update default block list,docs, tests (#7942) * update default block list,docs, tests * fix config for admin test * gofmt * remove the err return * Change sanitization message from error to warning (#7963) Signed-off-by: Ricardo Pchevuzinske Katz <ricardo.katz@gmail.com> * duplicate test Co-authored-by: Ricardo Katz <rikatz@users.noreply.github.com>
This commit is contained in:
parent
b159577c23
commit
18e6eb0a31
7 changed files with 89 additions and 74 deletions
|
|
@ -238,7 +238,11 @@ func (n *NGINXController) CheckIngress(ing *networking.Ingress) error {
|
|||
cfg := n.store.GetBackendConfiguration()
|
||||
cfg.Resolver = n.resolver
|
||||
|
||||
arraybadWords := strings.Split(strings.TrimSpace(cfg.AnnotationValueWordBlocklist), ",")
|
||||
var arrayBadWords []string
|
||||
|
||||
if cfg.AnnotationValueWordBlocklist != "" {
|
||||
arrayBadWords = strings.Split(strings.TrimSpace(cfg.AnnotationValueWordBlocklist), ",")
|
||||
}
|
||||
|
||||
for key, value := range ing.ObjectMeta.GetAnnotations() {
|
||||
|
||||
|
|
@ -247,8 +251,9 @@ func (n *NGINXController) CheckIngress(ing *networking.Ingress) error {
|
|||
return fmt.Errorf("This deployment has a custom annotation prefix defined. Use '%s' instead of '%s'", parser.AnnotationsPrefix, parser.DefaultAnnotationsPrefix)
|
||||
}
|
||||
}
|
||||
if strings.HasPrefix(key, fmt.Sprintf("%s/", parser.AnnotationsPrefix)) {
|
||||
for _, forbiddenvalue := range arraybadWords {
|
||||
|
||||
if strings.HasPrefix(key, fmt.Sprintf("%s/", parser.AnnotationsPrefix)) && len(arrayBadWords) != 0 {
|
||||
for _, forbiddenvalue := range arrayBadWords {
|
||||
if strings.Contains(value, strings.TrimSpace(forbiddenvalue)) {
|
||||
return fmt.Errorf("%s annotation contains invalid word %s", key, forbiddenvalue)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue