From 4e05f29fcdbfbbf42726125719d2e629e0b659d3 Mon Sep 17 00:00:00 2001 From: midoks Date: Mon, 24 Oct 2022 23:12:45 +0800 Subject: [PATCH] =?UTF-8?q?OP=E9=98=B2=E7=81=AB=E5=A2=99-0.2.3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- plugins/op_waf/index.py | 3 +- plugins/op_waf/info.json | 2 +- plugins/op_waf/js/op_waf.js | 70 ++++++++++++++++++++++++++++++++++ plugins/op_waf/waf/lua/init.lua | 11 ++++++ plugins/op_waf/waf/rule/url_white.json | 1 + 5 files changed, 85 insertions(+), 2 deletions(-) create mode 100755 plugins/op_waf/waf/rule/url_white.json diff --git a/plugins/op_waf/index.py b/plugins/op_waf/index.py index 0ba1fba1e..2075757cc 100755 --- a/plugins/op_waf/index.py +++ b/plugins/op_waf/index.py @@ -253,6 +253,7 @@ def contentReplace(content): def autoMakeLuaConfSingle(file): + # path = getPluginDir() + "/waf/rule/" + file + ".json" path = getServerDir() + "/waf/rule/" + file + ".json" to_path = getServerDir() + "/waf/conf/rule_" + file + ".lua" content = mw.readFile(path) @@ -280,7 +281,7 @@ def autoMakeLuaHtmlSingle(file): def autoMakeLuaConf(): conf_list = ['args', 'cookie', 'ip_black', 'ip_white', 'ipv6_black', 'post', 'scan_black', 'url', - 'user_agent'] + 'url_white', 'user_agent'] for x in conf_list: autoMakeLuaConfSingle(x) diff --git a/plugins/op_waf/info.json b/plugins/op_waf/info.json index dad20c9ee..0eda22edc 100755 --- a/plugins/op_waf/info.json +++ b/plugins/op_waf/info.json @@ -11,5 +11,5 @@ "home":"https://github.com/loveshell/ngx_lua_waf", "date":"2019-04-21", "pid": "1", - "versions": ["0.2.2"] + "versions": ["0.2.3"] } \ No newline at end of file diff --git a/plugins/op_waf/js/op_waf.js b/plugins/op_waf/js/op_waf.js index 606fbff6d..87a853560 100755 --- a/plugins/op_waf/js/op_waf.js +++ b/plugins/op_waf/js/op_waf.js @@ -691,6 +691,71 @@ function ipWhite(type) { }); } +//IP白名单 +function urlWhite(type) { + + var ruleName = "url_white"; + + if (type == undefined) { + create_l = layer.open({ + type: 1, + title: "管理URL白名单", + area: ['700px', '530px'], + closeBtn: 1, + shadeClose: false, + content: '
\ +
\ + \ + \ + \
\ +
\ +
\ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ +
规则说明操作状态
\ +
\ +
\ +
' + }); + tableFixed("jc-file-table"); + } + + getRuleByName(ruleName, function(data){ + var tmp = $.parseJSON(data.data); + var rdata = $.parseJSON(tmp.data); + console.log(rdata); + var tbody = '' + for (var i = 0; i < rdata.length; i++) { + var removeRule = '' + if (rdata[i][3] != 0) removeRule = ' | 删除'; + tbody += '\ + ' + rdata[i][1] + '\ + ' + rdata[i][2] + '\ + 编辑' + removeRule + '\ + \ +
\ + \ + \ +
\ + \ + ' + } + $("#set_obj_conf_con").html(tbody); + }); +} + // 获取IPV4黑名单 function getIpv4Address(callback){ @@ -1004,6 +1069,11 @@ function wafGloabl(){ 设置\ \ \ + URL白名单所有规则对URL白名单无效--\ + --\ + 设置\ + \ + \ IP白名单所有规则对IP白名单无效--\ --\ 设置\ diff --git a/plugins/op_waf/waf/lua/init.lua b/plugins/op_waf/waf/lua/init.lua index 07ee25c49..615f50db9 100644 --- a/plugins/op_waf/waf/lua/init.lua +++ b/plugins/op_waf/waf/lua/init.lua @@ -33,6 +33,7 @@ local user_agent_rules = require "rule_user_agent" local post_rules = require "rule_post" local cookie_rules = require "rule_cookie" local url_rules = require "rule_url" +local url_white_rules = require "rule_url_white" local server_name = string.gsub(C:get_sn(config_domains),'_','.') @@ -181,6 +182,13 @@ local function waf_ip_white() return false end +local function waf_url_white() + if C:ngx_match_list(url_white_rules, params['uri']) then + return true + end + return false +end + local function waf_ip_black() -- ipv4 ip black for _,rule in ipairs(ip_black_rules) @@ -517,6 +525,9 @@ function waf() -- white ip if waf_ip_white() then return true end + -- url white + if waf_url_white() then return true end + -- black ip if waf_ip_black() then return true end diff --git a/plugins/op_waf/waf/rule/url_white.json b/plugins/op_waf/waf/rule/url_white.json new file mode 100755 index 000000000..f5795c418 --- /dev/null +++ b/plugins/op_waf/waf/rule/url_white.json @@ -0,0 +1 @@ +[[1,"^/phpmyadmin_","MySQL[phpMyAdmin]", 0]] \ No newline at end of file