2020-10-08 15:06:42 +08:00
|
|
|
package waf
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"github.com/TeaOSLab/EdgeNode/internal/waf/requests"
|
|
|
|
|
"github.com/iwind/TeaGo/logs"
|
|
|
|
|
"net/http"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
type GoGroupAction struct {
|
|
|
|
|
GroupId string `yaml:"groupId" json:"groupId"`
|
|
|
|
|
}
|
|
|
|
|
|
2021-07-18 15:51:49 +08:00
|
|
|
func (this *GoGroupAction) Init(waf *WAF) error {
|
|
|
|
|
return nil
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (this *GoGroupAction) Code() string {
|
|
|
|
|
return ActionGoGroup
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (this *GoGroupAction) IsAttack() bool {
|
|
|
|
|
return false
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (this *GoGroupAction) WillChange() bool {
|
|
|
|
|
return true
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (this *GoGroupAction) Perform(waf *WAF, group *RuleGroup, set *RuleSet, request requests.Request, writer http.ResponseWriter) (allow bool) {
|
|
|
|
|
nextGroup := waf.FindRuleGroup(this.GroupId)
|
|
|
|
|
if nextGroup == nil || !nextGroup.IsOn {
|
2020-10-08 15:06:42 +08:00
|
|
|
return true
|
|
|
|
|
}
|
|
|
|
|
|
2021-07-18 15:51:49 +08:00
|
|
|
b, nextSet, err := nextGroup.MatchRequest(request)
|
2020-10-08 15:06:42 +08:00
|
|
|
if err != nil {
|
|
|
|
|
logs.Error(err)
|
|
|
|
|
return true
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if !b {
|
|
|
|
|
return true
|
|
|
|
|
}
|
|
|
|
|
|
2021-07-18 15:51:49 +08:00
|
|
|
return nextSet.PerformActions(waf, nextGroup, request, writer)
|
2020-10-08 15:06:42 +08:00
|
|
|
}
|