]> source.dussan.org Git - rspamd.git/commitdiff
[Feature] Add ability to add fuzzy hashes to headers
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Fri, 11 May 2018 16:52:49 +0000 (17:52 +0100)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Fri, 11 May 2018 16:52:49 +0000 (17:52 +0100)
src/plugins/lua/milter_headers.lua

index d693e8f7f8d8603587a2de7c172177159d93efbd..73b268b2e02af5c1e8bff4bf5dbd7ea06e99d105 100644 (file)
@@ -128,6 +128,9 @@ local settings = {
       header = 'X-Stat-Signature',
       remove = 1,
     },
+    ['fuzzy-hashes'] = {
+      header = 'X-Rspamd-Fuzzy',
+    },
   },
 }
 
@@ -342,7 +345,10 @@ local function milter_headers(task)
   end
 
   routines['spam-header'] = function()
-    spam_header('spam-header', settings.routines['spam-header'].header, settings.routines['spam-header'].value, settings.routines['spam-header'].remove)
+    spam_header('spam-header',
+        settings.routines['spam-header'].header,
+        settings.routines['spam-header'].value,
+        settings.routines['spam-header'].remove)
   end
 
   routines['remove-spam-flag'] = function()
@@ -459,6 +465,16 @@ local function milter_headers(task)
     end
   end
 
+  routines['fuzzy-hashes'] = function()
+    local res = task:get_mempool():get_variable("fuzzy_hashes", "fstrings")
+
+    if res and #res > 0 then
+      for _,h in ipairs(res) do
+        add_header(add[settings.routines['fuzzy-hashes'].header], h)
+      end
+    end
+  end
+
   for _, n in ipairs(active_routines) do
     local ok, err
     if custom_routines[n] then