mirror of
https://github.com/Safe3/uusec-waf.git
synced 2025-10-04 06:51:54 +08:00
### Feature Updates **Interface & Management** - Redesigned main program and management interface with improved aesthetics and usability, supports UI language switching (English/Chinese) - Added Rule Collections functionality: Create custom rule templates for batch configuration - Introduced whitelist rules that terminate further rule matching upon success - UUSEC WAF Rules API intelligent suggestions during advanced rule editing:ml-citation - New plugin management supporting hot-reloaded plugins to extend WAF capabilities **Protocol & Optimization** - Supports streaming responses for continuous data push (e.g., LLM stream outputs) - Enables Host header modification during proxying for upstream service access - Search engine validation: `waf.searchEngineValid(dns,ip,ua)` prevents high-frequency rules from affecting SEO indexing - Interception log report generation (HTML/PDF exports) - Automatic rotation of UUSEC WAF error/access logs to prevent performance issues **Security & Infrastructure** - Expanded free SSL certificate support: HTTP-01 & DNS-01 verification across 50+ domain providers - Customizable advanced WAF settings: HTTP2, GZIP, HTTP Caching, SSL protocols, etc - Cluster configuration: Manage UUSEC WAF nodes and ML servers via web UI
38 lines
No EOL
1.3 KiB
Lua
38 lines
No EOL
1.3 KiB
Lua
--[[
|
|
Rule Name: Data Mask
|
|
Filtering stage: Response body phase
|
|
Threat level: Medium
|
|
Rule description: Replace and desensitize the ID card and phone number with * on the response page
|
|
--]]
|
|
|
|
|
|
if waf.respContentLength == 0 or waf.respContentLength >= 2097152 then
|
|
return
|
|
end
|
|
|
|
-- Only the first two digits and the last two digits of the ID number number are reserved
|
|
local newstr, n, err = waf.rgxGsub(waf.respBody, [[\b((1[1-5]|2[1-3]|3[1-7]|4[1-6]|5[0-4]|6[1-5]|[7-9]1)\d{4}(18|19|20)\d{2}((0[1-9])|(1[0-2]))(([0-2][1-9])|10|20|30|31)\d{3}[0-9Xx])\b]], function(m)
|
|
return m[0]:sub(1, 2) .. "**************" .. m[0]:sub(-2)
|
|
end, "jos")
|
|
if not newstr then
|
|
waf.errLog("error: ", err)
|
|
return
|
|
end
|
|
if n > 0 then
|
|
waf.respBody = newstr
|
|
-- Notify the UUSEC WAF to replace the data
|
|
waf.replaceFilter = true
|
|
end
|
|
|
|
-- Only retain the first 3 and last 4 digits of the phone number
|
|
newstr, n, err = waf.rgxGsub(waf.respBody, [[\b1(?:(((3[0-9])|(4[5-9])|(5[0-35-9])|(6[2,5-7])|(7[0135-8])|(8[0-9])|(9[0-35-9]))[ -]?\d{4}[ -]?\d{4})|((74)[ -]?[0-5]\d{3}[ -]?\d{4}))\b]], function(m)
|
|
return m[0]:sub(1, 3) .. "****" .. m[0]:sub(-4)
|
|
end, "jos")
|
|
if not newstr then
|
|
waf.errLog("error: ", err)
|
|
return
|
|
end
|
|
if n > 0 then
|
|
waf.respBody = newstr
|
|
waf.replaceFilter = true
|
|
end |