aboutsummaryrefslogtreecommitdiffstats
path: root/lualib/lua_scanners/cloudmark.lua
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2021-11-12 21:18:49 +0000
committerVsevolod Stakhov <vsevolod@highsecure.ru>2021-11-12 21:18:49 +0000
commit0ec316f2fe69aebdd13789c457a8db92299acad2 (patch)
treefff312d3ea9836506405665e942e6d7d31e4d320 /lualib/lua_scanners/cloudmark.lua
parent4a0bb98bef3e80e02d6f995988244266eb8893bf (diff)
downloadrspamd-0ec316f2fe69aebdd13789c457a8db92299acad2.tar.gz
rspamd-0ec316f2fe69aebdd13789c457a8db92299acad2.zip
[Minor] Allow headers addition if configured
Diffstat (limited to 'lualib/lua_scanners/cloudmark.lua')
-rw-r--r--lualib/lua_scanners/cloudmark.lua13
1 files changed, 13 insertions, 0 deletions
diff --git a/lualib/lua_scanners/cloudmark.lua b/lualib/lua_scanners/cloudmark.lua
index bfea884cb..5993c4fe2 100644
--- a/lualib/lua_scanners/cloudmark.lua
+++ b/lualib/lua_scanners/cloudmark.lua
@@ -27,6 +27,7 @@ local ucl = require "ucl"
local rspamd_util = require "rspamd_util"
local common = require "lua_scanners/common"
local fun = require "fun"
+local lua_mime = require "lua_mime"
local N = 'cloudmark'
-- Boundary for multipart transfers, generated on module init
@@ -108,6 +109,7 @@ local function cloudmark_config(opts)
symbol_fail = 'CLOUDMARK_FAIL',
symbol = 'CLOUDMARK_CHECK',
symbol_spam = 'CLOUDMARK_SPAM',
+ add_headers = false, -- allow addition of the headers from Cloudmark
}
cloudmark_conf = lua_util.override_defaults(cloudmark_conf, opts)
@@ -225,6 +227,17 @@ local function parse_cloudmark_reply(task, rule, body)
task:insert_result(rule.symbol_spam, 1.0, tostring(score))
end
+ if rule.add_headers and type(obj.appendHeaders) == 'table' then
+ local headers_add = fun.tomap(fun.map(function(h)
+ return h.headerField,{
+ order = 1, value = h.body
+ }
+ end, obj.appendHeaders))
+ lua_mime.modify_headers(task, {
+ add = headers_add
+ })
+ end
+
end
local function cloudmark_check(task, content, digest, rule, maybe_part)