mirror of
https://github.com/TeaOSLab/EdgeAdmin.git
synced 2025-11-19 23:50:25 +08:00
WAF日志可以使用规则分组筛选
This commit is contained in:
@@ -1,8 +1,11 @@
|
|||||||
package waf
|
package waf
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"encoding/json"
|
||||||
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
|
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
|
||||||
"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"
|
||||||
timeutil "github.com/iwind/TeaGo/utils/time"
|
timeutil "github.com/iwind/TeaGo/utils/time"
|
||||||
"regexp"
|
"regexp"
|
||||||
"strings"
|
"strings"
|
||||||
@@ -20,6 +23,7 @@ func (this *LogAction) RunGet(params struct {
|
|||||||
Day string
|
Day string
|
||||||
RequestId string
|
RequestId string
|
||||||
FirewallPolicyId int64
|
FirewallPolicyId int64
|
||||||
|
GroupId int64
|
||||||
}) {
|
}) {
|
||||||
if len(params.Day) == 0 {
|
if len(params.Day) == 0 {
|
||||||
params.Day = timeutil.Format("Y-m-d")
|
params.Day = timeutil.Format("Y-m-d")
|
||||||
@@ -27,6 +31,7 @@ func (this *LogAction) RunGet(params struct {
|
|||||||
|
|
||||||
this.Data["path"] = this.Request.URL.Path
|
this.Data["path"] = this.Request.URL.Path
|
||||||
this.Data["day"] = params.Day
|
this.Data["day"] = params.Day
|
||||||
|
this.Data["groupId"] = params.GroupId
|
||||||
this.Data["accessLogs"] = []interface{}{}
|
this.Data["accessLogs"] = []interface{}{}
|
||||||
|
|
||||||
day := params.Day
|
day := params.Day
|
||||||
@@ -37,6 +42,7 @@ func (this *LogAction) RunGet(params struct {
|
|||||||
resp, err := this.RPC().HTTPAccessLogRPC().ListHTTPAccessLogs(this.AdminContext(), &pb.ListHTTPAccessLogsRequest{
|
resp, err := this.RPC().HTTPAccessLogRPC().ListHTTPAccessLogs(this.AdminContext(), &pb.ListHTTPAccessLogsRequest{
|
||||||
RequestId: params.RequestId,
|
RequestId: params.RequestId,
|
||||||
FirewallPolicyId: params.FirewallPolicyId,
|
FirewallPolicyId: params.FirewallPolicyId,
|
||||||
|
FirewallRuleGroupId: params.GroupId,
|
||||||
Day: day,
|
Day: day,
|
||||||
Size: size,
|
Size: size,
|
||||||
})
|
})
|
||||||
@@ -61,6 +67,7 @@ func (this *LogAction) RunGet(params struct {
|
|||||||
prevResp, err := this.RPC().HTTPAccessLogRPC().ListHTTPAccessLogs(this.AdminContext(), &pb.ListHTTPAccessLogsRequest{
|
prevResp, err := this.RPC().HTTPAccessLogRPC().ListHTTPAccessLogs(this.AdminContext(), &pb.ListHTTPAccessLogsRequest{
|
||||||
RequestId: params.RequestId,
|
RequestId: params.RequestId,
|
||||||
FirewallPolicyId: params.FirewallPolicyId,
|
FirewallPolicyId: params.FirewallPolicyId,
|
||||||
|
FirewallRuleGroupId: params.GroupId,
|
||||||
Day: day,
|
Day: day,
|
||||||
Size: size,
|
Size: size,
|
||||||
Reverse: true,
|
Reverse: true,
|
||||||
@@ -75,5 +82,29 @@ func (this *LogAction) RunGet(params struct {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 所有分组
|
||||||
|
policyResp, err := this.RPC().HTTPFirewallPolicyRPC().FindEnabledFirewallPolicyConfig(this.AdminContext(), &pb.FindEnabledFirewallPolicyConfigRequest{
|
||||||
|
FirewallPolicyId: params.FirewallPolicyId,
|
||||||
|
})
|
||||||
|
if err != nil {
|
||||||
|
this.ErrorPage(err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
policyConfig := &firewallconfigs.HTTPFirewallPolicy{}
|
||||||
|
err = json.Unmarshal(policyResp.FirewallPolicyJSON, policyConfig)
|
||||||
|
if err != nil {
|
||||||
|
this.ErrorPage(err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
groupMaps := []maps.Map{}
|
||||||
|
for _, group := range policyConfig.AllRuleGroups() {
|
||||||
|
groupMaps = append(groupMaps, maps.Map{
|
||||||
|
"id": group.Id,
|
||||||
|
"name": group.Name,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
this.Data["groups"] = groupMaps
|
||||||
|
|
||||||
this.Show()
|
this.Show()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,9 +14,15 @@
|
|||||||
<div class="right-box">
|
<div class="right-box">
|
||||||
{$template "waf_menu"}
|
{$template "waf_menu"}
|
||||||
|
|
||||||
<first-menu>
|
|
||||||
<div class="item right">
|
|
||||||
<form class="ui form small" :action="path" autocomplete="off">
|
<form class="ui form small" :action="path" autocomplete="off">
|
||||||
|
<first-menu style="margin-top: -1em">
|
||||||
|
<div class="item">
|
||||||
|
<select class="ui dropdown" name="groupId" v-model="groupId">
|
||||||
|
<option value="0">[规则分组]</option>
|
||||||
|
<option v-for="group in groups" :value="group.id">{{group.name}}</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
<div class="item right">
|
||||||
<input type="hidden" name="firewallPolicyId" :value="firewallPolicyId"/>
|
<input type="hidden" name="firewallPolicyId" :value="firewallPolicyId"/>
|
||||||
<div class="ui fields inline">
|
<div class="ui fields inline">
|
||||||
<div class="ui field">
|
<div class="ui field">
|
||||||
@@ -26,9 +32,9 @@
|
|||||||
<button class="ui button small" type="submit">查找</button>
|
<button class="ui button small" type="submit">查找</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
|
||||||
</div>
|
</div>
|
||||||
</first-menu>
|
</first-menu>
|
||||||
|
</form>
|
||||||
|
|
||||||
<p class="comment" v-if="accessLogs.length == 0">暂时还没有日志。</p>
|
<p class="comment" v-if="accessLogs.length == 0">暂时还没有日志。</p>
|
||||||
|
|
||||||
@@ -40,10 +46,10 @@
|
|||||||
</table>
|
</table>
|
||||||
|
|
||||||
<div v-if="accessLogs.length > 0">
|
<div v-if="accessLogs.length > 0">
|
||||||
<a :href="path + '?requestId=' + lastRequestId + '&day=' + day + '&firewallPolicyId=' + firewallPolicyId" v-if="hasPrev">上一页</a>
|
<a :href="path + '?requestId=' + lastRequestId + '&day=' + day + '&firewallPolicyId=' + firewallPolicyId + '&groupId=' + groupId" v-if="hasPrev">上一页</a>
|
||||||
<span v-else class="disabled">上一页</span>
|
<span v-else class="disabled">上一页</span>
|
||||||
<span class="disabled"> | </span>
|
<span class="disabled"> | </span>
|
||||||
<a :href="path + '?requestId=' + nextRequestId + '&day=' + day + '&firewallPolicyId=' + firewallPolicyId" v-if="hasMore">下一页</a>
|
<a :href="path + '?requestId=' + nextRequestId + '&day=' + day + '&firewallPolicyId=' + firewallPolicyId + '&groupId=' + groupId" v-if="hasMore">下一页</a>
|
||||||
<span v-else class="disabled">下一页</span>
|
<span v-else class="disabled">下一页</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
Reference in New Issue
Block a user