ipv6 = true;
checks = ['from', 'received'];
is_whitelist = true;
+ matcher = "luapattern";
whitelist_exception = "RCVD_IN_DNSWL";
whitelist_exception = "RCVD_IN_DNSWL_NONE";
whitelist_exception = "RCVD_IN_DNSWL_LOW";
rbl = "dwl.dnswl.org";
checks = ['dkim'];
ignore_whitelist = true;
+ matcher = "luapattern";
unknown = false;
returncodes {
selector = "specific_urls_filter_map('surbl_hashbl_map', {limit = 10}).apply_methods('get_host', 'get_path').join_tables('/')",
hash = 'md5';
hash_len = 32;
+ matcher = "luapattern";
returncodes = {
SURBL_HASHBL_PHISH = "127.0.0.8";
SURBL_HASHBL_MALWARE = "127.0.0.16";
ipv6 = ts.boolean:is_optional(),
is_whitelist = ts.boolean:is_optional(),
local_exclude_ip_map = ts.string:is_optional(),
+ matcher = ts.one_of { "equality", "luapattern" }:is_optional(),
monitored_address = ts.string:is_optional(),
no_ip = ts.boolean:is_optional(),
process_script = ts.string:is_optional(),
rule.from = true
end
+ if rule.returncodes and not rule.matcher then
+ for _, v in pairs(rule.returncodes) do
+ for _, e in ipairs(v) do
+ if e:find('%', 1, true) then
+ rspamd_logger.warnx(rspamd_config, 'implicitly enabling luapattern matcher for rule %s', rule.symbol)
+ rule.matcher = 'luapattern'
+ break
+ end
+ end
+ if rule.matcher then
+ break
+ end
+ end
+ end
+
return rule
end
end
end
-local function rbl_dns_process(task, rbl, to_resolve, results, err, resolve_table_elt)
+local matchers = {}
+
+matchers.equality = function(to_match, pattern)
+ return to_match == pattern
+end
+
+matchers.luapattern = function(to_match, pattern)
+ return string.find(to_match, '^' .. pattern .. '$') and true or false
+end
+
+local function rbl_dns_process(task, rbl, to_resolve, results, err, resolve_table_elt, match)
local function make_option(ip, label)
if ip then
return string.format('%s:%s:%s',
elseif rbl.returncodes then
for s, codes in pairs(rbl.returncodes) do
for _, v in ipairs(codes) do
- if string.find(ipstr, '^' .. v .. '$') then
+ if match(ipstr, v) then
foundrc = true
insert_results(s)
break
description[#description + 1] = 'selector'
end
+ if not rule.matcher then
+ rule.matcher = 'equality'
+ end
+ local match = matchers[rule.matcher]
+
local callback_f = function(task)
-- DNS requests to issue (might be hashed afterwards)
local dns_req = {}
local function gen_rbl_dns_callback(resolve_table_elt)
return function(_, to_resolve, results, err)
- rbl_dns_process(task, rule, to_resolve, results, err, resolve_table_elt)
+ rbl_dns_process(task, rule, to_resolve, results, err, resolve_table_elt, match)
end
end