Browse Source

return an error if a custom rule has both and and or

Sebastien Blot 1 year ago
parent
commit
2a920124fe
1 changed files with 4 additions and 0 deletions
  1. 4 0
      pkg/waf/waap_rule/modsecurity.go

+ 4 - 0
pkg/waf/waap_rule/modsecurity.go

@@ -82,6 +82,10 @@ func (m *ModsecurityRule) generateRuleID(rule *CustomRule, waapRuleName string,
 func (m *ModsecurityRule) buildRules(rule *CustomRule, waapRuleName string, and bool, toSkip int, depth int) ([]string, error) {
 	ret := make([]string, 0)
 
+	if len(rule.And) != 0 && len(rule.Or) != 0 {
+		return nil, fmt.Errorf("cannot have both 'and' and 'or' in the same rule")
+	}
+
 	if rule.And != nil {
 		for c, andRule := range rule.And {
 			depth++