Skip to content

Commit

Permalink
rename to wizwaf
Browse files Browse the repository at this point in the history
  • Loading branch information
hevienz committed Aug 11, 2015
1 parent 023b1f5 commit 40d0457
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
6 changes: 3 additions & 3 deletions init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ function debuglog(...)
for i = 1, select("#", ...) do
log_table[i] = select(i, ...)
end
ngx.log(ngx.ERR, "[NGINX-LUA-DS-WAF-DEBUG] ", cjson.encode(log_table))
ngx.log(ngx.ERR, "[WIZWAF-DEBUG] ", cjson.encode(log_table))
end

function ngxlog(...)
ngx.log(ngx.ERR, "[NGINX-LUA-DS-WAF] ", ...)
ngx.log(ngx.ERR, "[WIZWAF] ", ...)
end


Expand Down Expand Up @@ -40,7 +40,7 @@ function dswaf_output()
<meta charset="utf-8">
</head>
<body style="width:100%;height:100%;background:#0066cc;">
<h1 style="color:#FFF;text-align:center;">You have been blocked by NGINX-LUA-DS-WAF.</h1>
<h1 style="color:#FFF;text-align:center;">You have been blocked by WIZWAF.</h1>
</body>
</html>
]])
Expand Down
16 changes: 8 additions & 8 deletions waf.lua
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ function log(module_name, why)
end

function block_ip_module(mode)
local block_ips = get_smembers_from_cache_or_redis("DSWAF_BLOCK_IPS")
local block_ips = get_smembers_from_cache_or_redis("WIZWAF_BLOCK_IPS")
if block_ips then
for _, block_ip in ipairs(block_ips) do
if remote_addr == block_ip then
Expand All @@ -49,7 +49,7 @@ end


function block_url_module(mode)
local block_url_slices = get_smembers_from_cache_or_redis("DSWAF_BLOCK_URL_SLICES")
local block_url_slices = get_smembers_from_cache_or_redis("WIZWAF_BLOCK_URL_SLICES")
if block_url_slices then
for _, block_url_slice in ipairs(block_url_slices) do
if ngx.re.match(request_uri, block_url_slice, "sjo") then
Expand All @@ -62,7 +62,7 @@ end


function block_user_agent_module(mode)
local block_user_agent_slices = get_smembers_from_cache_or_redis("DSWAF_BLOCK_UA_SLICES")
local block_user_agent_slices = get_smembers_from_cache_or_redis("WIZWAF_BLOCK_UA_SLICES")
if block_user_agent_slices then
if http_user_agent then
for _, block_user_agent_slice in ipairs(block_user_agent_slices) do
Expand All @@ -77,7 +77,7 @@ end


function block_cookie_module(mode)
local block_cookie_slices = get_smembers_from_cache_or_redis("DSWAF_BLOCK_COOKIE_SLICES")
local block_cookie_slices = get_smembers_from_cache_or_redis("WIZWAF_BLOCK_COOKIE_SLICES")
if block_cookie_slices then
if http_cookie then
for _, block_cookie_slice in ipairs(block_cookie_slices) do
Expand All @@ -92,7 +92,7 @@ end


function block_body_module(mode)
local block_body_slices = get_smembers_from_cache_or_redis("DSWAF_BLOCK_BODY_SLICES")
local block_body_slices = get_smembers_from_cache_or_redis("WIZWAF_BLOCK_BODY_SLICES")
if block_body_slices then
ngx.req.read_body()
local post_args = ngx.req.get_post_args()
Expand All @@ -115,7 +115,7 @@ function dymanic_block_ip_module_redis(mode)
red:expire(remote_addr, 60)
else
red:incr(remote_addr)
if tonumber(access_num) > tonumber(get_value_from_cache_or_redis("DSWAF_DYMANIC_BLOCK_IPS_RATE") or 1000) then
if tonumber(access_num) > tonumber(get_value_from_cache_or_redis("WIZWAF_DYMANIC_BLOCK_IPS_RATE") or 1000) then
log("DYMANIC_BLOCK_IP_MODULE", remote_addr .. "(" .. access_num .. ")")
if mode == "ENABLE" then dswaf_output() else return end
end
Expand All @@ -127,14 +127,14 @@ function dymanic_block_ip_module_cache(mode)
ngx.shared.redis_cache:safe_add(remote_addr, 1, 60)
ngx.shared.redis_cache:incr(remote_addr, 1)
local access_num, err = ngx.shared.redis_cache:get(remote_addr)
if access_num and access_num > tonumber(get_value_from_cache_or_redis("DSWAF_DYMANIC_BLOCK_IPS_RATE") or 1000) then
if access_num and access_num > tonumber(get_value_from_cache_or_redis("WIZWAF_DYMANIC_BLOCK_IPS_RATE") or 1000) then
log("DYMANIC_BLOCK_IP_MODULE", remote_addr .. "(" .. access_num .. ")")
if mode == "ENABLE" then dswaf_output() else return end
end
end


local mode = get_value_from_cache_or_redis("DSWAF_MODE") or "ENABLE"
local mode = get_value_from_cache_or_redis("WIZWAF_MODE") or "ENABLE"
if mode == "ENABLE" or mode == "AUDIT" then
block_ip_module(mode)
block_url_module(mode)
Expand Down

0 comments on commit 40d0457

Please sign in to comment.