WAF模板中增加空Agent和随机字符拦截规则

This commit is contained in:
刘祥超
2021-10-25 11:57:25 +08:00
parent 3a30a65264
commit f5c3affc5f
4 changed files with 255 additions and 61 deletions

View File

@@ -1,6 +1,6 @@
package firewallconfigs
// 规则组
// HTTPFirewallRuleGroup 规则组
type HTTPFirewallRuleGroup struct {
Id int64 `yaml:"id" json:"id"`
IsOn bool `yaml:"isOn" json:"isOn"`
@@ -11,7 +11,7 @@ type HTTPFirewallRuleGroup struct {
Sets []*HTTPFirewallRuleSet `yaml:"sets" json:"sets"`
}
// 初始化
// Init 初始化
func (this *HTTPFirewallRuleGroup) Init() error {
for _, set := range this.Sets {
err := set.Init()
@@ -22,12 +22,12 @@ func (this *HTTPFirewallRuleGroup) Init() error {
return nil
}
// 添加规则集
// AddRuleSet 添加规则集
func (this *HTTPFirewallRuleGroup) AddRuleSet(ruleSet *HTTPFirewallRuleSet) {
this.Sets = append(this.Sets, ruleSet)
}
// 根据ID查找规则集
// FindRuleSet 根据ID查找规则集
func (this *HTTPFirewallRuleGroup) FindRuleSet(ruleSetId int64) *HTTPFirewallRuleSet {
for _, set := range this.Sets {
if set.Id == ruleSetId {
@@ -36,3 +36,13 @@ func (this *HTTPFirewallRuleGroup) FindRuleSet(ruleSetId int64) *HTTPFirewallRul
}
return nil
}
// FindRuleSetWithCode 根据Code查找规则集
func (this *HTTPFirewallRuleGroup) FindRuleSetWithCode(code string) *HTTPFirewallRuleSet {
for _, set := range this.Sets {
if set.Code == code {
return set
}
}
return nil
}