commit 18030c9: [Rework] Breaking: Do not report soft reject in history
Vsevolod Stakhov
vsevolod at rspamd.com
Sat Jan 7 14:49:03 UTC 2023
Author: Vsevolod Stakhov
Date: 2023-01-07 14:46:56 +0000
URL: https://github.com/rspamd/rspamd/commit/18030c9bbf8dec75709cba51781c074b2ba52268 (HEAD -> master)
[Rework] Breaking: Do not report soft reject in history
We can have much more clear information if we store the real action in
case of `soft-reject`. In this case, we can just imply that a module
that has set this action is an action itself, such as:
* greylist
* ratelimit
* multimap
* antivirus rule name
This policy seems quite reasonable, as `soft reject` has no meaning on
its own.
---
lualib/lua_verdict.lua | 19 +++++++++++++++++++
src/plugins/lua/history_redis.lua | 6 ++++--
2 files changed, 23 insertions(+), 2 deletions(-)
diff --git a/lualib/lua_verdict.lua b/lualib/lua_verdict.lua
index 3ce7e0689..8f3f23ea9 100644
--- a/lualib/lua_verdict.lua
+++ b/lualib/lua_verdict.lua
@@ -186,4 +186,23 @@ exports.describe = function(verdict, what)
return nil
end
+---[[[
+-- @function lua_verdict.adjust_passthrough_action(task)
+-- If an action is `soft reject` then this function extracts a module that has set this action
+-- and returns an adjusted action (e.g. 'greylist' or 'ratelimit').
+-- Otherwise an action is returned as is.
+--]]
+exports.adjust_passthrough_action = function(task)
+ local action = task:get_metric_action()
+ if action == 'soft reject' then
+ local has_pr,_,_,module = task:has_pre_result()
+
+ if has_pr and module then
+ action = module
+ end
+ end
+
+ return action
+end
+
return exports
\ No newline at end of file
diff --git a/src/plugins/lua/history_redis.lua b/src/plugins/lua/history_redis.lua
index c203d354b..d4ee71cd1 100644
--- a/src/plugins/lua/history_redis.lua
+++ b/src/plugins/lua/history_redis.lua
@@ -47,6 +47,7 @@ local lua_redis = require "lua_redis"
local fun = require "fun"
local ucl = require "ucl"
local ts = (require "tableshape").types
+local lua_verdict = require "lua_verdict"
local E = {}
local N = "history_redis"
local hostname = rspamd_util.get_hostname()
@@ -109,6 +110,7 @@ local function normalise_results(tbl, task)
tbl.rmilter = nil
tbl.messages = nil
tbl.urls = nil
+ tbl.action = lua_verdict.adjust_passthrough_action(task)
local seconds = task:get_timeval()['tv_sec']
tbl.unix_time = seconds
@@ -148,8 +150,8 @@ local function history_save(task)
rspamd_logger.errx('cannot get protocol reply, skip saving in history')
return
end
- -- 1 is 'json-compact' but faster
- local json = ucl.to_format(data, 1)
+
+ local json = ucl.to_format(data, 'json-compact')
if settings.compress then
json = rspamd_util.zstd_compress(json)
More information about the Commits
mailing list