From 09c208bda19a1c46fdb7f2750f70cc2c30e2d15f Mon Sep 17 00:00:00 2001 From: Vsevolod Stakhov Date: Sat, 29 Sep 2018 14:51:42 +0100 Subject: [PATCH] [Fix] Fix groups mess --- src/plugins/lua/antivirus.lua | 5 ++++- src/plugins/lua/arc.lua | 7 +++++++ src/plugins/lua/dmarc.lua | 14 ++++++++++++++ src/plugins/lua/forged_recipients.lua | 2 ++ src/plugins/lua/hfilter.lua | 13 +++++++++++++ src/plugins/lua/mid.lua | 3 +++ src/plugins/lua/mime_types.lua | 27 ++++++++++++++++++--------- 7 files changed, 61 insertions(+), 10 deletions(-) diff --git a/src/plugins/lua/antivirus.lua b/src/plugins/lua/antivirus.lua index 5080a1c2a..91a6c0a9b 100644 --- a/src/plugins/lua/antivirus.lua +++ b/src/plugins/lua/antivirus.lua @@ -926,12 +926,15 @@ if opts and type(opts) == 'table' then type = 'normal', name = m['symbol'], callback = cb, + score = 0.0, + group = 'antivirus' }) rspamd_config:register_symbol({ type = 'virtual', name = m['symbol_fail'], parent = id, score = 0.0, + group = 'antivirus' }) has_valid = true if type(m['patterns']) == 'table' then @@ -977,7 +980,7 @@ if opts and type(opts) == 'table' then name = m['symbol'], score = m['score'], description = description, - group = group + group = group or 'antivirus' }) end end diff --git a/src/plugins/lua/arc.lua b/src/plugins/lua/arc.lua index bf6010c3f..eeae65289 100644 --- a/src/plugins/lua/arc.lua +++ b/src/plugins/lua/arc.lua @@ -343,6 +343,8 @@ end local id = rspamd_config:register_symbol({ name = 'ARC_CALLBACK', type = 'callback', + group = 'policies', + groups = {'arc'}, callback = arc_callback }) @@ -353,6 +355,7 @@ rspamd_config:register_symbol({ type = 'virtual', score = -1.0, group = 'policies', + groups = {'arc'}, }) rspamd_config:register_symbol({ name = arc_symbols['reject'], @@ -360,6 +363,7 @@ rspamd_config:register_symbol({ type = 'virtual', score = 2.0, group = 'policies', + groups = {'arc'}, }) rspamd_config:register_symbol({ name = arc_symbols['invalid'], @@ -367,6 +371,7 @@ rspamd_config:register_symbol({ type = 'virtual', score = 1.0, group = 'policies', + groups = {'arc'}, }) rspamd_config:register_symbol({ name = arc_symbols['dnsfail'], @@ -374,6 +379,7 @@ rspamd_config:register_symbol({ type = 'virtual', score = 0.0, group = 'policies', + groups = {'arc'}, }) rspamd_config:register_symbol({ name = arc_symbols['na'], @@ -381,6 +387,7 @@ rspamd_config:register_symbol({ type = 'virtual', score = 0.0, group = 'policies', + groups = {'arc'}, }) rspamd_config:register_dependency('ARC_CALLBACK', symbols['spf_allow_symbol']) diff --git a/src/plugins/lua/dmarc.lua b/src/plugins/lua/dmarc.lua index c08b1dfa9..38f54f1f8 100644 --- a/src/plugins/lua/dmarc.lua +++ b/src/plugins/lua/dmarc.lua @@ -1266,37 +1266,51 @@ end local id = rspamd_config:register_symbol({ name = 'DMARC_CALLBACK', type = 'callback', + group = 'policies', + groups = {'dmarc'}, callback = dmarc_callback }) rspamd_config:register_symbol({ name = dmarc_symbols['allow'], flags = 'nice', parent = id, + group = 'policies', + groups = {'dmarc'}, type = 'virtual' }) rspamd_config:register_symbol({ name = dmarc_symbols['reject'], parent = id, + group = 'policies', + groups = {'dmarc'}, type = 'virtual' }) rspamd_config:register_symbol({ name = dmarc_symbols['quarantine'], parent = id, + group = 'policies', + groups = {'dmarc'}, type = 'virtual' }) rspamd_config:register_symbol({ name = dmarc_symbols['softfail'], parent = id, + group = 'policies', + groups = {'dmarc'}, type = 'virtual' }) rspamd_config:register_symbol({ name = dmarc_symbols['dnsfail'], parent = id, + group = 'policies', + groups = {'dmarc'}, type = 'virtual' }) rspamd_config:register_symbol({ name = dmarc_symbols['na'], parent = id, + group = 'policies', + groups = {'dmarc'}, type = 'virtual' }) diff --git a/src/plugins/lua/forged_recipients.lua b/src/plugins/lua/forged_recipients.lua index 25d6c8f8c..887b1bf82 100644 --- a/src/plugins/lua/forged_recipients.lua +++ b/src/plugins/lua/forged_recipients.lua @@ -97,6 +97,8 @@ if opts then name = 'FORGED_CALLBACK', callback = check_forged_headers, type = 'callback', + group = 'headers', + score = 0.0, }) if opts['symbol_rcpt'] then symbol_rcpt = opts['symbol_rcpt'] diff --git a/src/plugins/lua/hfilter.lua b/src/plugins/lua/hfilter.lua index 70992b8f3..b63483f41 100644 --- a/src/plugins/lua/hfilter.lua +++ b/src/plugins/lua/hfilter.lua @@ -618,6 +618,19 @@ end --dumper(symbols_enabled) if #symbols_enabled > 0 then rspamd_config:register_symbols(hfilter, 1.0, "HFILTER", symbols_enabled); + rspamd_config:set_metric_symbol({ + name = 'HFILTER', + score = 0.0, + group = 'hfilter' + }) + + for _,s in ipairs(symbols_enabled) do + rspamd_config:set_metric_symbol({ + name = s, + score = 0.0, + group = 'hfilter' + }) + end else lua_util.disable_module(N, "config") end diff --git a/src/plugins/lua/mid.lua b/src/plugins/lua/mid.lua index 4baa8867c..5410e7f9f 100644 --- a/src/plugins/lua/mid.lua +++ b/src/plugins/lua/mid.lua @@ -79,16 +79,19 @@ if opts then local id = rspamd_config:register_symbol({ name = 'KNOWN_MID_CALLBACK', type = 'callback', + group = 'mid', callback = known_mid_cb }) rspamd_config:register_symbol({ name = settings['symbol_known_mid'], parent = id, + group = 'mid', type = 'virtual' }) rspamd_config:register_symbol({ name = settings['symbol_known_no_mid'], parent = id, + group = 'mid', type = 'virtual' }) rspamd_config:add_composite(settings['csymbol_invalid_msgid_allowed'], diff --git a/src/plugins/lua/mime_types.lua b/src/plugins/lua/mime_types.lua index f97f22d2a..7e383724b 100644 --- a/src/plugins/lua/mime_types.lua +++ b/src/plugins/lua/mime_types.lua @@ -1018,49 +1018,58 @@ if opts then local id = rspamd_config:register_symbol({ name = 'MIME_TYPES_CALLBACK', callback = check_mime_type, - type = 'callback,nostat' + type = 'callback,nostat', + group = 'mime_types', }) rspamd_config:register_symbol({ type = 'virtual', name = settings['symbol_unknown'], - parent = id + parent = id, + group = 'mime_types', }) rspamd_config:register_symbol({ type = 'virtual', name = settings['symbol_bad'], - parent = id + parent = id, + group = 'mime_types', }) rspamd_config:register_symbol({ type = 'virtual', name = settings['symbol_good'], flags = 'nice', - parent = id + parent = id, + group = 'mime_types', }) rspamd_config:register_symbol({ type = 'virtual', name = settings['symbol_attachment'], - parent = id + parent = id, + group = 'mime_types', }) rspamd_config:register_symbol({ type = 'virtual', name = settings['symbol_encrypted_archive'], - parent = id + parent = id, + group = 'mime_types', }) rspamd_config:register_symbol({ type = 'virtual', name = settings['symbol_archive_in_archive'], - parent = id + parent = id, + group = 'mime_types', }) rspamd_config:register_symbol({ type = 'virtual', name = settings['symbol_double_extension'], - parent = id + parent = id, + group = 'mime_types', }) rspamd_config:register_symbol({ type = 'virtual', name = settings['symbol_bad_extension'], - parent = id + parent = id, + group = 'mime_types', }) else lua_util.disable_module(N, "config") -- 2.39.5