优化WAF规则相关界面

This commit is contained in:
GoEdgeLab
2022-11-16 15:43:08 +08:00
parent 501226f5ab
commit aa089db13c
7 changed files with 37 additions and 9 deletions

View File

@@ -32,6 +32,7 @@ func (this *CreateRulePopupAction) RunGet(params struct {
"params": checkpoint.Params, "params": checkpoint.Params,
"options": checkpoint.Options, "options": checkpoint.Options,
"isComposed": checkpoint.IsComposed, "isComposed": checkpoint.IsComposed,
"dataType": checkpoint.DataType,
}) })
} }
} }

View File

@@ -14,6 +14,7 @@ Vue.component("http-firewall-rules-box", {
window.UPDATING_RULE = null window.UPDATING_RULE = null
let that = this let that = this
teaweb.popup("/servers/components/waf/createRulePopup?type=" + this.vType, { teaweb.popup("/servers/components/waf/createRulePopup?type=" + this.vType, {
height: "30em",
callback: function (resp) { callback: function (resp) {
that.rules.push(resp.data.rule) that.rules.push(resp.data.rule)
} }
@@ -23,6 +24,7 @@ Vue.component("http-firewall-rules-box", {
window.UPDATING_RULE = rule window.UPDATING_RULE = rule
let that = this let that = this
teaweb.popup("/servers/components/waf/createRulePopup?type=" + this.vType, { teaweb.popup("/servers/components/waf/createRulePopup?type=" + this.vType, {
height: "30em",
callback: function (resp) { callback: function (resp) {
Vue.set(that.rules, index, resp.data.rule) Vue.set(that.rules, index, resp.data.rule)
} }

View File

@@ -91,7 +91,7 @@
</tr> </tr>
<tr> <tr>
<td> <td>
<span v-if="rule.operator == 'match' || rule.operator == 'not match'">正则表达式</span> <span v-if="(checkpoint == null || checkpoint.dataType != 'bool') && (rule.operator == 'match' || rule.operator == 'not match')">正则表达式</span>
<span v-else>对比值</span> <span v-else>对比值</span>
</td> </td>
<td> <td>
@@ -105,6 +105,15 @@
<p class="comment">将二进制进行Base64Encode后放在这里比如<code-label>Hello</code-label>对应<code-label>SGVsbG8=</code-label></p> <p class="comment">将二进制进行Base64Encode后放在这里比如<code-label>Hello</code-label>对应<code-label>SGVsbG8=</code-label></p>
</div> </div>
<!-- bool数据 -->
<div v-else-if="checkpoint != null && checkpoint.dataType == 'bool'">
<select name="value" class="ui selectable auto-width" v-model="rule.value" @change="changeRuleValue">
<option value="">[请选择]</option>
<option value="1">是(1)</option>
<option value="0">否(0)</option>
</select>
</div>
<!-- 其余数据 --> <!-- 其余数据 -->
<textarea rows="3" maxlength="4096" name="value" v-model="rule.value" @input="changeRuleValue" v-else></textarea> <textarea rows="3" maxlength="4096" name="value" v-model="rule.value" @input="changeRuleValue" v-else></textarea>
@@ -132,7 +141,7 @@
</div> </div>
</td> </td>
</tr> </tr>
<tr v-if="rule.operator == 'match' || rule.operator == 'not match'"> <tr v-if="(checkpoint == null || checkpoint.dataType != 'bool') && (rule.operator == 'match' || rule.operator == 'not match')">
<td>正则表达式测试</td> <td>正则表达式测试</td>
<td> <td>
<a href="" v-if="!regexpTestIsOn" @click.prevent="changeRegexpTestIsOn">[输入测试字符串]</a> <a href="" v-if="!regexpTestIsOn" @click.prevent="changeRegexpTestIsOn">[输入测试字符串]</a>
@@ -147,7 +156,7 @@
</div> </div>
</td> </td>
</tr> </tr>
<tr v-if="operator.case != 'none'"> <tr v-if="(checkpoint == null || checkpoint.dataType != 'bool') && operator != null && operator.case != 'none'">
<td>不区分大小写</td> <td>不区分大小写</td>
<td> <td>
<div class="ui checkbox"> <div class="ui checkbox">

View File

@@ -52,6 +52,19 @@ Tea.context(function () {
this.checkpoint = this.checkpoints.$find(function (k, v) { this.checkpoint = this.checkpoints.$find(function (k, v) {
return v.prefix == that.rule.checkpointPrefix return v.prefix == that.rule.checkpointPrefix
}) })
if (this.checkpoint == null) {
return
}
switch (this.checkpoint.dataType) {
case "bool":
this.rule.operator = "eq"
break
case "number":
this.rule.operator = "eq"
break
default:
this.rule.operator = "match"
}
} }
@@ -63,6 +76,9 @@ Tea.context(function () {
this.operator = this.operators.$find(function (k, v) { this.operator = this.operators.$find(function (k, v) {
return v.code == that.rule.operator return v.code == that.rule.operator
}) })
if (this.operator == null) {
return
}
if (!this.isUpdating) { if (!this.isUpdating) {
this.rule.isCaseInsensitive = (this.operator.case == "yes") this.rule.isCaseInsensitive = (this.operator.case == "yes")
} }

View File

@@ -34,7 +34,7 @@ Tea.context(function () {
this.createSet = function (groupId) { this.createSet = function (groupId) {
teaweb.popup("/servers/components/waf/createSetPopup?firewallPolicyId=" + this.firewallPolicyId + "&groupId=" + groupId + "&type=" + this.type, { teaweb.popup("/servers/components/waf/createSetPopup?firewallPolicyId=" + this.firewallPolicyId + "&groupId=" + groupId + "&type=" + this.type, {
width: "50em", width: "50em",
height: "30em", height: "40em",
callback: function () { callback: function () {
teaweb.success("保存成功", function () { teaweb.success("保存成功", function () {
window.location.reload() window.location.reload()
@@ -47,7 +47,7 @@ Tea.context(function () {
this.updateSet = function (setId) { this.updateSet = function (setId) {
teaweb.popup("/servers/components/waf/updateSetPopup?firewallPolicyId=" + this.firewallPolicyId + "&groupId=" + this.group.id + "&type=" + this.type + "&setId=" + setId, { teaweb.popup("/servers/components/waf/updateSetPopup?firewallPolicyId=" + this.firewallPolicyId + "&groupId=" + this.group.id + "&type=" + this.type + "&setId=" + setId, {
width: "50em", width: "50em",
height: "30em", height: "40em",
callback: function () { callback: function () {
teaweb.success("保存成功", function () { teaweb.success("保存成功", function () {
window.location.reload() window.location.reload()

View File

@@ -35,7 +35,7 @@ Tea.context(function () {
this.createSet = function (groupId) { this.createSet = function (groupId) {
teaweb.popup("/servers/components/waf/createSetPopup?firewallPolicyId=" + this.firewallPolicyId + "&groupId=" + groupId + "&type=" + this.type, { teaweb.popup("/servers/components/waf/createSetPopup?firewallPolicyId=" + this.firewallPolicyId + "&groupId=" + groupId + "&type=" + this.type, {
width: "50em", width: "50em",
height: "30em", height: "40em",
callback: function () { callback: function () {
teaweb.success("保存成功", function () { teaweb.success("保存成功", function () {
window.location.reload() window.location.reload()
@@ -48,7 +48,7 @@ Tea.context(function () {
this.updateSet = function (setId) { this.updateSet = function (setId) {
teaweb.popup("/servers/components/waf/updateSetPopup?firewallPolicyId=" + this.firewallPolicyId + "&groupId=" + this.group.id + "&type=" + this.type + "&setId=" + setId, { teaweb.popup("/servers/components/waf/updateSetPopup?firewallPolicyId=" + this.firewallPolicyId + "&groupId=" + this.group.id + "&type=" + this.type + "&setId=" + setId, {
width: "50em", width: "50em",
height: "30em", height: "40em",
callback: function () { callback: function () {
teaweb.success("保存成功", function () { teaweb.success("保存成功", function () {
window.location.reload() window.location.reload()

View File

@@ -35,7 +35,7 @@ Tea.context(function () {
this.createSet = function (groupId) { this.createSet = function (groupId) {
teaweb.popup("/servers/components/waf/createSetPopup?firewallPolicyId=" + this.firewallPolicyId + "&groupId=" + groupId + "&type=" + this.type, { teaweb.popup("/servers/components/waf/createSetPopup?firewallPolicyId=" + this.firewallPolicyId + "&groupId=" + groupId + "&type=" + this.type, {
width: "50em", width: "50em",
height: "30em", height: "40em",
callback: function () { callback: function () {
teaweb.success("保存成功", function () { teaweb.success("保存成功", function () {
window.location.reload() window.location.reload()
@@ -48,7 +48,7 @@ Tea.context(function () {
this.updateSet = function (setId) { this.updateSet = function (setId) {
teaweb.popup("/servers/components/waf/updateSetPopup?firewallPolicyId=" + this.firewallPolicyId + "&groupId=" + this.group.id + "&type=" + this.type + "&setId=" + setId, { teaweb.popup("/servers/components/waf/updateSetPopup?firewallPolicyId=" + this.firewallPolicyId + "&groupId=" + this.group.id + "&type=" + this.type + "&setId=" + setId, {
width: "50em", width: "50em",
height: "30em", height: "40em",
callback: function () { callback: function () {
teaweb.success("保存成功", function () { teaweb.success("保存成功", function () {
window.location.reload() window.location.reload()