commit 259a51c: [Minor] lua_scanners - fix small errors

Carsten Rosenberg c.rosenberg at heinlein-support.de
Fri Oct 4 10:42:16 UTC 2019


Author: Carsten Rosenberg
Date: 2019-09-27 14:06:41 +0200
URL: https://github.com/rspamd/rspamd/commit/259a51ccefbac3e48bfcc0501be963d5baf10bc4

[Minor] lua_scanners - fix small errors

---
 lualib/lua_scanners/common.lua |  2 +-
 lualib/lua_scanners/icap.lua   | 21 +++++++++++++++------
 2 files changed, 16 insertions(+), 7 deletions(-)

diff --git a/lualib/lua_scanners/common.lua b/lualib/lua_scanners/common.lua
index dcd31db30..64f67dcc8 100644
--- a/lualib/lua_scanners/common.lua
+++ b/lualib/lua_scanners/common.lua
@@ -207,7 +207,7 @@ local function check_cache(task, digest, rule, fn)
       if err then
         rspamd_logger.errx(task, 'got error checking cache: %s', err)
       end
-      fn()
+      return true
     end
   end
 
diff --git a/lualib/lua_scanners/icap.lua b/lualib/lua_scanners/icap.lua
index c7b495c29..d43ba4f78 100644
--- a/lualib/lua_scanners/icap.lua
+++ b/lualib/lua_scanners/icap.lua
@@ -243,20 +243,29 @@ local function icap_check(task, content, digest, rule)
             table.insert(threat_string, icap_headers['X-Virus-ID'])
           end
         elseif icap_headers['X-FSecure-Scan-Result'] ~= nil and icap_headers['X-FSecure-Scan-Result'] ~= "clean" then
+
+          local infected_filename = ""
+          local infection_name = "-unknown-"
+
+          if icap_headers['X-FSecure-Infected-Filename'] ~= nil then
+            infected_filename = string.gsub(icap_headers['X-FSecure-Infected-Filename'], '[%s"]', '')
+          end
+          if icap_headers['X-FSecure-Infection-Name'] ~= nil then
+            infection_name = string.gsub(icap_headers['X-FSecure-Infection-Name'], '[%s"]', '')
+          end
+
           lua_util.debugm(rule.name, task,
               '%s: icap X-FSecure-Infection-Name (X-FSecure-Infected-Filename): %s (%s)',
-              rule.log_prefix, string.gsub(icap_headers['X-FSecure-Infection-Name'], '[%s"]', ''),
-              string.gsub(icap_headers['X-FSecure-Infected-Filename:'], '[%s"]', ''))
+              rule.log_prefix, infection_name, infected_filename)
 
-          if string.find(icap_headers['X-FSecure-Infection-Name'], ', ') then
-            local vnames = rspamd_str_split(string.gsub(icap_headers['X-FSecure-Infection-Name'], '[%s"]', '')
-              , ',') or {}
+          if string.find(infection_name, ', ') then
+            local vnames = rspamd_str_split(infection_name, ',') or {}
 
             for _,v in ipairs(vnames) do
               table.insert(threat_string, v)
             end
           else
-            table.insert(threat_string, string.gsub(icap_headers['X-FSecure-Infection-Name'], '[%s"]', ''))
+            table.insert(threat_string, infection_name)
           end
         end
         if #threat_string > 0 then


More information about the Commits mailing list