mirror of
https://github.com/TeaOSLab/EdgeAPI.git
synced 2025-12-02 06:20:24 +08:00
WAF策略增加观察模式和通过模式
This commit is contained in:
@@ -229,7 +229,7 @@ func (this *HTTPFirewallPolicyDAO) UpdateFirewallPolicyInbound(tx *dbs.Tx, polic
|
|||||||
}
|
}
|
||||||
|
|
||||||
// UpdateFirewallPolicy 修改策略
|
// UpdateFirewallPolicy 修改策略
|
||||||
func (this *HTTPFirewallPolicyDAO) UpdateFirewallPolicy(tx *dbs.Tx, policyId int64, isOn bool, name string, description string, inboundJSON []byte, outboundJSON []byte, blockOptionsJSON []byte) error {
|
func (this *HTTPFirewallPolicyDAO) UpdateFirewallPolicy(tx *dbs.Tx, policyId int64, isOn bool, name string, description string, inboundJSON []byte, outboundJSON []byte, blockOptionsJSON []byte, mode firewallconfigs.FirewallMode) error {
|
||||||
if policyId <= 0 {
|
if policyId <= 0 {
|
||||||
return errors.New("invalid policyId")
|
return errors.New("invalid policyId")
|
||||||
}
|
}
|
||||||
@@ -238,6 +238,7 @@ func (this *HTTPFirewallPolicyDAO) UpdateFirewallPolicy(tx *dbs.Tx, policyId int
|
|||||||
op.IsOn = isOn
|
op.IsOn = isOn
|
||||||
op.Name = name
|
op.Name = name
|
||||||
op.Description = description
|
op.Description = description
|
||||||
|
op.Mode = mode
|
||||||
if len(inboundJSON) > 0 {
|
if len(inboundJSON) > 0 {
|
||||||
op.Inbound = inboundJSON
|
op.Inbound = inboundJSON
|
||||||
} else {
|
} else {
|
||||||
@@ -316,6 +317,7 @@ func (this *HTTPFirewallPolicyDAO) ComposeFirewallPolicy(tx *dbs.Tx, policyId in
|
|||||||
config.IsOn = policy.IsOn == 1
|
config.IsOn = policy.IsOn == 1
|
||||||
config.Name = policy.Name
|
config.Name = policy.Name
|
||||||
config.Description = policy.Description
|
config.Description = policy.Description
|
||||||
|
config.Mode = policy.Mode
|
||||||
|
|
||||||
// Inbound
|
// Inbound
|
||||||
inbound := &firewallconfigs.HTTPFirewallInboundConfig{}
|
inbound := &firewallconfigs.HTTPFirewallInboundConfig{}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
package models
|
package models
|
||||||
|
|
||||||
// HTTP防火墙
|
// HTTPFirewallPolicy HTTP防火墙
|
||||||
type HTTPFirewallPolicy struct {
|
type HTTPFirewallPolicy struct {
|
||||||
Id uint32 `field:"id"` // ID
|
Id uint32 `field:"id"` // ID
|
||||||
TemplateId uint32 `field:"templateId"` // 模版ID
|
TemplateId uint32 `field:"templateId"` // 模版ID
|
||||||
@@ -15,6 +15,7 @@ type HTTPFirewallPolicy struct {
|
|||||||
Inbound string `field:"inbound"` // 入站规则
|
Inbound string `field:"inbound"` // 入站规则
|
||||||
Outbound string `field:"outbound"` // 出站规则
|
Outbound string `field:"outbound"` // 出站规则
|
||||||
BlockOptions string `field:"blockOptions"` // BLOCK选项
|
BlockOptions string `field:"blockOptions"` // BLOCK选项
|
||||||
|
Mode string `field:"mode"` // 模式
|
||||||
}
|
}
|
||||||
|
|
||||||
type HTTPFirewallPolicyOperator struct {
|
type HTTPFirewallPolicyOperator struct {
|
||||||
@@ -31,6 +32,7 @@ type HTTPFirewallPolicyOperator struct {
|
|||||||
Inbound interface{} // 入站规则
|
Inbound interface{} // 入站规则
|
||||||
Outbound interface{} // 出站规则
|
Outbound interface{} // 出站规则
|
||||||
BlockOptions interface{} // BLOCK选项
|
BlockOptions interface{} // BLOCK选项
|
||||||
|
Mode interface{} // 模式
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewHTTPFirewallPolicyOperator() *HTTPFirewallPolicyOperator {
|
func NewHTTPFirewallPolicyOperator() *HTTPFirewallPolicyOperator {
|
||||||
|
|||||||
@@ -43,6 +43,7 @@ func (this *HTTPFirewallPolicyService) FindAllEnabledHTTPFirewallPolicies(ctx co
|
|||||||
IsOn: p.IsOn == 1,
|
IsOn: p.IsOn == 1,
|
||||||
InboundJSON: []byte(p.Inbound),
|
InboundJSON: []byte(p.Inbound),
|
||||||
OutboundJSON: []byte(p.Outbound),
|
OutboundJSON: []byte(p.Outbound),
|
||||||
|
Mode: p.Mode,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -283,7 +284,7 @@ func (this *HTTPFirewallPolicyService) UpdateHTTPFirewallPolicy(ctx context.Cont
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
err = models.SharedHTTPFirewallPolicyDAO.UpdateFirewallPolicy(tx, req.HttpFirewallPolicyId, req.IsOn, req.Name, req.Description, inboundConfigJSON, outboundConfigJSON, req.BlockOptionsJSON)
|
err = models.SharedHTTPFirewallPolicyDAO.UpdateFirewallPolicy(tx, req.HttpFirewallPolicyId, req.IsOn, req.Name, req.Description, inboundConfigJSON, outboundConfigJSON, req.BlockOptionsJSON, req.Mode)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -382,6 +383,7 @@ func (this *HTTPFirewallPolicyService) ListEnabledHTTPFirewallPolicies(ctx conte
|
|||||||
IsOn: p.IsOn == 1,
|
IsOn: p.IsOn == 1,
|
||||||
InboundJSON: []byte(p.Inbound),
|
InboundJSON: []byte(p.Inbound),
|
||||||
OutboundJSON: []byte(p.Outbound),
|
OutboundJSON: []byte(p.Outbound),
|
||||||
|
Mode: p.Mode,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -471,6 +473,7 @@ func (this *HTTPFirewallPolicyService) FindEnabledHTTPFirewallPolicy(ctx context
|
|||||||
IsOn: policy.IsOn == 1,
|
IsOn: policy.IsOn == 1,
|
||||||
InboundJSON: []byte(policy.Inbound),
|
InboundJSON: []byte(policy.Inbound),
|
||||||
OutboundJSON: []byte(policy.Outbound),
|
OutboundJSON: []byte(policy.Outbound),
|
||||||
|
Mode: policy.Mode,
|
||||||
}}, nil
|
}}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user