commit 259c79b: [Rework] Convert surbl rules to rbl rules
Vsevolod Stakhov
vsevolod at highsecure.ru
Tue Aug 27 17:49:13 UTC 2019
Author: Vsevolod Stakhov
Date: 2019-08-27 18:42:51 +0100
URL: https://github.com/rspamd/rspamd/commit/259c79b98d420286271b3f02901771feb3a4a081 (HEAD -> master)
[Rework] Convert surbl rules to rbl rules
---
lualib/lua_cfg_transform.lua | 54 ++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 54 insertions(+)
diff --git a/lualib/lua_cfg_transform.lua b/lualib/lua_cfg_transform.lua
index f74d6d49d..07a53723e 100644
--- a/lualib/lua_cfg_transform.lua
+++ b/lualib/lua_cfg_transform.lua
@@ -233,6 +233,46 @@ local function check_statistics_sanity()
end
end
+-- Converts surbl module config to rbl module
+local function surbl_section_convert(cfg, section)
+ local rbl_section = cfg.rbl.rbls
+ local wl = section.whitelist
+ for name,value in pairs(section.rules or {}) do
+ if not rbl_section[name] then
+ local converted = {
+ urls = true,
+ ignore_defaults = true,
+ }
+
+ if wl then
+ converted.whitelist = wl
+ end
+
+ for k,v in pairs(value) do
+ -- Rename
+ if k == 'suffix' then k = 'rbl' end
+ if k == 'ips' then k = 'returncodes' end
+ if k == 'bits' then k = 'returnbits' end
+ if k:match('check_') then
+ local n = k:match('check_(.*)')
+ k = n
+ end
+
+ if k == 'dkim' and v then
+ converted.dkim_domainonly = false
+ converted.dkim_match_from = true
+ end
+
+ converted[k] = lua_util.deepcopy(v)
+ end
+ rbl_section[name] = converted
+ else
+ logger.warnx(rspamd_config, 'conflicting names in surbl and rbl rules: %s, ignore surbl rule',
+ name)
+ end
+ end
+end
+
return function(cfg)
local ret = false
@@ -402,5 +442,19 @@ return function(cfg)
end
end
+ if cfg.surbl then
+ if not cfg.rbl then
+ cfg.rbl = {
+ rbls = {}
+ }
+ end
+ if not cfg.rbl.rbls then
+ cfg.rbl.rbls = {}
+ end
+ surbl_section_convert(cfg, cfg.surbl)
+ logger.infox(rspamd_config, 'converted surbl rules to rbl rules')
+ cfg.surbl = {}
+ end
+
return ret, cfg
end
More information about the Commits
mailing list