Diff

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
parent 2521:66b81e144ded
child 2529:3fe4ca2b55c2
line wrap: on
line diff
--- a/mod_firewall/conditions.lib.lua	Mon Feb 20 09:29:38 2017 +0000
+++ b/mod_firewall/conditions.lib.lua	Mon Feb 20 09:31:30 2017 +0000
@@ -263,4 +263,13 @@
 	return ("list_%s:contains(%s) == true"):format(list_name, expr), { "list:"..list_name, unpack(meta_deps) };
 end
 
+-- SCAN: body for word in badwords
+function condition_handlers.SCAN(scan_expression)
+	local search_name, pattern_name, list_name = scan_expression:match("(%S+) for (%S+) in (%S+)$");
+	if not (search_name) then
+		error("Error parsing SCAN expression, syntax: SEARCH for PATTERN in LIST");
+	end
+	return ("scan_list(%s, %s)"):format(list_name, "tokens_"..search_name.."_"..pattern_name), { "scan_list", "tokens:"..search_name.."_"..pattern_name, "list:"..list_name };
+end
+
 return condition_handlers;