From: Vsevolod Stakhov Date: Sat, 9 Mar 2024 13:20:53 +0000 (+0000) Subject: [Minor] Improve logging when doing signing via Vault X-Git-Tag: 3.9.0~102^2~2 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=db0911cdb4bd4f6e0c2d736ec566f608bb99aafe;p=rspamd.git [Minor] Improve logging when doing signing via Vault Issue: #4865 --- diff --git a/lualib/lua_dkim_tools.lua b/lualib/lua_dkim_tools.lua index 165ea8f56..38753c46e 100644 --- a/lualib/lua_dkim_tools.lua +++ b/lualib/lua_dkim_tools.lua @@ -641,22 +641,27 @@ exports.sign_using_vault = function(N, task, settings, selectors, sign_func, err full_url, body)) else local elts = obj.data.selectors or {} + local errs = {} + local nvalid = 0 -- Filter selectors by time/sanity local function is_selector_valid(p) if not p.key or not p.selector then + table.insert(errs, { "missing key/selector", p }) return false end if p.valid_start then -- Check start time if rspamd_util.get_time() < tonumber(p.valid_start) then + table.insert(errs, { "start time is in the future", p }) return false end end if p.valid_end then if rspamd_util.get_time() >= tonumber(p.valid_end) then + table.insert(errs, { "end time is in the past", p }) return false end end @@ -672,8 +677,17 @@ exports.sign_using_vault = function(N, task, settings, selectors, sign_func, err } lua_util.debugm(N, task, 'found and parsed key for %s:%s in Vault', dkim_sign_data.domain, dkim_sign_data.selector) + nvalid = nvalid + 1 sign_func(task, dkim_sign_data) end, fun.filter(is_selector_valid, elts)) + for _, e in errs do + lua_util.debugm(N, task, 'error found during processing Vault selectors: %s:%s', + e[1], e[2]) + end + + if nvalid == 0 then + lua_util.debugm(N, task, 'no valid selectors have been returned from the Vault, skip signing') + end end end end