diff options
author | Vsevolod Stakhov <vsevolod@rspamd.com> | 2024-07-08 14:49:19 +0100 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@rspamd.com> | 2024-07-08 14:49:19 +0100 |
commit | ca8675103beadca0c6a6a2059b63125d1e3ca1af (patch) | |
tree | e9d8c76f43020408446be731eae332e1a0f1394c /src/plugins/lua | |
parent | 470fe5ae7ddba65078d9d456dc0068ccb8b9905b (diff) | |
download | rspamd-ca8675103beadca0c6a6a2059b63125d1e3ca1af.tar.gz rspamd-ca8675103beadca0c6a6a2059b63125d1e3ca1af.zip |
[Feature] Allow to specify minimum weight in GPT plugin
Diffstat (limited to 'src/plugins/lua')
-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 |