Skip to content

Commit

Permalink
[Minor] Add support of validity checks in the vault
Browse files Browse the repository at this point in the history
  • Loading branch information
vstakhov committed Apr 23, 2019
1 parent ab20b88 commit 27235fe
Showing 1 changed file with 25 additions and 3 deletions.
28 changes: 25 additions & 3 deletions lualib/lua_dkim_tools.lua
Expand Up @@ -21,6 +21,7 @@ local E = {}
local lua_util = require "lua_util"
local rspamd_util = require "rspamd_util"
local logger = require "rspamd_logger"
local fun = require "fun"

local function check_violation(N, task, domain)
-- Check for DKIM_REJECT
Expand Down Expand Up @@ -576,16 +577,37 @@ exports.sign_using_vault = function(N, task, settings, selectors, sign_func, err
else
local elts = obj.data.selectors or {}

for _,p in ipairs(elts) do
-- Filter selectors by time/sanity
local function is_selector_valid(p)
if not p.key or not p.selector then
return false
end

if p.valid_start then
-- Check start time
if rspamd_util.get_time() < tonumber(p.valid_start) then
return false
end
end

if p.valid_end then
if rspamd_util.get_time() >= tonumber(p.valid_end) then
return false
end
end

return true
end
fun.each(function(p)
local dkim_sign_data = {
rawkey = p.key,
selector = p.selector,
domain = selectors.domain
domain = p.domain or selectors.domain
}
lua_util.debugm(N, task, 'found and parsed key for %s:%s in Vault',
dkim_sign_data.domain, dkim_sign_data.selector)
sign_func(task, dkim_sign_data)
end
end, fun.filter(is_selector_valid, elts))
end
end
end
Expand Down

0 comments on commit 27235fe

Please sign in to comment.