commit 11cf19b: [Minor] Save into ClickHouse unnamed attaches

Anton Yuzhaninov citrin+git at citrin.ru
Tue Aug 18 19:00:07 UTC 2020


Author: Anton Yuzhaninov
Date: 2020-08-18 18:45:30 +0100
URL: https://github.com/rspamd/rspamd/commit/11cf19b02cfdcf3cafd2cf4bf8becb477e98261b (refs/pull/3474/head)

[Minor] Save into ClickHouse unnamed attaches
Most MUA allow to save attachments (parts with Content-Disposition: attachment)
even if don't have a name.  Keep name field empty and save other
information about such attachments to ClickHouse: Content-Type, size,
digest.

Modify attachments selector as well to return hashes of unnamed
attachments.

---
 lualib/lua_selectors/extractors.lua | 2 +-
 src/plugins/lua/clickhouse.lua      | 8 +++-----
 2 files changed, 4 insertions(+), 6 deletions(-)

diff --git a/lualib/lua_selectors/extractors.lua b/lualib/lua_selectors/extractors.lua
index d88eaa216..4727b389c 100644
--- a/lualib/lua_selectors/extractors.lua
+++ b/lualib/lua_selectors/extractors.lua
@@ -135,7 +135,7 @@ uses any type by default)]],
       local parts = task:get_parts() or E
       local digests = {}
       for i,p in ipairs(parts) do
-        if p:get_filename() then
+        if p:is_attachment() then
           table.insert(digests, common.get_cached_or_raw_digest(task, i, p, args))
         end
       end
diff --git a/src/plugins/lua/clickhouse.lua b/src/plugins/lua/clickhouse.lua
index 734832d57..487997ddd 100644
--- a/src/plugins/lua/clickhouse.lua
+++ b/src/plugins/lua/clickhouse.lua
@@ -726,11 +726,9 @@ local function clickhouse_collect(task)
   local attachments_ctypes = {}
   local attachments_lengths = {}
   local attachments_digests = {}
-  for _,part in ipairs(task:get_parts()) do
-    local fname = part:get_filename()
-
-    if fname then
-      table.insert(attachments_fnames, fname)
+  for _, part in ipairs(task:get_parts()) do
+    if part:is_attachment() then
+      table.insert(attachments_fnames, part:get_filename() or '')
       local mime_type, mime_subtype = part:get_type()
       table.insert(attachments_ctypes, string.format("%s/%s", mime_type, mime_subtype))
       table.insert(attachments_lengths, part:get_length())


More information about the Commits mailing list