diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2018-07-02 16:00:54 +0100 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2018-07-02 16:00:54 +0100 |
commit | 101782e459ca2cb4f198d38cce844859f3367885 (patch) | |
tree | 70993b7c84f4b53b7a60ca846a1105a6991e7fe6 /src/plugins/lua/antivirus.lua | |
parent | c857ae2c0a4e185173b6b18f1b992973e01a4408 (diff) | |
download | rspamd-101782e459ca2cb4f198d38cce844859f3367885.tar.gz rspamd-101782e459ca2cb4f198d38cce844859f3367885.zip |
[Feature] Allow to configure AV module rejection message
Issue: #2313
Diffstat (limited to 'src/plugins/lua/antivirus.lua')
-rw-r--r-- | src/plugins/lua/antivirus.lua | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/src/plugins/lua/antivirus.lua b/src/plugins/lua/antivirus.lua index 946400743..8e2ddbbbd 100644 --- a/src/plugins/lua/antivirus.lua +++ b/src/plugins/lua/antivirus.lua @@ -33,6 +33,8 @@ antivirus { clamav { # If set force this action if any virus is found (default unset: no action is forced) # action = "reject"; + # If set, then rejection message is set to this value (mention single quotes) + # message = '${SCANNER}: virus found: "${VIRUS}"'; # if `true` only messages with non-image attachments will be checked (default true) attachments_only = true; # If `max_size` is set, messages > n bytes in size are not scanned @@ -64,6 +66,8 @@ antivirus { return end +local default_message = '${SCANNER}: virus found: "${VIRUS}"' + local function match_patterns(default_sym, found, patterns) if type(patterns) ~= 'table' then return default_sym end if not patterns[1] then @@ -113,7 +117,10 @@ local function yield_result(task, rule, vname) vname = table.concat(vname, '; ') end task:set_pre_result(rule['action'], - string.format('%s: virus found: "%s"', rule['type'], vname)) + lua_util.template(rule.message or 'Rejected', { + SCANNER = rule['type'], + VIRUS = vname, + })) end end @@ -125,6 +132,7 @@ local function clamav_config(opts) timeout = 15.0, retransmits = 2, cache_expire = 3600, -- expire redis in one hour + message = default_message, } for k,v in pairs(opts) do @@ -162,6 +170,7 @@ local function fprot_config(opts) log_clean = false, retransmits = 2, cache_expire = 3600, -- expire redis in one hour + message = default_message, } for k,v in pairs(opts) do @@ -199,6 +208,7 @@ local function sophos_config(opts) log_clean = false, retransmits = 2, cache_expire = 3600, -- expire redis in one hour + message = default_message, } for k,v in pairs(opts) do @@ -237,6 +247,7 @@ local function savapi_config(opts) timeout = 15.0, retransmits = 2, cache_expire = 3600, -- expire redis in one hour + message = default_message, } for k,v in pairs(opts) do |