diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2018-07-04 15:51:29 +0100 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2018-07-04 15:54:39 +0100 |
commit | 24e056d1d43ac9ff487aa370b9dbc3c467eead0e (patch) | |
tree | 6f6f33b4e80dbd8e6d087e194822ddccb837f5db /lualib/rspamadm | |
parent | 5d3677f48bf7b0493bab5cae6f7928f9a878f320 (diff) | |
download | rspamd-24e056d1d43ac9ff487aa370b9dbc3c467eead0e.tar.gz rspamd-24e056d1d43ac9ff487aa370b9dbc3c467eead0e.zip |
[Feature] Implement fuzzy hashes extraction in mime tool
Diffstat (limited to 'lualib/rspamadm')
-rw-r--r-- | lualib/rspamadm/mime.lua | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/lualib/rspamadm/mime.lua b/lualib/rspamadm/mime.lua index f41529646..e07f1142a 100644 --- a/lualib/rspamadm/mime.lua +++ b/lualib/rspamadm/mime.lua @@ -92,6 +92,8 @@ stat:mutex( stat:flag "-F --fuzzy" :description "Fuzzy hashes" ) +stat:flag "-s --shingles" + :description "Show shingles for fuzzy hashes" local urls = parser:command "urls url u" :description "Extracts URLs from MIME messages" @@ -321,7 +323,16 @@ local function stat_handler(opts) local parts = task:get_parts() or {} out_elts[fname] = {} process_func = function(e) - return string.format('part: %s(%s): %s', e.type, e.file or "", e.digest) + local ret = string.format('part: %s(%s): %s', e.type, e.file or "", e.digest) + if opts.shingles and e.shingles then + local sgl = {} + for _,s in ipairs(e.shingles) do + table.insert(sgl, string.format('%s: %s+%s+%s', s[1], s[2], s[3], s[4])) + end + + ret = ret .. '\n' .. table.concat(sgl, '\n') + end + return ret end for _,part in ipairs(parts) do if not part:is_multipart() then @@ -331,7 +342,7 @@ local function stat_handler(opts) local digest,shingles = text:get_fuzzy_hashes(task:get_mempool()) table.insert(out_elts[fname], { digest = digest, - shingles = rspamd_logger.slog('%s', shingles), + shingles = shingles, type = string.format('%s/%s', part:get_type()) }) else |