]> source.dussan.org Git - rspamd.git/commitdiff
[Feature] Add DMARC_BAD_POLICY symbol when DMARC policy was invalid
authorAndrew Lewis <nerf@judo.za.org>
Sun, 31 Jul 2016 13:33:48 +0000 (15:33 +0200)
committerAndrew Lewis <nerf@judo.za.org>
Sun, 31 Jul 2016 13:33:48 +0000 (15:33 +0200)
src/plugins/lua/dmarc.lua

index d162b11640650306a0b8108d20a5f1b955369ee0..45a30054aeffb772ae7176eea248a10a17ef5279 100644 (file)
@@ -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