WAF策略:可以修改分组代号/导入时可以根据名称合并

This commit is contained in:
GoEdgeLab
2021-12-12 20:24:36 +08:00
parent 8096bf3cd5
commit 0646d474a9
5 changed files with 92 additions and 82 deletions

View File

@@ -95,6 +95,7 @@ func (this *HTTPFirewallRuleGroupDAO) ComposeFirewallRuleGroup(tx *dbs.Tx, group
config.Name = group.Name
config.Description = group.Description
config.Code = group.Code
config.IsTemplate = group.IsTemplate == 1
if IsNotNull(group.Sets) {
setRefs := []*firewallconfigs.HTTPFirewallRuleSetRef{}
@@ -125,6 +126,7 @@ func (this *HTTPFirewallRuleGroupDAO) CreateGroupFromConfig(tx *dbs.Tx, groupCon
op.Description = groupConfig.Description
op.State = HTTPFirewallRuleGroupStateEnabled
op.Code = groupConfig.Code
op.IsTemplate = groupConfig.IsTemplate
// sets
setRefs := []*firewallconfigs.HTTPFirewallRuleSetRef{}
@@ -178,7 +180,7 @@ func (this *HTTPFirewallRuleGroupDAO) CreateGroup(tx *dbs.Tx, isOn bool, name st
}
// UpdateGroup 修改分组
func (this *HTTPFirewallRuleGroupDAO) UpdateGroup(tx *dbs.Tx, groupId int64, isOn bool, name string, description string) error {
func (this *HTTPFirewallRuleGroupDAO) UpdateGroup(tx *dbs.Tx, groupId int64, isOn bool, name string, code string, description string) error {
if groupId <= 0 {
return errors.New("invalid groupId")
}
@@ -186,6 +188,7 @@ func (this *HTTPFirewallRuleGroupDAO) UpdateGroup(tx *dbs.Tx, groupId int64, isO
op.Id = groupId
op.IsOn = isOn
op.Name = name
op.Code = code
op.Description = description
err := this.Save(tx, op)
if err != nil {

View File

@@ -1,12 +1,13 @@
package models
// 防火墙规则分组
// HTTPFirewallRuleGroup 防火墙规则分组
type HTTPFirewallRuleGroup struct {
Id uint32 `field:"id"` // ID
IsOn uint8 `field:"isOn"` // 是否启用
Name string `field:"name"` // 名称
Description string `field:"description"` // 描述
Code string `field:"code"` // 代号
IsTemplate uint8 `field:"isTemplate"` // 是否为预置模板
AdminId uint32 `field:"adminId"` // 管理员ID
UserId uint32 `field:"userId"` // 用户ID
State uint8 `field:"state"` // 状态
@@ -20,6 +21,7 @@ type HTTPFirewallRuleGroupOperator struct {
Name interface{} // 名称
Description interface{} // 描述
Code interface{} // 代号
IsTemplate interface{} // 是否为预置模板
AdminId interface{} // 管理员ID
UserId interface{} // 用户ID
State interface{} // 状态