[style] Update format
parent
ae2e365496
commit
7b238357ae
38
init.lua
38
init.lua
|
@ -119,8 +119,8 @@ function cookie_attack_check()
|
|||
return true
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
@ -149,14 +149,14 @@ function url_args_attack_check()
|
|||
local ARGS_RULES = get_rule('args')
|
||||
for _,rule in pairs(ARGS_RULES) do
|
||||
--local REQ_ARGS = ngx.req.get_uri_args()
|
||||
local REQ_ARGS, err = ngx.req.get_uri_args()
|
||||
if err == "truncated" then
|
||||
log_record("Deny_URL_Args_Many",ngx.var.request_uri,"-",rule)
|
||||
if config_waf_enable == "on" then
|
||||
waf_output()
|
||||
return true
|
||||
end
|
||||
end
|
||||
local REQ_ARGS, err = ngx.req.get_uri_args()
|
||||
if err == "truncated" then
|
||||
log_record("Deny_URL_Args_Many",ngx.var.request_uri,"-",rule)
|
||||
if config_waf_enable == "on" then
|
||||
waf_output()
|
||||
return true
|
||||
end
|
||||
end
|
||||
for key, val in pairs(REQ_ARGS) do
|
||||
if type(val) == "table" then
|
||||
ARGS_DATA = string.lower(table.concat(val, " "))
|
||||
|
@ -204,14 +204,14 @@ function post_attack_check()
|
|||
local POST_RULES = get_rule("post")
|
||||
for _,rule in pairs(POST_RULES) do
|
||||
-- local REQ_POST = ngx.req.get_post_args()
|
||||
local REQ_POST, err = ngx.req.get_post_args()
|
||||
if err == "truncated" then
|
||||
log_record("Deny_POST_Many",ngx.var.request_uri,"-",rule)
|
||||
if config_waf_enable == "on" then
|
||||
waf_output()
|
||||
return true
|
||||
end
|
||||
end
|
||||
local REQ_POST, err = ngx.req.get_post_args()
|
||||
if err == "truncated" then
|
||||
log_record("Deny_POST_Many",ngx.var.request_uri,"-",rule)
|
||||
if config_waf_enable == "on" then
|
||||
waf_output()
|
||||
return true
|
||||
end
|
||||
end
|
||||
for key, val in pairs(REQ_POST) do
|
||||
if type(val) == "table" then
|
||||
POST_DATA = string.lower(table.concat(val, " "))
|
||||
|
@ -232,4 +232,4 @@ function post_attack_check()
|
|||
return true
|
||||
end
|
||||
return false
|
||||
end
|
||||
end
|
26
lib.lua
26
lib.lua
|
@ -51,15 +51,15 @@ function log_record(method,url,data,ruletag)
|
|||
local SERVER_NAME = ngx.var.host
|
||||
local LOCAL_TIME = ngx.localtime()
|
||||
local log_json_obj = {
|
||||
client_ip = CLIENT_IP,
|
||||
local_time = LOCAL_TIME,
|
||||
server_name = SERVER_NAME,
|
||||
req_url = url,
|
||||
attack_method = method,
|
||||
req_data = data,
|
||||
rule_tag = ruletag,
|
||||
user_agent = USER_AGENT,
|
||||
}
|
||||
client_ip = CLIENT_IP,
|
||||
local_time = LOCAL_TIME,
|
||||
server_name = SERVER_NAME,
|
||||
req_url = url,
|
||||
attack_method = method,
|
||||
req_data = data,
|
||||
rule_tag = ruletag,
|
||||
user_agent = USER_AGENT,
|
||||
}
|
||||
local LOG_LINE = cjson.encode(log_json_obj)
|
||||
local LOG_NAME = LOG_PATH..'/'..ngx.today().."_sec.log"
|
||||
local file = io.open(LOG_NAME,"a")
|
||||
|
@ -79,9 +79,9 @@ function test_log_record(data)
|
|||
local CLIENT_IP = get_client_ip()
|
||||
local LOCAL_TIME = ngx.localtime()
|
||||
local log_json_obj = {
|
||||
client_ip = CLIENT_IP,
|
||||
req_data = data,
|
||||
}
|
||||
client_ip = CLIENT_IP,
|
||||
req_data = data,
|
||||
}
|
||||
local LOG_LINE = cjson.encode(log_json_obj)
|
||||
local LOG_NAME = LOG_PATH..'/'.."test.log"
|
||||
local file = io.open(LOG_NAME,"a")
|
||||
|
@ -103,4 +103,4 @@ function waf_output()
|
|||
ngx.say(config_output_html)
|
||||
ngx.exit(ngx.status)
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Reference in New Issue