From 63884bc8369444f757c134f77dc9dbdcdb567e51 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E7=A5=A5=E8=B6=85?= Date: Sun, 18 Jul 2021 15:52:50 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96WAF=E5=8A=A8=E4=BD=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../components/server/http-access-log-box.js | 2 +- .../server/http-firewall-actions-box.js | 90 +++++++++++++------ .../components/waf/createSetPopup.html | 2 +- .../servers/components/waf/groups.html | 76 ++++++++-------- .../components/waf/updateSetPopup.html | 2 +- .../servers/server/settings/waf/group.html | 13 +-- 6 files changed, 112 insertions(+), 73 deletions(-) diff --git a/web/public/js/components/server/http-access-log-box.js b/web/public/js/components/server/http-access-log-box.js index 939085b5..823d061f 100644 --- a/web/public/js/components/server/http-access-log-box.js +++ b/web/public/js/components/server/http-access-log-box.js @@ -49,7 +49,7 @@ Vue.component("http-access-log-box", { } }, template: `
- [{{accessLog.region}}] {{accessLog.remoteAddr}} [{{accessLog.timeLocal}}] "{{accessLog.requestMethod}} {{accessLog.scheme}}://{{accessLog.host}}{{accessLog.requestURI}} {{accessLog.proto}}" {{accessLog.status}} cache hit waf {{accessLog.attrs['waf.action']}} - 耗时:{{formatCost(accessLog.requestTime)}} ms   ({{accessLog.humanTime}}) + [{{accessLog.region}}] {{accessLog.remoteAddr}} [{{accessLog.timeLocal}}] "{{accessLog.requestMethod}} {{accessLog.scheme}}://{{accessLog.host}}{{accessLog.requestURI}} {{accessLog.proto}}" {{accessLog.status}} cache hit waf {{accessLog.firewallActions}} - {{tag}} - 耗时:{{formatCost(accessLog.requestTime)}} ms   ({{accessLog.humanTime}})  
` }) \ No newline at end of file diff --git a/web/public/js/components/server/http-firewall-actions-box.js b/web/public/js/components/server/http-firewall-actions-box.js index db1678be..b0d8c731 100644 --- a/web/public/js/components/server/http-firewall-actions-box.js +++ b/web/public/js/components/server/http-firewall-actions-box.js @@ -62,7 +62,7 @@ Vue.component("http-firewall-actions-box", { ipListLevels: [], // 动作参数 - blockLife: "", + blockTimeout: "", captchaLife: "", get302Life: "", post307Life: "", @@ -89,12 +89,12 @@ Vue.component("http-firewall-actions-box", { }) this.actionOptions = {} }, - blockLife: function (v) { + blockTimeout: function (v) { v = parseInt(v) if (isNaN(v)) { - this.actionOptions["life"] = 0 + this.actionOptions["timeout"] = 0 } else { - this.actionOptions["life"] = v + this.actionOptions["timeout"] = v } }, captchaLife: function (v) { @@ -121,7 +121,7 @@ Vue.component("http-firewall-actions-box", { this.actionOptions["life"] = v } }, - recordIPType: function () { + recordIPType: function (v) { this.recordIPListId = 0 }, recordIPTimeout: function (v) { @@ -168,7 +168,7 @@ Vue.component("http-firewall-actions-box", { this.actionOptions = {} // 动作参数 - this.blockLife = "" + this.blockTimeout = "" this.captchaLife = "" this.get302Life = "" this.post307Life = "" @@ -192,8 +192,13 @@ Vue.component("http-firewall-actions-box", { this.action = this.vActions.$find(function (k, v) { return v.code == that.actionCode }) + + // 滚到界面底部 + this.scroll() }, remove: function (index) { + this.isAdding = false + this.editingIndex = -1 this.configs.$remove(index) }, update: function (index, config) { @@ -211,9 +216,9 @@ Vue.component("http-firewall-actions-box", { switch (config.code) { case "block": - this.blockLife = "" - if (config.options.life != null || config.options.life > 0) { - this.blockLife = config.options.life.toString() + this.blockTimeout = "" + if (config.options.timeout != null || config.options.timeout > 0) { + this.blockTimeout = config.options.timeout.toString() } break case "allow": @@ -247,8 +252,13 @@ Vue.component("http-firewall-actions-box", { if (config.options.timeout > 0) { this.recordIPTimeout = config.options.timeout.toString() } - this.recordIPListId = config.options.ipListId - this.recordIPListName = config.options.ipListName + let that = this + + // VUE需要在函数执行完之后才会调用watch函数,这样会导致设置的值被覆盖,所以这里使用setTimeout + setTimeout(function () { + that.recordIPListId = config.options.ipListId + that.recordIPListName = config.options.ipListName + }) } break case "tag": @@ -274,18 +284,25 @@ Vue.component("http-firewall-actions-box", { return v.id == config.options.groupId }) - this.goSetId = config.options.setId - if (this.goGroup != null) { - let set = this.goGroup.sets.$find(function (k, v) { - return v.id == config.options.setId - }) - if (set != null) { - this.goSetName = set.name + // VUE需要在函数执行完之后才会调用watch函数,这样会导致设置的值被覆盖,所以这里使用setTimeout + let that = this + setTimeout(function () { + that.goSetId = config.options.setId + if (that.goGroup != null) { + let set = that.goGroup.sets.$find(function (k, v) { + return v.id == config.options.setId + }) + if (set != null) { + that.goSetName = set.name + } } - } + }) } break } + + // 滚到界面底部 + this.scroll() }, cancel: function () { this.isAdding = false @@ -335,7 +352,7 @@ Vue.component("http-firewall-actions-box", { return } this.actionOptions = { - groupId: groupId, + groupId: groupId.toString(), groupName: this.goGroupName } } else if (this.actionCode == "go_set") { // go_set @@ -358,9 +375,9 @@ Vue.component("http-firewall-actions-box", { return } this.actionOptions = { - groupId: groupId, + groupId: groupId.toString(), groupName: this.goGroupName, - setId: setId, + setId: setId.toString(), setName: this.goSetName } } @@ -419,6 +436,14 @@ Vue.component("http-firewall-actions-box", { callback() }) document.head.appendChild(jsFile) + }, + scroll: function () { + setTimeout(function () { + let mainDiv = document.getElementsByClassName("main") + if (mainDiv.length > 0) { + mainDiv[0].scrollTo(0, 1000) + } + }, 10) } }, template: `
@@ -427,6 +452,18 @@ Vue.component("http-firewall-actions-box", {
{{config.name}} ({{config.code.toUpperCase()}}) + + :有效期{{config.options.timeout}}秒 + + + :有效期{{config.options.life}}秒 + + + :有效期{{config.options.life}}秒 + + + :有效期{{config.options.life}}秒 + :{{config.options.ipListName}} @@ -461,7 +498,7 @@ Vue.component("http-firewall-actions-box", { 封锁时间
- +
@@ -475,7 +512,7 @@ Vue.component("http-firewall-actions-box", {
-

验证通过后在这个时间内不再验证。

+

验证通过后在这个时间内不再验证,默认600秒。

@@ -514,7 +551,7 @@ Vue.component("http-firewall-actions-box", { - 选择IP名单 + 选择IP名单 *
{{recordIPListName}}
@@ -533,7 +570,7 @@ Vue.component("http-firewall-actions-box", { 超时时间
- +

0表示不超时。

@@ -585,5 +622,6 @@ Vue.component("http-firewall-actions-box", {
+

系统总是会先执行记录日志、标签等不会修改请求的动作,再执行阻止、验证码等可能改变请求的动作。

` }) \ No newline at end of file diff --git a/web/views/@default/servers/components/waf/createSetPopup.html b/web/views/@default/servers/components/waf/createSetPopup.html index 92ac5bea..dd04ea08 100644 --- a/web/views/@default/servers/components/waf/createSetPopup.html +++ b/web/views/@default/servers/components/waf/createSetPopup.html @@ -12,7 +12,7 @@ - 规则 + 规则 * diff --git a/web/views/@default/servers/components/waf/groups.html b/web/views/@default/servers/components/waf/groups.html index e8d46f3c..297ac034 100644 --- a/web/views/@default/servers/components/waf/groups.html +++ b/web/views/@default/servers/components/waf/groups.html @@ -1,44 +1,44 @@ {$layout} - {$template "waf_menu"} +{$template "waf_menu"} - - [添加分组] - + + [添加分组] + -

暂时还没有规则分组。

+

暂时还没有规则分组。

- - - - - - - - - - - - - - - - - -
规则分组规则集操作
{{group.name}} -

{{group.description}}

-

- 启用 - 停用 - 预置 - 自定义 -

-
- {{group.countSets}} - - 详情   - 启用停用   - 删除 -
+ + + + + + + + + + + + + + + + + +
规则分组规则集操作
{{group.name}} +

{{group.description}}

+

+ 启用 + 停用 + 预置 + 自定义 +

+
+ {{group.countSets}} + + 详情   + 启用停用   + 删除 +
-

所有规则匹配顺序为从上到下,可以拖动左侧的排序。

\ No newline at end of file +

所有规则匹配顺序为从上到下,可以拖动左侧的排序。

\ No newline at end of file diff --git a/web/views/@default/servers/components/waf/updateSetPopup.html b/web/views/@default/servers/components/waf/updateSetPopup.html index d3fb5078..90f981f6 100644 --- a/web/views/@default/servers/components/waf/updateSetPopup.html +++ b/web/views/@default/servers/components/waf/updateSetPopup.html @@ -12,7 +12,7 @@ - 规则 + 规则 * diff --git a/web/views/@default/servers/server/settings/waf/group.html b/web/views/@default/servers/server/settings/waf/group.html index 690d52f1..d0bb4e2e 100644 --- a/web/views/@default/servers/server/settings/waf/group.html +++ b/web/views/@default/servers/server/settings/waf/group.html @@ -33,7 +33,7 @@ 规则集名称 规则 - 关系 + 关系 动作 操作 @@ -52,11 +52,12 @@ 暂时还没有规则 - {{set.connector.toUpperCase()}} - {{set.actionName}}[{{set.action.toUpperCase()}}] -
- -> [{{link.name}}]   -
+ + + ({{set.connector.toUpperCase()}}) + + + 修改   停用启用   删除