]> source.dussan.org Git - rspamd.git/commitdiff
[Minor] Filter artificial Received header in multimap by default 1422/head
authorAndrew Lewis <nerf@judo.za.org>
Mon, 13 Feb 2017 16:45:02 +0000 (18:45 +0200)
committerAndrew Lewis <nerf@judo.za.org>
Mon, 13 Feb 2017 16:45:02 +0000 (18:45 +0200)
 - Also filter headers in CHECK_RECEIVED rule

rules/misc.lua
src/plugins/lua/multimap.lua

index d1bd8f9cac7510f7754985046f22d4efd9327813..e7dca4b043f9be19c550164e5cb7fa603b288232 100644 (file)
@@ -17,6 +17,7 @@ limitations under the License.
 -- This is main lua config file for rspamd
 
 local E = {}
+local fun = require "fun"
 local util = require "rspamd_util"
 local rspamd_regexp = require "rspamd_regexp"
 
@@ -610,6 +611,9 @@ rspamd_config:set_metric_symbol('TO_MATCH_ENVRCPT_SOME', 0, 'Some of the recipie
 rspamd_config.CHECK_RECEIVED = {
   callback = function (task)
     local received = task:get_received_headers()
+    received = fun.filter(function(h)
+      return not h['artificial']
+    end, received):totable()
     task:insert_result('RCVD_COUNT_' .. #received, 1.0)
   end
 }
@@ -788,7 +792,6 @@ rspamd_config:register_dependency(freemail_reply_neq_from_id, 'FREEMAIL_FROM')
 
 rspamd_config.OMOGRAPH_URL = {
   callback = function(task)
-    local fun = require "fun"
     local urls = task:get_urls()
 
     if urls then
index bdd9d306961e342ffccfbdddfd18fc464420f737..5afada7896cb7c4c21cf947d12970aa8f9c32c69 100644 (file)
@@ -712,6 +712,11 @@ local function multimap_callback(task, rule)
     received = function()
       local hdrs = task:get_received_headers()
       if hdrs and hdrs[1] then
+        if not rule['artificial'] then
+          hdrs = fun.filter(function(h)
+            return not h['artificial']
+          end, hdrs):totable()
+        end
         for pos, h in ipairs(hdrs) do
           match_received_header(rule, pos, #hdrs, h)
         end