diff options
author | Vsevolod Stakhov <vsevolod@rspamd.com> | 2024-09-27 12:51:38 +0100 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@rspamd.com> | 2024-09-27 12:58:53 +0100 |
commit | 30133c49b714d8d774e6b0514986de795a61e235 (patch) | |
tree | d5df3171e2e891fae83bf19d9d6d3e536ad0469a /lualib/lua_scanners | |
parent | 6ed56a333ca7ef1b2a5a007d67fda0759af1a280 (diff) | |
download | rspamd-30133c49b714d8d774e6b0514986de795a61e235.tar.gz rspamd-30133c49b714d8d774e6b0514986de795a61e235.zip |
[Fix] Fix DCC `rep` handlingvstakhov-fix-dcc
Issue: #5158
Diffstat (limited to 'lualib/lua_scanners')
-rw-r--r-- | lualib/lua_scanners/dcc.lua | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/lualib/lua_scanners/dcc.lua b/lualib/lua_scanners/dcc.lua index 8d5e9e10a..186d1543d 100644 --- a/lualib/lua_scanners/dcc.lua +++ b/lualib/lua_scanners/dcc.lua @@ -198,13 +198,18 @@ local function dcc_check(task, content, digest, rule) local opts = {} local score = 0.0 info = info:lower() - local rep = info:match('rep=([^=%s]+)') + local rep = info:match('rep=(%d+)') -- Adjust reputation if available if rep then - rep = tonumber(rep) - end - if not rep then + rep = (tonumber(rep) or 100.0) / 100.0 + + if rep > 1.0 then + rep = 1.0 + elseif rep < 0.0 then + rep = 0.0 + end + else rep = 1.0 end @@ -213,12 +218,12 @@ local function dcc_check(task, content, digest, rule) if num == 'many' then rnum = lim else - rnum = tonumber(num) + rnum = tonumber(num) or lim end if rnum and rnum >= lim then opts[#opts + 1] = string.format('%s=%s', what, num) - score = score + rep / 3.0 + score = score * rep end end |