优化WAF动作排序

This commit is contained in:
GoEdgeLab
2021-10-06 09:39:57 +08:00
parent e82171afc8
commit 6f10aa94c5

View File

@@ -76,6 +76,18 @@ func (this *RuleSet) Init(waf *WAF) error {
}
}
// sort actions
sort.Slice(this.actionInstances, func(i, j int) bool {
var instance1 = this.actionInstances[i]
if !instance1.WillChange() {
return true
}
if instance1.Code() == ActionRecordIP {
return true
}
return false
})
return nil
}
@@ -123,18 +135,6 @@ func (this *RuleSet) PerformActions(waf *WAF, group *RuleGroup, req requests.Req
return true
}
// 排序
sort.Slice(this.actionInstances, func(i, j int) bool {
var instance1 = this.actionInstances[i]
if !instance1.WillChange() {
return true
}
if instance1.Code() == ActionRecordIP {
return true
}
return false
})
// 先执行allow
for _, instance := range this.actionInstances {
if !instance.WillChange() {