diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2021-02-16 14:14:25 +0000 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2021-02-16 14:14:25 +0000 |
commit | a1281498414a7efdb4c275eee647273be4d92c4b (patch) | |
tree | ba785a2555d82894a20ae09049b52ba4ad2e8b56 | |
parent | 8c3dfcf875b2da9b59125b4286fc0ed759492aa3 (diff) | |
download | rspamd-a1281498414a7efdb4c275eee647273be4d92c4b.tar.gz rspamd-a1281498414a7efdb4c275eee647273be4d92c4b.zip |
[Feature] Rbl: Distinguish flattened and non-flattened selectors in RBL requests
Issue: #3648
-rw-r--r-- | lualib/plugins/rbl.lua | 2 | ||||
-rw-r--r-- | src/plugins/lua/rbl.lua | 16 |
2 files changed, 13 insertions, 5 deletions
diff --git a/lualib/plugins/rbl.lua b/lualib/plugins/rbl.lua index 78f2c9064..3bddf52ba 100644 --- a/lualib/plugins/rbl.lua +++ b/lualib/plugins/rbl.lua @@ -53,6 +53,7 @@ local default_options = { ['default_exclude_local'] = true, ['default_no_ip'] = false, ['default_dkim_match_from'] = false, + ['default_selector_flatten'] = true, } local return_codes_schema = ts.map_of( @@ -126,6 +127,7 @@ local rule_schema_tbl = { returnbits = return_bits_schema:is_optional(), returncodes = return_codes_schema:is_optional(), selector = ts.one_of{ts.string, ts.table}:is_optional(), + selector_flatten = ts.boolean:is_optional(), symbol = ts.string:is_optional(), symbols_prefixes = ts.map_of(ts.string, ts.string):is_optional(), unknown = ts.boolean:is_optional(), diff --git a/src/plugins/lua/rbl.lua b/src/plugins/lua/rbl.lua index 5878b2f3d..87b97e171 100644 --- a/src/plugins/lua/rbl.lua +++ b/src/plugins/lua/rbl.lua @@ -601,9 +601,14 @@ local function gen_rbl_callback(rule) local res = selector(task) if res then - for _,r in ipairs(res) do - add_dns_request(task, r, false, false, requests_table, - selector_label, whitelist) + if rule.selector_flatten then + add_dns_request(task, table.concat(res, ''), false, false, + requests_table, selector_label, whitelist) + else + for _,r in ipairs(res) do + add_dns_request(task, r, false, false, requests_table, + selector_label, whitelist) + end end end end @@ -904,8 +909,9 @@ local function add_rbl(key, rbl, global_opts) known_selectors[selector].id) rbl.selectors[selector_label] = known_selectors[selector].selector else - -- Create a new flattened closure - local sel = selectors.create_selector_closure(rspamd_config, selector, '', true) + + local sel = selectors.create_selector_closure(rspamd_config, selector, '', + rbl.selector_flatten) if not sel then rspamd_logger.errx('invalid selector for rbl rule %s: %s', key, selector) |