commit a128149: [Feature] Rbl: Distinguish flattened and non-flattened selectors in RBL requests
Vsevolod Stakhov
vsevolod at highsecure.ru
Tue Feb 16 14:21:06 UTC 2021
Author: Vsevolod Stakhov
Date: 2021-02-16 14:14:25 +0000
URL: https://github.com/rspamd/rspamd/commit/a1281498414a7efdb4c275eee647273be4d92c4b (HEAD -> master)
[Feature] Rbl: Distinguish flattened and non-flattened selectors in RBL requests
Issue: #3648
---
lualib/plugins/rbl.lua | 2 ++
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)
More information about the Commits
mailing list