From 249df31d3b6382ba0c240858f208f8753ada1fba Mon Sep 17 00:00:00 2001 From: Andrew Lewis Date: Sun, 31 Jul 2016 15:33:48 +0200 Subject: [PATCH] [Feature] Add DMARC_BAD_POLICY symbol when DMARC policy was invalid --- src/plugins/lua/dmarc.lua | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/plugins/lua/dmarc.lua b/src/plugins/lua/dmarc.lua index d162b1164..45a30054a 100644 --- a/src/plugins/lua/dmarc.lua +++ b/src/plugins/lua/dmarc.lua @@ -93,7 +93,7 @@ local function dmarc_callback(task) local strict_policy = false local quarantine_policy = false local found_policy = false - local failed_policy = false + local failed_policy local rua for _,r in ipairs(results) do @@ -103,7 +103,7 @@ local function dmarc_callback(task) return else if found_policy then - failed_policy = true + failed_policy = 'Multiple policies defined in DNS' return else found_policy = true @@ -118,7 +118,7 @@ local function dmarc_callback(task) if dkim_pol == 's' then strict_dkim = true elseif dkim_pol ~= 'r' then - failed_policy = true + failed_policy = 'adkim tag has invalid value' return end end @@ -127,7 +127,7 @@ local function dmarc_callback(task) if spf_pol == 's' then strict_spf = true elseif spf_pol ~= 'r' then - failed_policy = true + failed_policy = 'aspf tag has invalid value' return end end @@ -139,7 +139,7 @@ local function dmarc_callback(task) strict_policy = true quarantine_policy = true elseif (policy ~= 'none') then - failed_policy = true + failed_policy = 'p tag has invalid value' return end end @@ -160,7 +160,7 @@ local function dmarc_callback(task) quarantine_policy = false end else - failed_policy = true + failed_policy = 'sp tag has invalid value' return end end @@ -192,7 +192,10 @@ local function dmarc_callback(task) end end - if failed_policy then return end + if failed_policy then + task:insert_result('DMARC_BAD_POLICY', res, lookup_domain .. ' : ' .. failed_policy) + return + end -- Check dkim and spf symbols local spf_ok = false @@ -264,7 +267,6 @@ local function dmarc_callback(task) end end - -- XXX: handle rua and push data to redis end -- Do initial request -- 2.39.5