aboutsummaryrefslogtreecommitdiffstats
path: root/lualib/lua_magic
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2019-09-07 15:11:21 +0100
committerVsevolod Stakhov <vsevolod@highsecure.ru>2019-09-07 15:11:21 +0100
commit0f4f770639d8ca2f472df95ba6dab6fa27e5772a (patch)
treeb2e3f1320b21f719842808444fe2095c2bf3188a /lualib/lua_magic
parent189fea9a636ed0e1fb4525c697fe4c8ff4af8659 (diff)
downloadrspamd-0f4f770639d8ca2f472df95ba6dab6fa27e5772a.tar.gz
rspamd-0f4f770639d8ca2f472df95ba6dab6fa27e5772a.zip
[Project] Lua_magic: Support ole documents recognition
Diffstat (limited to 'lualib/lua_magic')
-rw-r--r--lualib/lua_magic/init.lua2
-rw-r--r--lualib/lua_magic/patterns.lua13
-rw-r--r--lualib/lua_magic/types.lua21
3 files changed, 35 insertions, 1 deletions
diff --git a/lualib/lua_magic/init.lua b/lualib/lua_magic/init.lua
index 98d4845eb..59e2a6e36 100644
--- a/lualib/lua_magic/init.lua
+++ b/lualib/lua_magic/init.lua
@@ -140,7 +140,7 @@ local function match_chunk(chunk, input, tlen, offset, trie, processed_tbl, log_
if not res[ext] then
res[ext] = 0
end
- if match.weight then
+ if weight then
res[ext] = res[ext] + weight
else
res[ext] = res[ext] + 1
diff --git a/lualib/lua_magic/patterns.lua b/lualib/lua_magic/patterns.lua
index 003073cab..9bb6df182 100644
--- a/lualib/lua_magic/patterns.lua
+++ b/lualib/lua_magic/patterns.lua
@@ -19,6 +19,8 @@ limitations under the License.
-- This module contains most common patterns
--]]
+local heuristics = require "lua_magic/heuristics"
+
local patterns = {
pdf = {
-- These are alternatives
@@ -82,6 +84,17 @@ local patterns = {
}
}
},
+ -- MS Office format, needs heuristic
+ ole = {
+ matches = {
+ {
+ hex = [[d0cf11e0a1b11ae1]],
+ relative_position = 0,
+ weight = 60,
+ heuristic = heuristics.ole_format_heuristic
+ }
+ }
+ },
-- MS Exe file
exe = {
matches = {
diff --git a/lualib/lua_magic/types.lua b/lualib/lua_magic/types.lua
index b3af668c8..96c4952a8 100644
--- a/lualib/lua_magic/types.lua
+++ b/lualib/lua_magic/types.lua
@@ -130,6 +130,27 @@ local types = {
ct = 'application/x-shockwave-flash',
type = 'image',
},
+ -- Ole files
+ ole = {
+ ct = 'application/octet-stream',
+ type = 'msoffice'
+ },
+ doc = {
+ ct = 'application/msword',
+ type = 'msoffice'
+ },
+ xls = {
+ ct = 'application/vnd.ms-excel',
+ type = 'msoffice'
+ },
+ ppt = {
+ ct = 'application/vnd.ms-powerpoint',
+ type = 'msoffice'
+ },
+ msi = {
+ ct = 'application/x-msi',
+ type = 'executable'
+ },
-- other
pgp = {
ct = 'application/encrypted',