github.com/TeaOSLab/EdgeNode@v1.3.8/internal/waf/action_allow.go (about)

     1  package waf
     2  
     3  import (
     4  	"github.com/TeaOSLab/EdgeNode/internal/waf/requests"
     5  	"net/http"
     6  )
     7  
     8  type AllowScope = string
     9  
    10  const (
    11  	AllowScopeGroup  AllowScope = "group"
    12  	AllowScopeServer AllowScope = "server"
    13  	AllowScopeGlobal AllowScope = "global"
    14  )
    15  
    16  type AllowAction struct {
    17  	BaseAction
    18  
    19  	Scope AllowScope `yaml:"scope" json:"scope"`
    20  }
    21  
    22  func (this *AllowAction) Init(waf *WAF) error {
    23  	return nil
    24  }
    25  
    26  func (this *AllowAction) Code() string {
    27  	return ActionAllow
    28  }
    29  
    30  func (this *AllowAction) IsAttack() bool {
    31  	return false
    32  }
    33  
    34  func (this *AllowAction) WillChange() bool {
    35  	return true
    36  }
    37  
    38  func (this *AllowAction) Perform(waf *WAF, group *RuleGroup, set *RuleSet, request requests.Request, writer http.ResponseWriter) PerformResult {
    39  	// do nothing
    40  	return PerformResult{
    41  		ContinueRequest: true,
    42  		GoNextGroup:     this.Scope == AllowScopeGroup,
    43  		IsAllowed:       true,
    44  		AllowScope:      this.Scope,
    45  	}
    46  }