summaryrefslogtreecommitdiffstats
path: root/src/plugins/lua/arc.lua
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2017-05-27 09:57:50 +0100
committerVsevolod Stakhov <vsevolod@highsecure.ru>2017-05-27 09:57:50 +0100
commitbea12ce0e44b38c17dc876bf34f9cdf74aabeb1e (patch)
treecbc1ca1f57e784b3974bd90bd904267519a57958 /src/plugins/lua/arc.lua
parentcbd0e6ffdb8082dbf8e81d9c48a3c86ef5c6055b (diff)
downloadrspamd-bea12ce0e44b38c17dc876bf34f9cdf74aabeb1e.tar.gz
rspamd-bea12ce0e44b38c17dc876bf34f9cdf74aabeb1e.zip
[Minor] Fix couple of issues in arc plugin
Diffstat (limited to 'src/plugins/lua/arc.lua')
-rw-r--r--src/plugins/lua/arc.lua48
1 files changed, 39 insertions, 9 deletions
diff --git a/src/plugins/lua/arc.lua b/src/plugins/lua/arc.lua
index e75824be6..847eeb3e5 100644
--- a/src/plugins/lua/arc.lua
+++ b/src/plugins/lua/arc.lua
@@ -22,7 +22,7 @@ if confighelp then
return
end
-local N = 'dmarc'
+local N = 'arc'
local dkim_verify = rspamd_plugins.dkim.verify
local arc_symbols = {
@@ -117,6 +117,8 @@ local function arc_callback(task)
return (e1.i or 0) < (e2.i or 0)
end)
+ rspamd_logger.debugm(N, task, 'got %s arc sections', #cbdata.seals)
+
-- Now check sanity of what we have
for i = 1,#cbdata.seals do
if (cbdata.sigs[i].i or 0) ~= i then
@@ -136,15 +138,19 @@ local function arc_callback(task)
cbdata.seals[i].header = arc_seal_headers[i].decoded
end
- local function arc_seal_cb(res, err)
+ local function arc_seal_cb(_, res, err, domain)
cbdata.checked = cbdata.checked + 1
+ rspamd_logger.debugm(N, task, 'checked arc seal: %s(%s), %s processed',
+ res, err, cbdata.checked)
if not res then
cbdata.res = 'fail'
- table.insert(cbdata.errors(err))
+ if err and domain then
+ table.insert(cbdata.errors, string.format('sig:%s:%s', domain, err))
+ end
end
- if cbdata.checked == #arc_sig_headers - 1 then
+ if cbdata.checked == #arc_sig_headers then
if cbdata.res == 'success' then
task:insert_result(arc_symbols['allow'], 1.0, cbdata.errors)
else
@@ -153,21 +159,33 @@ local function arc_callback(task)
end
end
- local function arc_signature_cb(res, err)
+ local function arc_signature_cb(_, res, err, domain)
cbdata.checked = cbdata.checked + 1
+ rspamd_logger.debugm(N, task, 'checked arc signature %s: %s(%s), %s processed',
+ domain, res, err, cbdata.checked)
+
if not res then
cbdata.res = 'fail'
- table.insert(cbdata.errors(err))
+ if err and domain then
+ table.insert(cbdata.errors, string.format('sig:%s:%s', domain, err))
+ end
end
- if cbdata.checked == #arc_sig_headers - 1 then
+ if cbdata.checked == #arc_sig_headers then
if cbdata.res == 'success' then
-- Verify seals
cbdata.checked = 0
fun.each(
function(sig)
- dkim_verify(task, sig.header, arc_seal_cb, 'arc-seal')
+ local ret, lerr = dkim_verify(task, sig.header, arc_seal_cb, 'arc-seal')
+ if not ret then
+ cbdata.res = 'fail'
+ table.insert(cbdata.errors, string.format('sig:%s:%s', sig.d or '', lerr))
+ cbdata.checked = cbdata.checked + 1
+ rspamd_logger.debugm(N, task, 'checked arc seal %s: %s(%s), %s processed',
+ sig.d, ret, lerr, cbdata.checked)
+ end
end, cbdata.seals)
else
task:insert_result(arc_symbols['reject'], 1.0, cbdata.errors)
@@ -178,8 +196,20 @@ local function arc_callback(task)
-- Now we can verify all signatures
fun.each(
function(sig)
- dkim_verify(task, sig.header, arc_signature_cb, 'arc-sign')
+ local ret,err = dkim_verify(task, sig.header, arc_signature_cb, 'arc-sign')
+
+ if not ret then
+ cbdata.res = 'fail'
+ table.insert(cbdata.errors, string.format('sig:%s:%s', sig.d or '', err))
+ cbdata.checked = cbdata.checked + 1
+ rspamd_logger.debugm(N, task, 'checked arc sig %s: %s(%s), %s processed',
+ sig.d, ret, err, cbdata.checked)
+ end
end, cbdata.sigs)
+
+ if cbdata.checked == #arc_sig_headers then
+ task:insert_result(arc_symbols['reject'], 1.0, cbdata.errors)
+ end
end
local opts = rspamd_config:get_all_opt('arc')