]> source.dussan.org Git - rspamd.git/commitdiff
[Feature] Multimap: Do not check files in office archives
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Mon, 14 Oct 2019 13:55:36 +0000 (14:55 +0100)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Mon, 14 Oct 2019 13:55:36 +0000 (14:55 +0100)
lualib/lua_magic/init.lua
src/plugins/lua/multimap.lua

index d92980246d09a5ce5a8b39551cc791cd05a61353..d87e40d58727f4b6aa23feddacc3e2dda974fc52 100644 (file)
@@ -361,4 +361,6 @@ end
 -- Rspamd checks 2 chunks at start and 1 chunk at the end
 exports.chunk_size = 32768
 
+exports.types = types
+
 return exports
\ No newline at end of file
index 50733d92dec1ed1a77ffbda2ab573e2cc53a0d71..13316583ca193d541138f9a7fdd8fee273a16872 100644 (file)
@@ -868,8 +868,24 @@ local function multimap_callback(task, rule)
         return p:is_attachment() or (not p:is_text()) and (not p:is_multipart())
       end
 
+      local function filter_archive(p)
+        local ext = p:get_detected_ext()
+        local det_type = 'unknown'
+
+        if ext then
+          local lua_magic_types = require "lua_magic/types"
+          local det_t = lua_magic_types[ext]
+
+          if det_t then
+            det_type = det_t.type
+          end
+        end
+
+        return p:is_archive() and det_type == 'archive' and not rule.skip_archives
+      end
+
       for _,p in fun.iter(fun.filter(filter_parts, parts)) do
-        if p:is_archive() and not rule['skip_archives'] then
+        if filter_archive(p) then
           local fnames = p:get_archive():get_files()
 
           for _,fn in ipairs(fnames) do