github.com/TeaOSLab/EdgeNode@v1.3.8/internal/waf/action_go_set.go (about) 1 package waf 2 3 import ( 4 "github.com/TeaOSLab/EdgeNode/internal/remotelogs" 5 "github.com/TeaOSLab/EdgeNode/internal/waf/requests" 6 "github.com/iwind/TeaGo/types" 7 "net/http" 8 ) 9 10 type GoSetAction struct { 11 BaseAction 12 13 GroupId string `yaml:"groupId" json:"groupId"` 14 SetId string `yaml:"setId" json:"setId"` 15 } 16 17 func (this *GoSetAction) Init(waf *WAF) error { 18 return nil 19 } 20 21 func (this *GoSetAction) Code() string { 22 return ActionGoSet 23 } 24 25 func (this *GoSetAction) IsAttack() bool { 26 return false 27 } 28 29 func (this *GoSetAction) WillChange() bool { 30 return true 31 } 32 33 func (this *GoSetAction) Perform(waf *WAF, group *RuleGroup, set *RuleSet, request requests.Request, writer http.ResponseWriter) PerformResult { 34 var nextGroup = waf.FindRuleGroup(types.Int64(this.GroupId)) 35 if nextGroup == nil || !nextGroup.IsOn { 36 return PerformResult{ 37 ContinueRequest: true, 38 GoNextSet: true, 39 } 40 } 41 var nextSet = nextGroup.FindRuleSet(types.Int64(this.SetId)) 42 if nextSet == nil || !nextSet.IsOn { 43 return PerformResult{ 44 ContinueRequest: true, 45 GoNextSet: true, 46 } 47 } 48 49 b, _, err := nextSet.MatchRequest(request) 50 if err != nil { 51 remotelogs.Error("WAF", "GO_GROUP_ACTION: "+err.Error()) 52 return PerformResult{ 53 ContinueRequest: true, 54 GoNextSet: true, 55 } 56 } 57 if !b { 58 return PerformResult{ 59 ContinueRequest: true, 60 GoNextSet: true, 61 } 62 } 63 return nextSet.PerformActions(waf, nextGroup, request, writer) 64 }