commit b636902: [Feature] Clickhouse: Add authenticated user and settings id columns
Vsevolod Stakhov
vsevolod at highsecure.ru
Tue Jun 11 11:49:03 UTC 2019
Author: Vsevolod Stakhov
Date: 2019-06-11 12:48:25 +0100
URL: https://github.com/rspamd/rspamd/commit/b636902dcf27991b16f80c0e4230389984d6c598 (HEAD -> master)
[Feature] Clickhouse: Add authenticated user and settings id columns
---
src/plugins/lua/clickhouse.lua | 21 +++++++++++++++++++--
1 file changed, 19 insertions(+), 2 deletions(-)
diff --git a/src/plugins/lua/clickhouse.lua b/src/plugins/lua/clickhouse.lua
index 599164006..1ac9398da 100644
--- a/src/plugins/lua/clickhouse.lua
+++ b/src/plugins/lua/clickhouse.lua
@@ -30,7 +30,7 @@ end
local data_rows = {}
local custom_rows = {}
local nrows = 0
-local schema_version = 5 -- Current schema version
+local schema_version = 6 -- Current schema version
local settings = {
limit = 1000,
@@ -130,6 +130,8 @@ CREATE TABLE rspamd
`Symbols.Options` Array(String),
ScanTimeReal UInt32,
ScanTimeVirtual UInt32,
+ AuthUser String,
+ SettingsId LowCardinality(String),
Digest FixedString(32),
SMTPFrom ALIAS if(From = '', '', concat(FromUser, '@', From)),
SMTPRcpt ALIAS if(RcptDomain = '', '', concat(RcptUser, '@', RcptDomain)),
@@ -199,6 +201,14 @@ local migrations = {
-- New version
[[INSERT INTO rspamd_version (Version) Values (5)]],
},
+ [5] = {
+ [[ALTER TABLE rspamd
+ ADD COLUMN AuthUser String AFTER ScanTimeVirtual,
+ ADD COLUMN SettingsId LowCardinality(String) AFTER AuthUser
+ ]],
+ -- New version
+ [[INSERT INTO rspamd_version (Version) Values (6)]],
+ },
}
local predefined_actions = {
@@ -243,6 +253,9 @@ local function clickhouse_main_row(res)
'ScanTimeVirtual',
-- 1.9.3 +
'CustomAction',
+ -- 2.0 +
+ 'AuthUser',
+ 'SettingsId',
}
for _,v in ipairs(fields) do table.insert(res, v) end
@@ -599,6 +612,8 @@ local function clickhouse_collect(task)
scan_real = 0
end
+ local auth_user = task:get_user() or ''
+
local row = {
today(timestamp),
timestamp,
@@ -628,7 +643,9 @@ local function clickhouse_collect(task)
message_id,
scan_real,
scan_virtual,
- custom_action
+ custom_action,
+ auth_user,
+ '' -- TODO: Add settings id support
}
-- Attachments step
More information about the Commits
mailing list