OP防火墙-0.2.3
This commit is contained in:
parent
d5f3b0d442
commit
4e05f29fcd
|
|
@ -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)
|
||||
|
||||
|
|
|
|||
|
|
@ -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"]
|
||||
}
|
||||
|
|
@ -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: '<div class="pd15">\
|
||||
<div style="border-bottom:#ccc 1px solid;margin-bottom:10px;padding-bottom:10px">\
|
||||
<input class="bt-input-text" name="ruleValue" type="text" value="" style="width:470px;margin-right:12px;" placeholder="规则内容,请使用正则表达式">\
|
||||
<input class="bt-input-text mr5" name="rulePs" type="text" style="width:120px;" placeholder="描述">\
|
||||
<button class="btn btn-success btn-sm va0 pull-right" onclick="addRule(\''+ ruleName + '\');">添加</button>\</div>\
|
||||
<div class="divtable">\
|
||||
<div id="jc-file-table" class="table_head_fix" style="max-height:300px;overflow:auto;border:#ddd 1px solid">\
|
||||
<table class="table table-hover" style="border:none">\
|
||||
<thead>\
|
||||
<tr>\
|
||||
<th width="360">规则</th>\
|
||||
<th>说明</th>\
|
||||
<th>操作</th>\
|
||||
<th style="text-align: right;">状态</th>\
|
||||
</tr>\
|
||||
</thead>\
|
||||
<tbody id="set_obj_conf_con" class="gztr"></tbody>\
|
||||
</table>\
|
||||
</div>\
|
||||
</div>\
|
||||
<ul class="help-info-text c7 ptb10">\
|
||||
<li style="color:red;">注意:如果您不了解正则表达式,请不要随意修改规则内容</li>\
|
||||
<li>您可以添加或修改规则内容,但请使用正则表达式</li>\
|
||||
<li>内置规则允许修改,但不可以直接删除,您可以设置规则状态来定义防火墙是否使用此规则</li>\
|
||||
</ul></div>'
|
||||
});
|
||||
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 = ' | <a class="btlink" onclick="removeRule(\'' + ruleName + '\',' + i + ')">删除</a>';
|
||||
tbody += '<tr>\
|
||||
<td class="rule_body_'+ i + '">' + rdata[i][1] + '</td>\
|
||||
<td class="rule_ps_'+ i + '">' + rdata[i][2] + '</td>\
|
||||
<td class="rule_modify_'+ i + '"><a class="btlink" onclick="modifyRule(' + i + ',\'' + ruleName + '\')">编辑</a>' + removeRule + '</td>\
|
||||
<td class="text-right">\
|
||||
<div class="pull-right">\
|
||||
<input class="btswitch btswitch-ios" id="closeua_'+ i + '" type="checkbox" ' + (rdata[i][0] ? 'checked' : '') + '>\
|
||||
<label class="btswitch-btn" style="width:2.0em;height:1.2em;margin-bottom: 0" for="closeua_'+ i + '" onclick="setRuleState(\'' + ruleName + '\',' + i + ')"></label>\
|
||||
</div>\
|
||||
</td>\
|
||||
</tr>'
|
||||
}
|
||||
$("#set_obj_conf_con").html(tbody);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
// 获取IPV4黑名单
|
||||
function getIpv4Address(callback){
|
||||
|
|
@ -1004,6 +1069,11 @@ function wafGloabl(){
|
|||
</div></td><td class="text-right"><a class="btlink" onclick="scanRule()">设置</a></td>\
|
||||
</tr>\
|
||||
<tr>\
|
||||
<td>URL白名单</td><td>所有规则对URL白名单无效</td><td style="text-align: center;">--</td>\
|
||||
<td style="text-align: center;">--</td>\
|
||||
<td class="text-right"><a class="btlink" onclick="urlWhite()">设置</a></td>\
|
||||
</tr>\
|
||||
<tr>\
|
||||
<td>IP白名单</td><td>所有规则对IP白名单无效</td><td style="text-align: center;">--</td>\
|
||||
<td style="text-align: center;">--</td>\
|
||||
<td class="text-right"><a class="btlink" onclick="ipWhite()">设置</a></td>\
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1 @@
|
|||
[[1,"^/phpmyadmin_","MySQL[phpMyAdmin]", 0]]
|
||||
Loading…
Reference in New Issue