From: Vsevolod Stakhov Date: Fri, 12 Nov 2021 21:18:49 +0000 (+0000) Subject: [Minor] Allow headers addition if configured X-Git-Tag: 3.2~265 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=0ec316f2fe69aebdd13789c457a8db92299acad2;p=rspamd.git [Minor] Allow headers addition if configured --- 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)