Browse Source

[Minor] Reiterate on the previous changes

- Demote message to info level
 - Name it returncodes_matcher for better specificity
pull/4657/head
Andrew Lewis 2 years ago
parent
commit
15e3f277fa
  1. 6
      conf/modules.d/rbl.conf
  2. 10
      lualib/plugins/rbl.lua
  3. 8
      src/plugins/lua/rbl.lua
  4. 8
      test/functional/configs/merged-override.conf

6
conf/modules.d/rbl.conf

@ -105,7 +105,7 @@ rbl {
ipv6 = true;
checks = ['from', 'received'];
is_whitelist = true;
matcher = "luapattern";
returncodes_matcher = "luapattern";
whitelist_exception = "RCVD_IN_DNSWL";
whitelist_exception = "RCVD_IN_DNSWL_NONE";
whitelist_exception = "RCVD_IN_DNSWL_LOW";
@ -153,7 +153,7 @@ rbl {
rbl = "dwl.dnswl.org";
checks = ['dkim'];
ignore_whitelist = true;
matcher = "luapattern";
returncodes_matcher = "luapattern";
unknown = false;
returncodes {
@ -224,7 +224,7 @@ rbl {
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_matcher = "luapattern";
returncodes = {
SURBL_HASHBL_PHISH = "127.0.0.8";
SURBL_HASHBL_MALWARE = "127.0.0.16";

10
lualib/plugins/rbl.lua

@ -107,7 +107,6 @@ local rule_schema_tbl = {
ipv6 = ts.boolean:is_optional(),
is_whitelist = ts.boolean:is_optional(),
local_exclude_ip_map = ts.string:is_optional(),
matcher = ts.one_of { "equality", "glob", "luapattern", "radix", "regexp" }:is_optional(),
monitored_address = ts.string:is_optional(),
no_ip = ts.boolean:is_optional(),
process_script = ts.string:is_optional(),
@ -131,6 +130,7 @@ local rule_schema_tbl = {
return_codes = return_codes_schema:is_optional(),
returnbits = return_bits_schema:is_optional(),
returncodes = return_codes_schema:is_optional(),
returncodes_matcher = ts.one_of { "equality", "glob", "luapattern", "radix", "regexp" }:is_optional(),
selector = ts.one_of { ts.string, ts.table }:is_optional(),
selector_flatten = ts.boolean:is_optional(),
symbol = ts.string:is_optional(),
@ -200,16 +200,16 @@ local function convert_checks(rule)
rule.from = true
end
if rule.returncodes and not rule.matcher then
if rule.returncodes and not rule.returncodes_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'
rspamd_logger.info(rspamd_config, 'implicitly enabling luapattern returncodes_matcher for rule %s', rule.symbol)
rule.returncodes_matcher = 'luapattern'
break
end
end
if rule.matcher then
if rule.returncodes_matcher then
break
end
end

8
src/plugins/lua/rbl.lua

@ -894,10 +894,10 @@ local function gen_rbl_callback(rule)
description[#description + 1] = 'selector'
end
if not rule.matcher then
rule.matcher = 'equality'
if not rule.returncodes_matcher then
rule.returncodes_matcher = 'equality'
end
local match = matchers[rule.matcher]
local match = matchers[rule.returncodes_matcher]
local callback_f = function(task)
-- DNS requests to issue (might be hashed afterwards)
@ -1096,7 +1096,7 @@ local function add_rbl(key, rbl, global_opts)
def_type, rbl.symbol)
end
local match_type = rbl.matcher
local match_type = rbl.returncodes_matcher
if match_type and rbl.returncodes and map_match_types[match_type] then
if not rbl.returncodes_maps then
rbl.returncodes_maps = {}

8
test/functional/configs/merged-override.conf

@ -269,7 +269,7 @@ rbl {
from = 'FAKE_RBL',
}
unknown = true;
matcher = "regexp";
returncodes_matcher = "regexp";
returncodes = {
"CODE_2" = '^127\.0\.0\.2$';
"CODE_3" = '^127\.0\.0\.3$';
@ -284,7 +284,7 @@ rbl {
rbl = "fake.wl";
symbol = "FAKE_WL_RBL_UNKNOWN";
unknown = true;
#matcher = "luapattern";
#returncodes_matcher = "luapattern";
returncodes = {
"FAKE_WL_RBL_CODE_2" = "127%.0%.0%.2";
"FAKE_WL_RBL_CODE_3" = "127%.0%.0%.3";
@ -296,7 +296,7 @@ rbl {
ignore_defaults = true;
emails = true;
emails_domainonly = true
matcher = "radix";
returncodes_matcher = "radix";
returncodes = {
RSPAMD_EMAILBL = "127.0.0.2/32";
}
@ -314,7 +314,7 @@ rbl {
checks = ["numeric_urls"];
content_urls = true;
rbl = "test9.uribl";
matcher = "glob";
returncodes_matcher = "glob";
returncodes = {
URIBL_NUMERIC_CONTENT = "*.*.*.*";
}

Loading…
Cancel
Save