From 8106c483421827318ac14e45216ea5ff452da664 Mon Sep 17 00:00:00 2001 From: GoEdgeLab Date: Fri, 10 Mar 2023 10:34:50 +0800 Subject: [PATCH] =?UTF-8?q?WAF=20cc=E9=98=B2=E6=8A=A4=E5=A2=9E=E5=8A=A0?= =?UTF-8?q?=E2=80=9C=E6=A3=80=E6=9F=A5=E8=AF=B7=E6=B1=82=E6=9D=A5=E6=BA=90?= =?UTF-8?q?=E6=8C=87=E7=BA=B9=E2=80=9D=E9=80=89=E9=A1=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- web/public/js/components.js | 145 ++++++-- web/public/js/components.src.js | 326 ++++++++++++++++-- .../components/server/http-firewall-rules.js | 24 ++ 3 files changed, 436 insertions(+), 59 deletions(-) diff --git a/web/public/js/components.js b/web/public/js/components.js index 837f9af4..c98e4b40 100644 --- a/web/public/js/components.js +++ b/web/public/js/components.js @@ -1935,7 +1935,7 @@ Vue.component("traffic-map-box",{props:["v-stats","v-is-attack"],mounted:functio -`}),Vue.component("http-firewall-config-box",{props:["v-firewall-config","v-is-location","v-is-group","v-firewall-policy"],data:function(){let e=this.vFirewallConfig;return{firewall:e=null==e?{isPrior:!1,isOn:!1,firewallPolicyId:0,ignoreGlobalRules:!1}:e,moreOptionsVisible:!1}},methods:{changeOptionsVisible:function(e){this.moreOptionsVisible=e}},template:`
+
`}),Vue.component("http-firewall-config-box",{props:["v-firewall-config","v-is-location","v-is-group","v-firewall-policy"],data:function(){let e=this.vFirewallConfig;return{firewall:e=null==e?{isPrior:!1,isOn:!1,firewallPolicyId:0,ignoreGlobalRules:!1}:e,moreOptionsVisible:!1,execGlobalRules:!e.ignoreGlobalRules}},watch:{execGlobalRules:function(e){this.firewall.ignoreGlobalRules=!e}},methods:{changeOptionsVisible:function(e){this.moreOptionsVisible=e}},template:`
@@ -1957,17 +1957,17 @@ Vue.component("traffic-map-box",{props:["v-stats","v-is-attack"],mounted:functio - + @@ -2095,7 +2095,7 @@ Vue.component("traffic-map-box",{props:["v-stats","v-is-attack"],mounted:functio
启用WAF -

启用WAF之后,各项WAF设置才会生效。

+

选中后,表示启用当前网站服务的WAF功能。

不使用全局规则启用系统全局规则 - -

选中后,表示不使用系统全局WAF策略中定义的规则。

+ +

选中后,表示使用系统全局WAF策略中定义的规则。

-
`}),Vue.component("http-firewall-checkpoint-cc",{props:["v-checkpoint"],data:function(){let e=[],t=60,i=1e3,n=!1,s={},o=(null==(s=null!=window.parent.UPDATING_RULE?window.parent.UPDATING_RULE.checkpointOptions:s)&&(s={}),0==(e=null!=s.keys?s.keys:e).length&&(e=["${remoteAddr}","${requestPath}"]),null!=s.period&&(t=s.period),null!=s.threshold&&(i=s.threshold),null!=s.ignoreCommonFiles&&"boolean"==typeof s.ignoreCommonFiles&&(n=s.ignoreCommonFiles),this);return setTimeout(function(){o.change()},100),{keys:e,period:t,threshold:i,ignoreCommonFiles:n,options:{},value:i}},watch:{period:function(){this.change()},threshold:function(){this.change()},ignoreCommonFiles:function(){this.change()}},methods:{changeKeys:function(e){this.keys=e,this.change()},change:function(){let e=parseInt(this.period.toString()),t=((isNaN(e)||e<=0)&&(e=60),parseInt(this.threshold.toString())),i=((isNaN(t)||t<=0)&&(t=1e3),this.value=t,this.ignoreCommonFiles);"boolean"!=typeof i&&(i=!1),this.vCheckpoint.options=[{code:"keys",value:this.keys},{code:"period",value:e},{code:"threshold",value:t},{code:"ignoreCommonFiles",value:i}]},thresholdTooLow:function(){let e=parseInt(this.threshold.toString());return 0<(e=isNaN(e)||e<=0?1e3:e)&&e<5}},template:`
+
`}),Vue.component("http-firewall-checkpoint-cc",{props:["v-checkpoint"],data:function(){let e=[],t=60,i=1e3,n=!1,s=!0,o={},a=(null==(o=null!=window.parent.UPDATING_RULE?window.parent.UPDATING_RULE.checkpointOptions:o)&&(o={}),0==(e=null!=o.keys?o.keys:e).length&&(e=["${remoteAddr}","${requestPath}"]),null!=o.period&&(t=o.period),null!=o.threshold&&(i=o.threshold),null!=o.ignoreCommonFiles&&"boolean"==typeof o.ignoreCommonFiles&&(n=o.ignoreCommonFiles),null!=o.enableFingerprint&&"boolean"==typeof o.enableFingerprint&&(s=o.enableFingerprint),this);return setTimeout(function(){a.change()},100),{keys:e,period:t,threshold:i,ignoreCommonFiles:n,enableFingerprint:s,options:{},value:i}},watch:{period:function(){this.change()},threshold:function(){this.change()},ignoreCommonFiles:function(){this.change()},enableFingerprint:function(){this.change()}},methods:{changeKeys:function(e){this.keys=e,this.change()},change:function(){let e=parseInt(this.period.toString()),t=((isNaN(e)||e<=0)&&(e=60),parseInt(this.threshold.toString())),i=((isNaN(t)||t<=0)&&(t=1e3),this.value=t,this.ignoreCommonFiles),n=("boolean"!=typeof i&&(i=!1),this.enableFingerprint);"boolean"!=typeof n&&(n=!0),this.vCheckpoint.options=[{code:"keys",value:this.keys},{code:"period",value:e},{code:"threshold",value:t},{code:"ignoreCommonFiles",value:i},{code:"enableFingerprint",value:n}]},thresholdTooLow:function(){let e=parseInt(this.threshold.toString());return 0<(e=isNaN(e)||e<=0?1e3:e)&&e<5}},template:`
@@ -2121,6 +2121,13 @@ Vue.component("traffic-map-box",{props:["v-stats","v-is-attack"],mounted:functio

对于网站类应用来说,当前阈值设置的太低,有可能会影响用户正常访问。

+ + + +
检查请求来源指纹 + +

在接收到HTTPS请求时尝试检查请求来源的指纹,用来检测代理服务和爬虫攻击。

+
忽略常见文件 @@ -2431,6 +2438,43 @@ Vue.component("traffic-map-box",{props:["v-stats","v-is-attack"],mounted:functio +`}),Vue.component("uam-config-box",{props:["v-uam-config","v-is-location","v-is-group"],data:function(){let e=this.vUamConfig;return null==(e=null==e?{isPrior:!1,isOn:!1,onlyURLPatterns:[],exceptURLPatterns:[]}:e).onlyURLPatterns&&(e.onlyURLPatterns=[]),null==e.exceptURLPatterns&&(e.exceptURLPatterns=[]),{config:e,moreOptionsVisible:!1}},methods:{showMoreOptions:function(){this.moreOptionsVisible=!this.moreOptionsVisible}},template:`
+ + + + + + + + + + + + + + + + + + + + + + + + + +
启用5秒盾 + +

启用后,访问网站时,自动检查浏览器环境,阻止非正常访问。

+
例外URL + +

如果填写了例外URL,表示这些URL跳过5秒盾不做处理。

+
限制URL + +

如果填写了支持URL,表示只对这些URL进行5秒盾处理;如果不填则表示支持所有的URL。

+
+
`}),Vue.component("http-cache-stale-config",{props:["v-cache-stale-config"],data:function(){let e=this.vCacheStaleConfig;return{config:e=null==e?{isPrior:!1,isOn:!1,status:[],supportStaleIfErrorHeader:!0,life:{count:1,unit:"day"}}:e}},watch:{config:{deep:!0,handler:function(){this.$emit("change",this.config)}}},methods:{},template:` @@ -3013,21 +3057,6 @@ example2.com
`}),Vue.component("user-selector",{props:["v-user-id","data-url"],data:function(){let e=this.vUserId,t=(null==e&&(e=0),this.dataUrl);return null!=t&&0!=t.length||(t="/servers/users/options"),{users:[],userId:e,dataURL:t}},methods:{change:function(e){null!=e?this.$emit("change",e.id):this.$emit("change",0)}},template:`
-
`}),Vue.component("uam-config-box",{props:["v-uam-config","v-is-location","v-is-group"],data:function(){let e=this.vUamConfig;return{config:e=null==e?{isPrior:!1,isOn:!1}:e}},template:`
- -
- - - - - - - -
启用5秒盾 - -

启用后,访问网站时,自动检查浏览器环境,阻止非正常访问。

-
-
`}),Vue.component("http-header-policy-box",{props:["v-request-header-policy","v-request-header-ref","v-response-header-policy","v-response-header-ref","v-params","v-is-location","v-is-group","v-has-group-request-config","v-has-group-response-config","v-group-setting-url"],data:function(){let e="response";"#request"==window.location.hash&&(e="request");let t=this.vRequestHeaderRef,i=(null==t&&(t={isPrior:!1,isOn:!0,headerPolicyId:0}),this.vResponseHeaderRef),n=(null==i&&(i={isPrior:!1,isOn:!0,headerPolicyId:0}),[]),s=[];var o=this.vRequestHeaderPolicy;null!=o&&(null!=o.setHeaders&&(n=o.setHeaders),null!=o.deleteHeaders&&(s=o.deleteHeaders));let a=[],l=[];o=this.vResponseHeaderPolicy;null!=o&&(null!=o.setHeaders&&(a=o.setHeaders),null!=o.deleteHeaders&&(l=o.deleteHeaders));let c={isOn:!1};return null!=o.cors&&(c=o.cors),{type:e,typeName:"request"==e?"请求":"响应",requestHeaderRef:t,responseHeaderRef:i,requestSettingHeaders:n,requestDeletingHeaders:s,responseSettingHeaders:a,responseDeletingHeaders:l,responseCORS:c}},methods:{selectType:function(e){this.type=e,window.location.hash="#"+e,window.location.reload()},addSettingHeader:function(e){teaweb.popup("/servers/server/settings/headers/createSetPopup?"+this.vParams+"&headerPolicyId="+e+"&type="+this.type,{callback:function(){teaweb.successRefresh("保存成功")}})},addDeletingHeader:function(e,t){teaweb.popup("/servers/server/settings/headers/createDeletePopup?"+this.vParams+"&headerPolicyId="+e+"&type="+t,{callback:function(){teaweb.successRefresh("保存成功")}})},updateSettingPopup:function(e,t){teaweb.popup("/servers/server/settings/headers/updateSetPopup?"+this.vParams+"&headerPolicyId="+e+"&headerId="+t+"&type="+this.type,{callback:function(){teaweb.successRefresh("保存成功")}})},deleteDeletingHeader:function(e,t){teaweb.confirm("确定要删除'"+t+"'吗?",function(){Tea.action("/servers/server/settings/headers/deleteDeletingHeader").params({headerPolicyId:e,headerName:t}).post().refresh()})},deleteHeader:function(e,t,i){teaweb.confirm("确定要删除此Header吗?",function(){this.$post("/servers/server/settings/headers/delete").params({headerPolicyId:e,type:t,headerId:i}).refresh()})},updateCORS:function(e){teaweb.popup("/servers/server/settings/headers/updateCORSPopup?"+this.vParams+"&headerPolicyId="+e+"&type="+this.type,{callback:function(){teaweb.successRefresh("保存成功")}})}},template:`
+
`}),Vue.component("http-cc-config-box",{props:["v-cc-config","v-is-location","v-is-group"],data:function(){let e=this.vCcConfig;return null==(e=null==e?{isPrior:!1,isOn:!1,onlyURLPatterns:[],exceptURLPatterns:[]}:e).onlyURLPatterns&&(e.onlyURLPatterns=[]),null==e.exceptURLPatterns&&(e.exceptURLPatterns=[]),{config:e,moreOptionsVisible:!1}},methods:{showMoreOptions:function(){this.moreOptionsVisible=!this.moreOptionsVisible}},template:`
+ + + + + + + + + + + + + + + + + + + + + + + + + +
启用CC无感防护 + +

启用后,自动检测并拦截CC攻击,此功能不需要开启WAF功能。

+
例外URL + +

如果填写了例外URL,表示这些URL跳过CC防护不做处理。

+
限制URL + +

如果填写了支持URL,表示只对这些URL进行CC防护处理;如果不填则表示支持所有的URL。

+
+
`}),Vue.component("firewall-event-level-options",{props:["v-value"],mounted:function(){let t=this;Tea.action("/ui/eventLevelOptions").post().success(function(e){t.levels=e.data.eventLevels,t.change()})},data:function(){let e=this.vValue;return{levels:[],description:"",level:e=null!=e&&0!=e.length?e:""}},methods:{change:function(){this.$emit("change");let i=this;var e=this.levels.$find(function(e,t){return t.code==i.level});this.description=null!=e?e.description:""}},template:`
+ + + +
+
+ +
+
+ + +
+
+ +
+ + +
+ +
`}),Vue.component("size-capacity-view",{props:["v-default-text","v-value"],template:`
{{vValue.count}}{{vValue.unit.toUpperCase()}} {{vDefaultText}} diff --git a/web/public/js/components.src.js b/web/public/js/components.src.js index e9c9bcbd..ce54daad 100755 --- a/web/public/js/components.src.js +++ b/web/public/js/components.src.js @@ -5239,7 +5239,13 @@ Vue.component("http-firewall-config-box", { return { firewall: firewall, - moreOptionsVisible: false + moreOptionsVisible: false, + execGlobalRules: !firewall.ignoreGlobalRules + } + }, + watch: { + execGlobalRules: function (v) { + this.firewall.ignoreGlobalRules = !v } }, methods: { @@ -5269,17 +5275,17 @@ Vue.component("http-firewall-config-box", { 启用WAF -

启用WAF之后,各项WAF设置才会生效。

+

选中后,表示启用当前网站服务的WAF功能。

- 不使用全局规则 + 启用系统全局规则 - -

选中后,表示不使用系统全局WAF策略中定义的规则。

+ +

选中后,表示使用系统全局WAF策略中定义的规则。

@@ -5960,6 +5966,7 @@ Vue.component("http-firewall-checkpoint-cc", { let period = 60 let threshold = 1000 let ignoreCommonFiles = false + let enableFingerprint = true let options = {} if (window.parent.UPDATING_RULE != null) { @@ -5984,6 +5991,9 @@ Vue.component("http-firewall-checkpoint-cc", { if (options.ignoreCommonFiles != null && typeof (options.ignoreCommonFiles) == "boolean") { ignoreCommonFiles = options.ignoreCommonFiles } + if (options.enableFingerprint != null && typeof (options.enableFingerprint) == "boolean") { + enableFingerprint = options.enableFingerprint + } let that = this setTimeout(function () { @@ -5995,6 +6005,7 @@ Vue.component("http-firewall-checkpoint-cc", { period: period, threshold: threshold, ignoreCommonFiles: ignoreCommonFiles, + enableFingerprint: enableFingerprint, options: {}, value: threshold } @@ -6008,6 +6019,9 @@ Vue.component("http-firewall-checkpoint-cc", { }, ignoreCommonFiles: function () { this.change() + }, + enableFingerprint: function () { + this.change() } }, methods: { @@ -6032,6 +6046,11 @@ Vue.component("http-firewall-checkpoint-cc", { ignoreCommonFiles = false } + let enableFingerprint = this.enableFingerprint + if (typeof enableFingerprint != "boolean") { + enableFingerprint = true + } + this.vCheckpoint.options = [ { code: "keys", @@ -6048,6 +6067,10 @@ Vue.component("http-firewall-checkpoint-cc", { { code: "ignoreCommonFiles", value: ignoreCommonFiles + }, + { + code: "enableFingerprint", + value: enableFingerprint } ] }, @@ -6085,6 +6108,13 @@ Vue.component("http-firewall-checkpoint-cc", {

对于网站类应用来说,当前阈值设置的太低,有可能会影响用户正常访问。

+ + 检查请求来源指纹 + + +

在接收到HTTPS请求时尝试检查请求来源的指纹,用来检测代理服务和爬虫攻击。

+ + 忽略常见文件 @@ -7094,6 +7124,75 @@ Vue.component("server-name-box", {
` }) +// UAM模式配置 +Vue.component("uam-config-box", { + props: ["v-uam-config", "v-is-location", "v-is-group"], + data: function () { + let config = this.vUamConfig + if (config == null) { + config = { + isPrior: false, + isOn: false, + onlyURLPatterns: [], + exceptURLPatterns: [] + } + } + if (config.onlyURLPatterns == null) { + config.onlyURLPatterns = [] + } + if (config.exceptURLPatterns == null) { + config.exceptURLPatterns = [] + } + return { + config: config, + moreOptionsVisible: false + } + }, + methods: { + showMoreOptions: function () { + this.moreOptionsVisible = !this.moreOptionsVisible + } + }, + template: `
+ + + + + + + + + + + + + + + + + + + + + + + + + +
启用5秒盾 + +

启用后,访问网站时,自动检查浏览器环境,阻止非正常访问。

+
例外URL + +

如果填写了例外URL,表示这些URL跳过5秒盾不做处理。

+
限制URL + +

如果填写了支持URL,表示只对这些URL进行5秒盾处理;如果不填则表示支持所有的URL。

+
+
+
` +}) + Vue.component("http-cache-stale-config", { props: ["v-cache-stale-config"], data: function () { @@ -8720,39 +8819,6 @@ Vue.component("user-selector", { ` }) -// UAM模式配置 -Vue.component("uam-config-box", { - props: ["v-uam-config", "v-is-location", "v-is-group"], - data: function () { - let config = this.vUamConfig - if (config == null) { - config = { - isPrior: false, - isOn: false - } - } - return { - config: config - } - }, - template: `
- - - - - - - - - -
启用5秒盾 - -

启用后,访问网站时,自动检查浏览器环境,阻止非正常访问。

-
-
-
` -}) - Vue.component("http-header-policy-box", { props: ["v-request-header-policy", "v-request-header-ref", "v-response-header-policy", "v-response-header-ref", "v-params", "v-is-location", "v-is-group", "v-has-group-request-config", "v-has-group-response-config", "v-group-setting-url"], data: function () { @@ -9551,6 +9617,75 @@ Vue.component("http-compression-config-box", { ` }) +// HTTP CC防护配置 +Vue.component("http-cc-config-box", { + props: ["v-cc-config", "v-is-location", "v-is-group"], + data: function () { + let config = this.vCcConfig + if (config == null) { + config = { + isPrior: false, + isOn: false, + onlyURLPatterns: [], + exceptURLPatterns: [] + } + } + if (config.onlyURLPatterns == null) { + config.onlyURLPatterns = [] + } + if (config.exceptURLPatterns == null) { + config.exceptURLPatterns = [] + } + return { + config: config, + moreOptionsVisible: false + } + }, + methods: { + showMoreOptions: function () { + this.moreOptionsVisible = !this.moreOptionsVisible + } + }, + template: `
+ + + + + + + + + + + + + + + + + + + + + + + + + +
启用CC无感防护 + +

启用后,自动检测并拦截CC攻击,此功能不需要开启WAF功能。

+
例外URL + +

如果填写了例外URL,表示这些URL跳过CC防护不做处理。

+
限制URL + +

如果填写了支持URL,表示只对这些URL进行CC防护处理;如果不填则表示支持所有的URL。

+
+
+
` +}) + Vue.component("firewall-event-level-options", { props: ["v-value"], mounted: function () { @@ -10536,6 +10671,12 @@ Vue.component("http-location-labels", { 源站 + + 5秒盾 + + + CC防护 + @@ -16283,6 +16424,115 @@ Vue.component("network-addresses-view", { ` }) +Vue.component("url-patterns-box", { + props: ["value"], + data: function () { + let patterns = [] + if (this.value != null) { + patterns = this.value + } + return { + patterns: patterns, + isAdding: false, + + addingPattern: {"type": "wildcard", "pattern": ""}, + editingIndex: -1 + } + }, + methods: { + add: function () { + this.isAdding = true + let that = this + setTimeout(function () { + that.$refs.patternInput.focus() + }) + }, + edit: function (index) { + this.isAdding = true + this.editingIndex = index + this.addingPattern = { + type: this.patterns[index].type, + pattern: this.patterns[index].pattern + } + }, + confirm: function () { + let pattern = this.addingPattern.pattern.trim() + if (pattern.length == 0) { + let that = this + teaweb.warn("请输入URL", function () { + that.$refs.patternInput.focus() + }) + return + } + if (this.editingIndex < 0) { + this.patterns.push({ + type: this.addingPattern.type, + pattern: this.addingPattern.pattern + }) + } else { + this.patterns[this.editingIndex].type = this.addingPattern.type + this.patterns[this.editingIndex].pattern = this.addingPattern.pattern + } + this.notifyChange() + this.cancel() + }, + remove: function (index) { + this.patterns.$remove(index) + this.cancel() + this.notifyChange() + }, + cancel: function () { + this.isAdding = false + this.addingPattern = {"type": "wildcard", "pattern": ""} + this.editingIndex = -1 + }, + patternTypeName: function (patternType) { + switch (patternType) { + case "wildcard": + return "通配符" + case "regexp": + return "正则" + } + return "" + }, + notifyChange: function () { + this.$emit("input", this.patterns) + } + }, + template: `
+
+
+ [{{patternTypeName(pattern.type)}}] {{pattern.pattern}}   + + +
+
+
+
+
+ +
+
+ +
+
+ + +
+
+ +
+
+
+
+ +
+
` +}) + Vue.component("size-capacity-view", { props:["v-default-text", "v-value"], template: `
diff --git a/web/public/js/components/server/http-firewall-rules.js b/web/public/js/components/server/http-firewall-rules.js index 13eb7708..fc10a906 100644 --- a/web/public/js/components/server/http-firewall-rules.js +++ b/web/public/js/components/server/http-firewall-rules.js @@ -93,6 +93,7 @@ Vue.component("http-firewall-checkpoint-cc", { let period = 60 let threshold = 1000 let ignoreCommonFiles = false + let enableFingerprint = true let options = {} if (window.parent.UPDATING_RULE != null) { @@ -117,6 +118,9 @@ Vue.component("http-firewall-checkpoint-cc", { if (options.ignoreCommonFiles != null && typeof (options.ignoreCommonFiles) == "boolean") { ignoreCommonFiles = options.ignoreCommonFiles } + if (options.enableFingerprint != null && typeof (options.enableFingerprint) == "boolean") { + enableFingerprint = options.enableFingerprint + } let that = this setTimeout(function () { @@ -128,6 +132,7 @@ Vue.component("http-firewall-checkpoint-cc", { period: period, threshold: threshold, ignoreCommonFiles: ignoreCommonFiles, + enableFingerprint: enableFingerprint, options: {}, value: threshold } @@ -141,6 +146,9 @@ Vue.component("http-firewall-checkpoint-cc", { }, ignoreCommonFiles: function () { this.change() + }, + enableFingerprint: function () { + this.change() } }, methods: { @@ -165,6 +173,11 @@ Vue.component("http-firewall-checkpoint-cc", { ignoreCommonFiles = false } + let enableFingerprint = this.enableFingerprint + if (typeof enableFingerprint != "boolean") { + enableFingerprint = true + } + this.vCheckpoint.options = [ { code: "keys", @@ -181,6 +194,10 @@ Vue.component("http-firewall-checkpoint-cc", { { code: "ignoreCommonFiles", value: ignoreCommonFiles + }, + { + code: "enableFingerprint", + value: enableFingerprint } ] }, @@ -218,6 +235,13 @@ Vue.component("http-firewall-checkpoint-cc", {

对于网站类应用来说,当前阈值设置的太低,有可能会影响用户正常访问。

+ + 检查请求来源指纹 + + +

在接收到HTTPS请求时尝试检查请求来源的指纹,用来检测代理服务和爬虫攻击。

+ + 忽略常见文件