update default block list,docs, tests (#7942)
* update default block list,docs, tests * fix config for admin test * gofmt * remove the err return
This commit is contained in:
parent
e57d2f63fa
commit
d4a6ade65f
7 changed files with 69 additions and 63 deletions
|
|
@ -242,7 +242,12 @@ 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), ",")
|
||||
klog.Warningf("Blocklist is %s", cfg.AnnotationValueWordBlocklist)
|
||||
}
|
||||
|
||||
for key, value := range ing.ObjectMeta.GetAnnotations() {
|
||||
|
||||
|
|
@ -251,9 +256,11 @@ 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)) {
|
||||
klog.Errorf("%s annotation contains invalid word %s", key, forbiddenvalue)
|
||||
return fmt.Errorf("%s annotation contains invalid word %s", key, forbiddenvalue)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue