]> source.dussan.org Git - rspamd.git/commitdiff
[Minor] Initial implementation of fuzzy hashes extraction tool
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Tue, 3 Jul 2018 17:49:14 +0000 (18:49 +0100)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Tue, 3 Jul 2018 17:49:14 +0000 (18:49 +0100)
lualib/rspamadm/mime.lua

index 2cdec151393cb92e28ad79eeab724121e86a5165..f31fe29f1a5a4b99c9b44abd05603e20a1e9cadf 100644 (file)
@@ -317,6 +317,22 @@ local function stat_handler(opts)
             e.t2 or "", table.concat(fun.totable(
                 fun.map(function(k) return k end, e.flags)), ","))
       end
+    elseif opts.fuzzy then
+      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)
+      end
+      for _,part in ipairs(parts) do
+        if not part:is_multipart() then
+          table.insert(out_elts[fname], {
+            digest = part:get_digest(),
+            file = part:get_filename(),
+            type = string.format('%s/%s', part:get_type())
+          })
+
+        end
+      end
     end
 
     task:destroy() -- No automatic dtor