aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@rspamd.com>2024-07-10 18:53:30 +0600
committerGitHub <noreply@github.com>2024-07-10 18:53:30 +0600
commite62dd9dea2fb32981154a2b1106505d3335659de (patch)
tree9bbe84630a972d89319713ddea6c0ecf55e20128 /src/plugins
parent7f19699410f7d85ee9468b7ab6afab2fd1a4cedd (diff)
parent574cd4f7a3a8dbaaf3f05e9a93ea07effcbea69a (diff)
downloadrspamd-e62dd9dea2fb32981154a2b1106505d3335659de.tar.gz
rspamd-e62dd9dea2fb32981154a2b1106505d3335659de.zip
Merge branch 'master' into vstakhov-ratelimits-disable-dyn
Diffstat (limited to 'src/plugins')
-rw-r--r--src/plugins/lua/gpt.lua29
-rw-r--r--src/plugins/lua/metric_exporter.lua2
2 files changed, 21 insertions, 10 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
diff --git a/src/plugins/lua/metric_exporter.lua b/src/plugins/lua/metric_exporter.lua
index 75885516c..3de87c157 100644
--- a/src/plugins/lua/metric_exporter.lua
+++ b/src/plugins/lua/metric_exporter.lua
@@ -117,7 +117,7 @@ local function graphite_push(kwargs)
elseif #split == 2 then
mvalue = kwargs['stats'][split[1]][split[2]]
end
- table.insert(metrics_str, string.format('%s %s %s', mname, mvalue, stamp))
+ table.insert(metrics_str, string.format('%s %s %s', mname, mvalue or 'null', stamp))
end
metrics_str = table.concat(metrics_str, '\n')