pull/216/head
midoks 3 years ago
parent b3fef4c104
commit 897c28034d
  1. 4
      plugins/op_waf/index.py
  2. 4
      plugins/op_waf/t/index.py
  3. 12
      plugins/op_waf/waf/lua/common.lua
  4. 23
      plugins/op_waf/waf/lua/init.lua

@ -258,7 +258,7 @@ def autoMakeLuaConf():
for x in conf_list: for x in conf_list:
autoMakeLuaConfSingle(x) autoMakeLuaConfSingle(x)
import_list = ['config', 'site'] import_list = ['config', 'site', 'domains']
for x in import_list: for x in import_list:
autoMakeLuaImportSingle(x) autoMakeLuaImportSingle(x)
@ -772,7 +772,7 @@ def setSiteRetry():
def setCcConf(): def setCcConf():
args = getArgs() args = getArgs()
data = checkArgs(args, ['siteName', 'cycle', 'limit', data = checkArgs(args, ['siteName', 'cycle', 'limit',
'endtime', 'is_open_global', 'increase']) 'endtime', 'is_open_global'])
if not data[0]: if not data[0]:
return data[1] return data[1]

@ -197,9 +197,9 @@ def test_OK():
def test_start(): def test_start():
# test_OK() test_OK()
# test_Dir() # test_Dir()
test_UA() # test_UA()
# test_POST() # test_POST()
# test_scan() # test_scan()
# test_CC() # test_CC()

@ -500,11 +500,13 @@ end
function _M.write_log(self, name, rule) function _M.write_log(self, name, rule)
local config = self.config
local ip = self.params['ip'] local ip = self.params['ip']
local retry = self.config['retry']['retry']
local retry_time = self.config['retry']['retry_time'] local retry = config['retry']['retry']
local retry_cycle = self.config['retry']['retry_cycle'] local retry_time = config['retry']['retry_time']
local retry_cycle = config['retry']['retry_cycle']
local count, _ = ngx.shared.drop_ip:get(ip) local count, _ = ngx.shared.drop_ip:get(ip)
if count then if count then
@ -513,8 +515,8 @@ function _M.write_log(self, name, rule)
ngx.shared.drop_ip:set(ip,1,retry_cycle) ngx.shared.drop_ip:set(ip,1,retry_cycle)
end end
if self.config['log'] ~= true or self:is_site_config('log') ~= true then return false end if config['log'] ~= true or self:is_site_config('log') ~= true then return false end
local method = ngx.req.get_method() local method = self.params['method']
if error_rule then if error_rule then
rule = error_rule rule = error_rule
error_rule = nil error_rule = nil

@ -27,7 +27,26 @@ local user_agent_rules = require "rule_user_agent"
local post_rules = require "rule_post" local post_rules = require "rule_post"
local cookie_rules = require "rule_cookie" local cookie_rules = require "rule_cookie"
local server_name = string.gsub(C:get_server_name(),'_','.')
function get_server_name()
local request_name = ngx.var.server_name
-- local my_name = ngx.shared.limit:get(c_name)
-- if my_name then return my_name end
local config_domains = require "domains"
for _,v in ipairs(config_domains)
do
for _,cd_name in ipairs(v['domains'])
do
if request_name == cd_name then
-- ngx.shared.limit:set(c_name,v['name'],3600)
return v['name']
end
end
end
return request_name
end
local server_name = string.gsub(get_server_name(),'_','.')
local function initParams() local function initParams()
local data = {} local data = {}
@ -161,7 +180,7 @@ end
local function waf_get_args() local function waf_get_args()
if not config['get']['open'] or not C:is_site_config('get') then return false end if not config['get']['open'] or not C:is_site_config('get') then return false end
if C:is_ngx_match(args_rules, params['uri_request_args'],'args') then if C:ngx_match_list(args_rules, params['uri_request_args']) then
C:write_log('args','regular') C:write_log('args','regular')
C:return_html(config['get']['status'], get_html) C:return_html(config['get']['status'], get_html)
return true return true

Loading…
Cancel
Save