diff options
author | Vsevolod Stakhov <vsevolod@rspamd.com> | 2024-07-09 21:20:48 +0600 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-07-09 21:20:48 +0600 |
commit | 7627666d9efbac9b58d2396f281acb9879000a3c (patch) | |
tree | c57f000440650f051d7f1aa661153c792bda16df /src/plugins | |
parent | 6496aba509da4fdf163dd026be39b858e1c3bb9c (diff) | |
parent | ca8675103beadca0c6a6a2059b63125d1e3ca1af (diff) | |
download | rspamd-7627666d9efbac9b58d2396f281acb9879000a3c.tar.gz rspamd-7627666d9efbac9b58d2396f281acb9879000a3c.zip |
Merge pull request #5043 from rspamd/vstakhov-gpt-tunes
Improve some functions in the GPT plugin
Diffstat (limited to 'src/plugins')
-rw-r--r-- | src/plugins/lua/gpt.lua | 29 |
1 files changed, 20 insertions, 9 deletions
diff --git a/src/plugins/lua/gpt.lua b/src/plugins/lua/gpt.lua index ddd2f0186..6adbce3bf 100644 --- a/src/plugins/lua/gpt.lua +++ b/src/plugins/lua/gpt.lua @@ -59,13 +59,13 @@ local fun = require "fun" -- Exclude checks if one of those is found local default_symbols_to_except = { - 'BAYES_SPAM', -- We already know that it is a spam, so we can safely skip it, but no same logic for HAM! - 'WHITELIST_SPF', - 'WHITELIST_DKIM', - 'WHITELIST_DMARC', - 'FUZZY_DENIED', - 'REPLY', - 'BOUNCE', + BAYES_SPAM = 0.9, -- We already know that it is a spam, so we can safely skip it, but no same logic for HAM! + WHITELIST_SPF = -1, + WHITELIST_DKIM = -1, + WHITELIST_DMARC = -1, + FUZZY_DENIED = -1, + REPLY = -1, + BOUNCE = -1, } local settings = { @@ -105,9 +105,20 @@ local function default_condition(task) end end -- We also exclude some symbols - for _, s in ipairs(settings.symbols_to_except) do + for s, required_weight in pairs(settings.symbols_to_except) do if task:has_symbol(s) then - return false, 'skip as "' .. s .. '" is found' + if required_weight > 0 then + -- Also check score + local sym = task:get_symbol(s) + -- Must exist as we checked it before with `has_symbol` + if math.abs(sym.weight) >= required_weight then + return false, 'skip as "' .. s .. '" is found (weight: ' .. sym.weight .. ')' + end + lua_util.debugm(N, task, 'symbol %s has weight %s, but required %s', s, + sym.weight, required_weight) + else + return false, 'skip as "' .. s .. '" is found' + end end end |