]> git.ipfire.org Git - thirdparty/rspamd.git/commitdiff
[Minor] autolearnstats: fix false-positive learned detection 5946/head
authorAlexander Moisseev <moiseev@mezonplus.ru>
Thu, 19 Mar 2026 16:42:45 +0000 (19:42 +0300)
committerAlexander Moisseev <moiseev@mezonplus.ru>
Thu, 19 Mar 2026 16:42:45 +0000 (19:42 +0300)
 rspamd_stat_check_autolearn emits error log lines sharing the
 same function prefix as its success messages. Narrow re_confirmed
 to match only success lines, which start with <MSG-ID>: autolearn.

lualib/rspamadm/autolearnstats.lua

index 3841848e969fb3e95f827a56ca1637ee898a25d0..cd17f70d8851e686c72cb808dc4787b576fffded 100644 (file)
@@ -54,11 +54,13 @@ local re_lua = rspamd_regexp.create(
   'id: <[^>]*>, from: <([^>]*)>: can autolearn (\\w+): score (-?[\\d.]+) ' ..
   '([^\\s,]+) (-?[\\d.]+), mime_rcpts: <([^>]*)>/')
 
--- C-side "autolearn confirmed" line (rspamd_stat_check_autolearn)
+-- C-side "autolearn confirmed" line (rspamd_stat_check_autolearn).
 -- Module is "proxy" for rspamd_proxy worker, "task" for normal worker.
+-- Matched only against the success messages, which start with "<MSG-ID>: autolearn",
+-- to avoid false positives from error messages emitted by the same function.
 -- Captures: req_id
 local re_confirmed = rspamd_regexp.create(
-  '/\\([^)]+\\) (<[0-9a-fA-F]+>); \\w+; rspamd_stat_check_autolearn:/')
+  '/\\([^)]+\\) (<[0-9a-fA-F]+>); \\w+; rspamd_stat_check_autolearn: <[^>]*>: autolearn /')
 
 -- Task result line for sender IP extraction (rspamd_task_write_log)
 -- Module is "proxy" for rspamd_proxy worker, "task" for normal worker.