修复WAF策略模式为空导致动作不起作用的问题

This commit is contained in:
GoEdgeLab
2021-10-03 08:35:28 +08:00
parent 1135a03d15
commit a1ff7b09d1
2 changed files with 4 additions and 1 deletions

View File

@@ -57,6 +57,9 @@ func (this *WAFManager) convertWAF(policy *firewallconfigs.HTTPFirewallPolicy) (
if policy == nil {
return nil, errors.New("policy should not be nil")
}
if len(policy.Mode) == 0 {
policy.Mode = firewallconfigs.FirewallModeDefend
}
w := &waf.WAF{
Id: strconv.FormatInt(policy.Id, 10),
IsOn: policy.IsOn,

View File

@@ -118,7 +118,7 @@ func (this *RuleSet) ActionCodes() []string {
}
func (this *RuleSet) PerformActions(waf *WAF, group *RuleGroup, req requests.Request, writer http.ResponseWriter) bool {
if waf.Mode != firewallconfigs.FirewallModeDefend {
if len(waf.Mode) != 0 && waf.Mode != firewallconfigs.FirewallModeDefend {
return true
}