From d54cddeeee88a24bcfa75a9144989812fcd11208 Mon Sep 17 00:00:00 2001 From: Vsevolod Stakhov Date: Thu, 15 Mar 2018 16:24:04 +0000 Subject: [PATCH] [Project] Encourage dependencies registration by name only --- src/plugins/lua/arc.lua | 6 +++--- src/plugins/lua/dmarc.lua | 4 ++-- src/plugins/lua/force_actions.lua | 4 ++-- src/plugins/lua/mid.lua | 2 +- src/plugins/lua/ratelimit.lua | 2 +- src/plugins/lua/rbl.lua | 3 ++- src/plugins/lua/reputation.lua | 2 +- src/plugins/lua/whitelist.lua | 10 +++++----- 8 files changed, 17 insertions(+), 16 deletions(-) diff --git a/src/plugins/lua/arc.lua b/src/plugins/lua/arc.lua index 29faa1258..e04e2c067 100644 --- a/src/plugins/lua/arc.lua +++ b/src/plugins/lua/arc.lua @@ -341,8 +341,8 @@ rspamd_config:register_symbol({ group = 'policies', }) -rspamd_config:register_dependency(id, symbols['spf_allow_symbol']) -rspamd_config:register_dependency(id, symbols['dkim_allow_symbol']) +rspamd_config:register_dependency('ARC_CALLBACK', symbols['spf_allow_symbol']) +rspamd_config:register_dependency('ARC_CALLBACK', symbols['dkim_allow_symbol']) local function arc_sign_seal(task, params, header) local fold_type = "crlf" @@ -565,4 +565,4 @@ id = rspamd_config:register_symbol({ }) -- Do not sign unless valid -rspamd_config:register_dependency(id, 'ARC_CALLBACK') +rspamd_config:register_dependency(settings['sign_symbol'], 'ARC_CALLBACK') diff --git a/src/plugins/lua/dmarc.lua b/src/plugins/lua/dmarc.lua index c6e998429..652526d69 100644 --- a/src/plugins/lua/dmarc.lua +++ b/src/plugins/lua/dmarc.lua @@ -1260,6 +1260,6 @@ rspamd_config:register_symbol({ type = 'virtual' }) -rspamd_config:register_dependency(id, symbols['spf_allow_symbol']) -rspamd_config:register_dependency(id, symbols['dkim_allow_symbol']) +rspamd_config:register_dependency('DMARC_CALLBACK', symbols['spf_allow_symbol']) +rspamd_config:register_dependency('DMARC_CALLBACK', symbols['dkim_allow_symbol']) diff --git a/src/plugins/lua/force_actions.lua b/src/plugins/lua/force_actions.lua index ca960a2e4..d607e3343 100644 --- a/src/plugins/lua/force_actions.lua +++ b/src/plugins/lua/force_actions.lua @@ -121,7 +121,7 @@ local function configure_module() flags = 'empty', }) for _, a in ipairs(atoms) do - rspamd_config:register_dependency(id, a) + rspamd_config:register_dependency(name, a) end rspamd_logger.infox(rspamd_config, 'Registered symbol %1 <%2> with dependencies [%3]', name, expr, table.concat(atoms, ',')) end @@ -155,7 +155,7 @@ local function configure_module() local id = rspamd_config:register_symbol(t) if t.type == 'normal' then for _, a in ipairs(atoms) do - rspamd_config:register_dependency(id, a) + rspamd_config:register_dependency(t.name, a) end rspamd_logger.infox(rspamd_config, 'Registered symbol %1 <%2> with dependencies [%3]', name, expr, table.concat(atoms, ',')) else diff --git a/src/plugins/lua/mid.lua b/src/plugins/lua/mid.lua index e1dd9ed5d..4baa8867c 100644 --- a/src/plugins/lua/mid.lua +++ b/src/plugins/lua/mid.lua @@ -96,7 +96,7 @@ if opts then rspamd_config:add_composite(settings['csymbol_missing_mid_allowed'], settings['symbol_known_no_mid'] .. ' & ' .. settings['symbol_missing_mid']) - rspamd_config:register_dependency(id, settings['symbol_dkim_allow']) + rspamd_config:register_dependency('KNOWN_MID_CALLBACK', settings['symbol_dkim_allow']) else rspamd_logger.infox(rspamd_config, 'source is not specified, disabling module') lua_util.disable_module(N, "config") diff --git a/src/plugins/lua/ratelimit.lua b/src/plugins/lua/ratelimit.lua index 3bd595d77..d2aa1abb1 100644 --- a/src/plugins/lua/ratelimit.lua +++ b/src/plugins/lua/ratelimit.lua @@ -725,7 +725,7 @@ if opts then end local id = rspamd_config:register_symbol(s) if use_ip_score then - rspamd_config:register_dependency(id, 'IP_SCORE') + rspamd_config:register_dependency(s.name, 'IP_SCORE') end for _, v in pairs(custom_keywords) do if type(v) == 'table' and type(v['init']) == 'function' then diff --git a/src/plugins/lua/rbl.lua b/src/plugins/lua/rbl.lua index c3c4e7136..588a31567 100644 --- a/src/plugins/lua/rbl.lua +++ b/src/plugins/lua/rbl.lua @@ -527,6 +527,7 @@ local need_dkim = false local id = rspamd_config:register_symbol({ type = 'callback', callback = rbl_cb, + name = 'RBL_CALLBACK', flags = 'empty,nice' }) @@ -652,5 +653,5 @@ for _, w in pairs(white_symbols) do end end if need_dkim then - rspamd_config:register_dependency(id, symbols['dkim_allow_symbol']) + rspamd_config:register_dependency('RBL_CALLBACK', symbols['dkim_allow_symbol']) end diff --git a/src/plugins/lua/reputation.lua b/src/plugins/lua/reputation.lua index 251a4cf64..1969729ac 100644 --- a/src/plugins/lua/reputation.lua +++ b/src/plugins/lua/reputation.lua @@ -998,7 +998,7 @@ local function parse_rule(name, tbl) if rule.selector.dependencies then fun.each(function(d) - rspamd_config:register_dependency(id, d) + rspamd_config:register_dependency(symbol, d) end, rule.selector.dependencies) end diff --git a/src/plugins/lua/whitelist.lua b/src/plugins/lua/whitelist.lua index 815554766..89f382946 100644 --- a/src/plugins/lua/whitelist.lua +++ b/src/plugins/lua/whitelist.lua @@ -264,21 +264,21 @@ local configure_whitelist_module = function() local spf_dep = false local dkim_dep = false if rule['valid_spf'] then - rspamd_config:register_dependency(id, options['spf_allow_symbol']) + rspamd_config:register_dependency(symbol, options['spf_allow_symbol']) spf_dep = true end if rule['valid_dkim'] then - rspamd_config:register_dependency(id, options['dkim_allow_symbol']) + rspamd_config:register_dependency(symbol, options['dkim_allow_symbol']) dkim_dep = true end if rule['valid_dmarc'] then if not spf_dep then - rspamd_config:register_dependency(id, options['spf_allow_symbol']) + rspamd_config:register_dependency(symbol, options['spf_allow_symbol']) end if not dkim_dep then - rspamd_config:register_dependency(id, options['dkim_allow_symbol']) + rspamd_config:register_dependency(symbol, options['dkim_allow_symbol']) end - rspamd_config:register_dependency(id, 'DMARC_CALLBACK') + rspamd_config:register_dependency(symbol, 'DMARC_CALLBACK') end if rule['score'] then -- 2.39.5