]> source.dussan.org Git - rspamd.git/commitdiff
[Feature] Show the exact value matched for multima symbols
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Sat, 20 Aug 2016 15:39:34 +0000 (16:39 +0100)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Sat, 20 Aug 2016 15:39:55 +0000 (16:39 +0100)
src/plugins/lua/multimap.lua

index 99576a511cb0bd35a636c98b8e0427da7b0c4ec6..d913f7619f72b4adcafddbee00b6dae02d302682 100644 (file)
@@ -28,6 +28,48 @@ require "fun" ()
 
 local urls = {}
 
+local value_types = {
+  ip = {
+    get_value = function(ip) return ip:to_string() end,
+  },
+  from = {
+    get_value = function(val) return val end,
+  },
+  header = {
+    get_value = function(val) return val end,
+  },
+  rcpt = {
+    get_value = function(val) return val end,
+  },
+  user = {
+    get_value = function(val) return val end,
+  },
+  url = {
+    get_value = function(url) return url:get_tld() end,
+  },
+  dnsbl = {
+    get_value = function(ip) return ip:to_string() end,
+  },
+  filename = {
+    get_value = function(val) return val end,
+  },
+  content = {
+    get_value = function(val) return nil end,
+  },
+  hostname = {
+    get_value = function(val) return val end,
+  },
+  asn = {
+    get_value = function(val) return val end,
+  },
+  country = {
+    get_value = function(val) return val end,
+  },
+  mempool = {
+    get_value = function(val) return val end,
+  },
+}
+
 local function ip_to_rbl(ip, rbl)
   return table.concat(ip:inversed_str_octets(), ".") .. '.' .. rbl
 end
@@ -386,7 +428,13 @@ local function multimap_callback(task, rule)
         else
           symbol = r['symbol']
         end
-        task:insert_result(symbol, score)
+
+        local opt = value_types[r['type']].get_value(value)
+        if opt then
+          task:insert_result(symbol, score, opt)
+        else
+          task:insert_result(symbol, score)
+        end
 
         if pre_filter then
           task:set_pre_result(r['action'], 'Matched map: ' .. r['symbol'])