diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2020-04-13 15:16:15 +0100 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2020-04-13 15:16:15 +0100 |
commit | fe8df9944b2132bbb421b0291852e32b7dfdcf92 (patch) | |
tree | 1b0cee02e9424c94ea4c304ac1806cf936c49829 /lualib/lua_content/pdf.lua | |
parent | 592ededbbef6bcff2031b112b510d559008510e9 (diff) | |
download | rspamd-fe8df9944b2132bbb421b0291852e32b7dfdcf92.tar.gz rspamd-fe8df9944b2132bbb421b0291852e32b7dfdcf92.zip |
[Minor] Lua_content: Process xref objects and detect encryption there
Diffstat (limited to 'lualib/lua_content/pdf.lua')
-rw-r--r-- | lualib/lua_content/pdf.lua | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/lualib/lua_content/pdf.lua b/lualib/lua_content/pdf.lua index c69c9e3d2..b410c2a14 100644 --- a/lualib/lua_content/pdf.lua +++ b/lualib/lua_content/pdf.lua @@ -408,6 +408,10 @@ end -- Conditionally extract stream data from object and attach it as obj.uncompressed local function maybe_extract_object_stream(obj, pdf, task) + if pdf.encrypted then + -- TODO add decryption some day + return nil + end local dict = obj.dict if dict.Length then local len = math.min(obj.stream.len, @@ -607,6 +611,17 @@ local function process_catalog(task, pdf, obj) end end +local function process_xref(task, pdf, obj) + if obj.dict then + if obj.dict.Encrypt then + local encrypt = maybe_dereference_object(obj.dict.Encrypt, pdf, task) + lua_util.debugm(N, task, 'found encrypt: %s in xref object %s:%s', + encrypt, obj.major, obj.minor) + pdf.encrypted = true + end + end +end + process_dict = function(task, pdf, obj, dict) if not obj.type and type(dict) == 'table' then if dict.Type and type(dict.Type) == 'string' then @@ -705,6 +720,9 @@ process_dict = function(task, pdf, obj, dict) process_action(task, pdf, obj) elseif obj.type == 'Catalog' then process_catalog(task, pdf, obj) + elseif obj.type == 'XRef' then + -- XRef stream instead of trailer from PDF 1.5 (thanks Adobe) + process_xref(task, pdf, obj) elseif obj.type == 'Javascript' then local js = maybe_dereference_object(obj.dict.JS, pdf, task) |