From a6159ac41429b38bfb7369cd13f4ddabf5d7ce19 Mon Sep 17 00:00:00 2001 From: Ludovic Pouzenc Date: Fri, 29 May 2020 13:56:14 +0200 Subject: Thunderbird has a Reply-To bad behavior that triggers rspamd REPLYTO_EQ_TO_ADDR rule/metric --- rspamd.local.lua | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 rspamd.local.lua diff --git a/rspamd.local.lua b/rspamd.local.lua new file mode 100644 index 0000000..e2c6012 --- /dev/null +++ b/rspamd.local.lua @@ -0,0 +1,43 @@ +local rspamd_logger = require "rspamd_logger" + +local function get_raw_header(task, name) + return ((task:get_header_full(name) or {})[1] or {})['value'] +end + +rspamd_config:register_symbol{ + type = 'postfilter', -- 'callback' n'aurai pas permis task:adjust_result() + name = 'REPLYTO_EQ_TO_ADDR_TBIRD_BUG', + score = 0, + group = 'headers', -- Metric group + description = 'Thunderbird ajoute des headers Reply-To incorrects en réponse a des mails ayant un Reply-To (typiquement venant d\'une liste de diffusion). Inhiber REPLYTO_EQ_TO_ADDR dans ce cas.', + flags = 'fine', -- fine: symbol is always checked, skip: symbol is always skipped, empty: symbol work for checks with no message + callback = function(task) + -- N'exécuter ce callback que si REPLYTO_EQ_TO_ADDR a été positionné par /usr/share/rspamd/rules/headers_checks.lua + if not task:has_symbol('REPLYTO_EQ_TO_ADDR') then + return false + end + -- Vérifier qu'on est dans le cas où l'utilisateur est authentifié (outgoing mail) + local user = task:get_user() + rspamd_logger.infox('REPLYTO_EQ_TO_ADDR_TBIRD_BUG user = %1', user) + if not user then + return false + end + -- Vérifier que le User-Agent est présent et contient 'Thunderbird' + local ua = get_raw_header(task, 'User-Agent') + rspamd_logger.infox('REPLYTO_EQ_TO_ADDR_TBIRD_BUG ua = %1', ua) + if not ua then + return false + end + local match, match_end = ua:find('Thunderbird') + rspamd_logger.infox('REPLYTO_EQ_TO_ADDR_TBIRD_BUG match = %1', match) + if not match then + return false + end + -- Marquer le message avec REPLYTO_EQ_TO_ADDR_TBIRD_BUG + rspamd_logger.infox('REPLYTO_EQ_TO_ADDR_TBIRD_BUG insert_result(REPLYTO_EQ_TO_ADDR_TBIRD_BUG, 1.0)') + task:insert_result('REPLYTO_EQ_TO_ADDR_TBIRD_BUG', 1.0) + -- Astuce pour ignorer la règle REPLYTO_EQ_TO_ADDR qui est au milieu d'une forêt de if dans headers_checks.lua) + rspamd_logger.infox('REPLYTO_EQ_TO_ADDR_TBIRD_BUG adjust_result(REPLYTO_EQ_TO_ADDR, 0)') + task:adjust_result('REPLYTO_EQ_TO_ADDR', 0) + end, +} -- cgit v1.2.3