summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLudovic Pouzenc <ludovic@pouzenc.fr>2020-05-29 13:56:14 +0200
committerLudovic Pouzenc <ludovic@pouzenc.fr>2020-05-29 13:56:14 +0200
commita6159ac41429b38bfb7369cd13f4ddabf5d7ce19 (patch)
treea961beea1f23dfbcfaff2387cbebdbc58ebab125
parente4ded88080a9091f891ebd51fce3800afc44c12d (diff)
downloadtake-it-easy-linux-a6159ac41429b38bfb7369cd13f4ddabf5d7ce19.tar.gz
take-it-easy-linux-a6159ac41429b38bfb7369cd13f4ddabf5d7ce19.tar.bz2
take-it-easy-linux-a6159ac41429b38bfb7369cd13f4ddabf5d7ce19.zip
Thunderbird has a Reply-To bad behavior that triggers rspamd REPLYTO_EQ_TO_ADDR rule/metric
-rw-r--r--rspamd.local.lua43
1 files changed, 43 insertions, 0 deletions
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,
+}