commit 13a09de: [Feature] Multimap: Do not check files in office archives
Vsevolod Stakhov
vsevolod at highsecure.ru
Mon Oct 14 13:56:06 UTC 2019
Author: Vsevolod Stakhov
Date: 2019-10-14 14:55:36 +0100
URL: https://github.com/rspamd/rspamd/commit/13a09de8ed30edd27b3bd8422e75ebd695251f81 (HEAD -> master)
[Feature] Multimap: Do not check files in office archives
---
lualib/lua_magic/init.lua | 2 ++
src/plugins/lua/multimap.lua | 18 +++++++++++++++++-
2 files changed, 19 insertions(+), 1 deletion(-)
diff --git a/lualib/lua_magic/init.lua b/lualib/lua_magic/init.lua
index d92980246..d87e40d58 100644
--- a/lualib/lua_magic/init.lua
+++ b/lualib/lua_magic/init.lua
@@ -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
diff --git a/src/plugins/lua/multimap.lua b/src/plugins/lua/multimap.lua
index 50733d92d..13316583c 100644
--- a/src/plugins/lua/multimap.lua
+++ b/src/plugins/lua/multimap.lua
@@ -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
More information about the Commits
mailing list