[WAF]规则中增加请求Header长度限制和响应Header长度限制

This commit is contained in:
GoEdgeLab
2020-11-18 19:35:32 +08:00
parent 545ec75842
commit 60ba3e0a05
9 changed files with 192 additions and 66 deletions

View File

@@ -22,15 +22,16 @@ func (this *CreateRulePopupAction) RunGet(params struct {
}) {
// check points
checkpointList := []maps.Map{}
for _, def := range firewallconfigs.AllCheckpoints {
if (params.Type == "inbound" && def.IsRequest) || (params.Type == "outbound" && !def.IsRequest) {
for _, checkpoint := range firewallconfigs.AllCheckpoints {
if (params.Type == "inbound" && checkpoint.IsRequest) || (params.Type == "outbound" && !checkpoint.IsRequest) {
checkpointList = append(checkpointList, maps.Map{
"name": def.Name,
"prefix": def.Prefix,
"description": def.Description,
"hasParams": len(def.Params) > 0,
"params": def.Params,
"options": def.Options,
"name": checkpoint.Name,
"prefix": checkpoint.Prefix,
"description": checkpoint.Description,
"hasParams": len(checkpoint.Params) > 0,
"params": checkpoint.Params,
"options": checkpoint.Options,
"isComposed": checkpoint.IsComposed,
})
}
}
@@ -89,7 +90,7 @@ func (this *CreateRulePopupAction) RunPost(params struct {
rule.CheckpointOptions = map[string]interface{}{}
for _, option := range options {
rule.CheckpointOptions[option.GetString("code")] = option.GetString("value")
rule.CheckpointOptions[option.GetString("code")] = option.Get("value")
}
}

View File

@@ -86,15 +86,15 @@ func (this *GroupAction) RunGet(params struct {
"name": set.Name,
"rules": lists.Map(set.Rules, func(k int, v interface{}) interface{} {
rule := v.(*firewallconfigs.HTTPFirewallRule)
return maps.Map{
"param": rule.Param,
"operator": rule.Operator,
"value": rule.Value,
"isCaseInsensitive": rule.IsCaseInsensitive,
"isComposed": firewallconfigs.CheckCheckpointIsComposed(rule.Prefix()),
}
}),
"isOn": set.IsOn,
"isOn": set.IsOn,
"action": strings.ToUpper(set.Action),
"actionOptions": set.ActionOptions,
"actionName": firewallconfigs.FindActionName(set.Action),

View File

@@ -3,6 +3,7 @@ package waf
import (
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
"github.com/TeaOSLab/EdgeAdmin/internal/web/models"
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
"github.com/iwind/TeaGo/maps"
)
@@ -53,5 +54,20 @@ func (this *PolicyAction) RunGet(params struct {
"groups": internalGroups,
}
// 正在使用此策略的服务
listServersResp, err := this.RPC().ServerRPC().FindAllEnabledServersWithHTTPFirewallPolicyId(this.AdminContext(), &pb.FindAllEnabledServersWithHTTPFirewallPolicyIdRequest{FirewallPolicyId: params.FirewallPolicyId})
if err != nil {
this.ErrorPage(err)
return
}
serverMaps := []maps.Map{}
for _, server := range listServersResp.Servers {
serverMaps = append(serverMaps, maps.Map{
"id": server.Id,
"name": server.Name,
})
}
this.Data["servers"] = serverMaps
this.Show()
}