From: Vsevolod Stakhov Date: Thu, 23 May 2019 14:37:15 +0000 (+0100) Subject: [Minor] Clickhouse: Add exceptions logic X-Git-Tag: 2.0~864 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=087e3318348d368c2b0639a44abff418f91ef94b;p=rspamd.git [Minor] Clickhouse: Add exceptions logic --- diff --git a/src/plugins/lua/clickhouse.lua b/src/plugins/lua/clickhouse.lua index ccaee3042..599164006 100644 --- a/src/plugins/lua/clickhouse.lua +++ b/src/plugins/lua/clickhouse.lua @@ -76,6 +76,7 @@ local settings = { no_ssl_verify = false, custom_rules = {}, enable_digest = false, + exceptions = nil, retention = { enable = false, method = 'detach', @@ -380,12 +381,27 @@ local function clickhouse_send_data(task, ev_base) end local function clickhouse_collect(task) - if task:has_flag('skip') then return end - if not settings.allow_local and rspamd_lua_utils.is_rspamc_or_controller(task) then return end + if task:has_flag('skip') then + return + end + + if not settings.allow_local and rspamd_lua_utils.is_rspamc_or_controller(task) then + return + end for _,sym in ipairs(settings.stop_symbols) do if task:has_symbol(sym) then - lua_util.debugm(N, task, 'skip collection as symbol %s has fired', sym) + rspamd_logger.infox(task, 'skip Clickhouse storage for message: symbol %s has fired', sym) + return + end + end + + if settings.exceptions then + local excepted,trace = settings.exceptions:process(task) + if excepted then + rspamd_logger.infox(task, 'skipped Clickhouse storage for message: excepted (%s)', + trace) + -- Excepted return end end @@ -1069,6 +1085,13 @@ if opts then return end + if settings.exceptions then + local maps_expressions = require "lua_maps_expressions" + + settings.exceptions = maps_expressions.create(rspamd_config, + settings.exceptions, N) + end + rspamd_config:register_symbol({ name = 'CLICKHOUSE_COLLECT', type = 'idempotent',