comparison mod_firewall/conditions.lib.lua @ 2528:44a71584521d

mod_firewall: Add SEARCH, PATTERN definitions and SCAN condition to check tokenized stanza:find() against a list
author Matthew Wild <mwild1@gmail.com>
date Mon, 20 Feb 2017 09:31:30 +0000
parents 66b81e144ded
children 3fe4ca2b55c2
comparison
equal deleted inserted replaced
2527:5ff7eb601d60 2528:44a71584521d
261 local meta_deps = {}; 261 local meta_deps = {};
262 expr = meta(("%q"):format(expr), meta_deps); 262 expr = meta(("%q"):format(expr), meta_deps);
263 return ("list_%s:contains(%s) == true"):format(list_name, expr), { "list:"..list_name, unpack(meta_deps) }; 263 return ("list_%s:contains(%s) == true"):format(list_name, expr), { "list:"..list_name, unpack(meta_deps) };
264 end 264 end
265 265
266 -- SCAN: body for word in badwords
267 function condition_handlers.SCAN(scan_expression)
268 local search_name, pattern_name, list_name = scan_expression:match("(%S+) for (%S+) in (%S+)$");
269 if not (search_name) then
270 error("Error parsing SCAN expression, syntax: SEARCH for PATTERN in LIST");
271 end
272 return ("scan_list(%s, %s)"):format(list_name, "tokens_"..search_name.."_"..pattern_name), { "scan_list", "tokens:"..search_name.."_"..pattern_name, "list:"..list_name };
273 end
274
266 return condition_handlers; 275 return condition_handlers;