commit bd689b9: [Fix] Arc: Allow to reuse authentication results when doing multi-stage signing

Vsevolod Stakhov vsevolod at highsecure.ru
Tue Sep 8 14:35:08 UTC 2020


Author: Vsevolod Stakhov
Date: 2020-09-08 13:25:55 +0100
URL: https://github.com/rspamd/rspamd/commit/bd689b9b23679860d4e3c9e419f4c46bcb2e04e2

[Fix] Arc: Allow to reuse authentication results when doing multi-stage signing

---
 src/plugins/lua/arc.lua | 33 ++++++++++++++++++++++++++++++---
 1 file changed, 30 insertions(+), 3 deletions(-)

diff --git a/src/plugins/lua/arc.lua b/src/plugins/lua/arc.lua
index 3f21bd3f4..ce6f1e02e 100644
--- a/src/plugins/lua/arc.lua
+++ b/src/plugins/lua/arc.lua
@@ -553,11 +553,38 @@ local function prepare_arc_selector(task, sel)
   if arc_seals then
     sel.arc_idx = #arc_seals + 1
 
-    if task:has_symbol(arc_symbols.allow) then
-      sel.arc_cv = 'pass'
+    local function default_arc_cv()
+      if task:has_symbol(arc_symbols.allow) then
+        sel.arc_cv = 'pass'
+      else
+        sel.arc_cv = 'fail'
+      end
+    end
+
+    if settings.reuse_auth_results then
+      local ar_header = task:get_header('Authentication-Results')
+
+      if ar_header then
+        local arc_match = string.match(ar_header, 'arc=(%w+)')
+
+        if arc_match then
+          if arc_match == 'none' or arc_match == 'pass' then
+            -- none should be converted to `pass`
+            sel.arc_cv = 'pass'
+          else
+            sel.arc_cv = 'fail'
+          end
+        else
+          default_arc_cv()
+        end
+      else
+        -- Cannot reuse, use normal path
+        default_arc_cv()
+      end
     else
-      sel.arc_cv = 'fail'
+      default_arc_cv()
     end
+
   end
 end
 


More information about the Commits mailing list