mirror of
https://github.com/TeaOSLab/EdgeAdmin.git
synced 2025-11-14 04:10:26 +08:00
WAF策略增加观察模式和通过模式
This commit is contained in:
@@ -70,10 +70,17 @@ func (this *IndexAction) RunGet(params struct {
|
|||||||
}
|
}
|
||||||
countClusters := countClustersResp.Count
|
countClusters := countClustersResp.Count
|
||||||
|
|
||||||
|
// mode
|
||||||
|
if len(policy.Mode) == 0 {
|
||||||
|
policy.Mode = firewallconfigs.FirewallModeDefend
|
||||||
|
}
|
||||||
|
|
||||||
policyMaps = append(policyMaps, maps.Map{
|
policyMaps = append(policyMaps, maps.Map{
|
||||||
"id": policy.Id,
|
"id": policy.Id,
|
||||||
"isOn": policy.IsOn,
|
"isOn": policy.IsOn,
|
||||||
"name": policy.Name,
|
"name": policy.Name,
|
||||||
|
"mode": policy.Mode,
|
||||||
|
"modeInfo": firewallconfigs.FindFirewallMode(policy.Mode),
|
||||||
"countInbound": countInbound,
|
"countInbound": countInbound,
|
||||||
"countOutbound": countOutbound,
|
"countOutbound": countOutbound,
|
||||||
"countClusters": countClusters,
|
"countClusters": countClusters,
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import (
|
|||||||
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
|
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
|
||||||
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/dao"
|
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/dao"
|
||||||
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
|
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
|
||||||
|
"github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs/firewallconfigs"
|
||||||
"github.com/iwind/TeaGo/maps"
|
"github.com/iwind/TeaGo/maps"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -46,11 +47,17 @@ func (this *PolicyAction) RunGet(params struct {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 模式
|
||||||
|
if len(firewallPolicy.Mode) == 0 {
|
||||||
|
firewallPolicy.Mode = firewallconfigs.FirewallModeDefend
|
||||||
|
}
|
||||||
this.Data["firewallPolicy"] = maps.Map{
|
this.Data["firewallPolicy"] = maps.Map{
|
||||||
"id": firewallPolicy.Id,
|
"id": firewallPolicy.Id,
|
||||||
"name": firewallPolicy.Name,
|
"name": firewallPolicy.Name,
|
||||||
"isOn": firewallPolicy.IsOn,
|
"isOn": firewallPolicy.IsOn,
|
||||||
"description": firewallPolicy.Description,
|
"description": firewallPolicy.Description,
|
||||||
|
"mode": firewallPolicy.Mode,
|
||||||
|
"modeInfo": firewallconfigs.FindFirewallMode(firewallPolicy.Mode),
|
||||||
"groups": internalGroups,
|
"groups": internalGroups,
|
||||||
"blockOptions": firewallPolicy.BlockOptions,
|
"blockOptions": firewallPolicy.BlockOptions,
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -42,11 +42,18 @@ func (this *UpdateAction) RunGet(params struct {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// mode
|
||||||
|
if len(firewallPolicy.Mode) == 0 {
|
||||||
|
firewallPolicy.Mode = firewallconfigs.FirewallModeDefend
|
||||||
|
}
|
||||||
|
this.Data["modes"] = firewallconfigs.FindAllFirewallModes()
|
||||||
|
|
||||||
this.Data["firewallPolicy"] = maps.Map{
|
this.Data["firewallPolicy"] = maps.Map{
|
||||||
"id": firewallPolicy.Id,
|
"id": firewallPolicy.Id,
|
||||||
"name": firewallPolicy.Name,
|
"name": firewallPolicy.Name,
|
||||||
"description": firewallPolicy.Description,
|
"description": firewallPolicy.Description,
|
||||||
"isOn": firewallPolicy.IsOn,
|
"isOn": firewallPolicy.IsOn,
|
||||||
|
"mode": firewallPolicy.Mode,
|
||||||
"blockOptions": firewallPolicy.BlockOptions,
|
"blockOptions": firewallPolicy.BlockOptions,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -79,6 +86,7 @@ func (this *UpdateAction) RunPost(params struct {
|
|||||||
BlockOptionsJSON []byte
|
BlockOptionsJSON []byte
|
||||||
Description string
|
Description string
|
||||||
IsOn bool
|
IsOn bool
|
||||||
|
Mode string
|
||||||
|
|
||||||
Must *actions.Must
|
Must *actions.Must
|
||||||
}) {
|
}) {
|
||||||
@@ -103,6 +111,7 @@ func (this *UpdateAction) RunPost(params struct {
|
|||||||
Description: params.Description,
|
Description: params.Description,
|
||||||
FirewallGroupCodes: params.GroupCodes,
|
FirewallGroupCodes: params.GroupCodes,
|
||||||
BlockOptionsJSON: params.BlockOptionsJSON,
|
BlockOptionsJSON: params.BlockOptionsJSON,
|
||||||
|
Mode: params.Mode,
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
this.ErrorPage(err)
|
this.ErrorPage(err)
|
||||||
|
|||||||
@@ -37,10 +37,19 @@
|
|||||||
</thead>
|
</thead>
|
||||||
<tr v-for="policy in policies">
|
<tr v-for="policy in policies">
|
||||||
<td><a :href="'/servers/components/waf/policy?firewallPolicyId=' + policy.id"><keyword :v-word="keyword">{{policy.name}}</keyword></a></td>
|
<td><a :href="'/servers/components/waf/policy?firewallPolicyId=' + policy.id"><keyword :v-word="keyword">{{policy.name}}</keyword></a></td>
|
||||||
<td class="center">{{policy.countInbound}}</td>
|
<td class="center">
|
||||||
<td class="center">{{policy.countOutbound}}</td>
|
<a :href="'/servers/components/waf/groups?firewallPolicyId=' + policy.id + '&type=inbound'"><span :class="{disabled:policy.countInbound == 0 }">{{policy.countInbound}}</span></a>
|
||||||
|
</td>
|
||||||
|
<td class="center">
|
||||||
|
<a :href="'/servers/components/waf/groups?firewallPolicyId=' + policy.id + '&type=outbound'"><span :class="{disabled:policy.countOutbound == 0 }">{{policy.countOutbound}}</span></a>
|
||||||
|
</td>
|
||||||
<td class="center">{{policy.countClusters}}</td>
|
<td class="center">{{policy.countClusters}}</td>
|
||||||
<td class="center"><label-on :v-is-on="policy.isOn"></label-on></td>
|
<td class="center">
|
||||||
|
<span v-if="!policy.isOn" class="red">已停用</span>
|
||||||
|
<div v-else-if="policy.modeInfo != null">
|
||||||
|
<span :class="{green: policy.modeInfo.code == 'defend', blue: policy.modeInfo.code == 'observe', grey: policy.modeInfo.code == 'pass'}">{{policy.modeInfo.name}}</span>
|
||||||
|
</div>
|
||||||
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<a :href="'/servers/components/waf/policy?firewallPolicyId=' + policy.id">详情</a>
|
<a :href="'/servers/components/waf/policy?firewallPolicyId=' + policy.id">详情</a>
|
||||||
<a href="" @click.prevent="deletePolicy(policy.id)">删除</a>
|
<a href="" @click.prevent="deletePolicy(policy.id)">删除</a>
|
||||||
|
|||||||
@@ -7,9 +7,13 @@
|
|||||||
<td>{{firewallPolicy.name}}</td>
|
<td>{{firewallPolicy.name}}</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td>是否启用</td>
|
<td>状态</td>
|
||||||
<td>
|
<td>
|
||||||
<label-on :v-is-on="firewallPolicy.isOn"></label-on>
|
<span v-if="!firewallPolicy.isOn" class="red">已停用</span>
|
||||||
|
<div v-else-if="firewallPolicy.modeInfo != null">
|
||||||
|
<span :class="{green: firewallPolicy.modeInfo.code == 'defend', blue: firewallPolicy.modeInfo.code == 'observe', grey: firewallPolicy.modeInfo.code == 'pass'}">{{firewallPolicy.modeInfo.name}}</span>
|
||||||
|
<p class="comment">{{firewallPolicy.modeInfo.description}}</p>
|
||||||
|
</div>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
|
|||||||
@@ -12,6 +12,15 @@
|
|||||||
<p class="comment">给策略起一个容易识别的名字。</p>
|
<p class="comment">给策略起一个容易识别的名字。</p>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>当前模式</td>
|
||||||
|
<td>
|
||||||
|
<select class="ui dropdown auto-width" name="mode" v-model="firewallPolicy.mode">
|
||||||
|
<option v-for="mode in modes" :value="mode.code">{{mode.name}}</option>
|
||||||
|
</select>
|
||||||
|
<p class="comment" v-for="mode in modes" v-if="mode.code == firewallPolicy.mode">{{mode.description}}</p>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td>启用预置的规则</td>
|
<td>启用预置的规则</td>
|
||||||
<td>
|
<td>
|
||||||
|
|||||||
Reference in New Issue
Block a user