]> git.ipfire.org Git - thirdparty/rspamd.git/commitdiff
[Project] Recognize KAS SE response codes
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Sat, 5 Oct 2019 13:33:41 +0000 (14:33 +0100)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Sat, 5 Oct 2019 13:33:41 +0000 (14:33 +0100)
lualib/lua_scanners/kaspersky_se.lua

index f59cafa47e5974c0d44c79d3bc634c45e3306c2e..b1a35f101218353c4210c1bb552a4db4e5d598c6 100644 (file)
@@ -204,7 +204,45 @@ local function kaspersky_se_check(task, content, digest, rule)
           task:insert_result(rule.symbol_fail, 1.0, 'Bad HTTP code: ' .. code)
           return
         end
-        rspamd_logger.errx(task, 'got reply: %s', body)
+        lua_util.debugm(rule.name, task, 'got reply: %s', body)
+        local data = tostring(body)
+        local cached
+        lua_util.debugm(rule.name, task, '%s: got reply: %s',
+            rule.log_prefix, data)
+        if data == 'CLEAN' then
+          cached = 'CLEAN'
+          if rule['log_clean'] then
+            rspamd_logger.infox(task, '%s: message or mime_part is clean',
+                rule.log_prefix)
+          else
+            lua_util.debugm(rule.name, task, '%s: message or mime_part is clean',
+                rule.log_prefix)
+          end
+        elseif data == 'SERVER_ERROR' then
+          rspamd_logger.errx(task, '%s: error: %s', rule.log_prefix, data)
+          common.yield_result(task, rule, 'error:' .. data,
+              0.0, 'fail')
+        elseif string.match(data, 'DETECT (.+)') then
+          local vname = string.match(data, 'DETECT (.+)')
+          common.yield_result(task, rule, vname)
+          cached = vname
+        elseif string.match(data, 'NON_SCANNED %((.+)%)') then
+          local why = string.match(data, 'NON_SCANNED %((.+)%)')
+
+          if why == 'PASSWORD PROTECTED' then
+            rspamd_logger.errx(task, '%s: File is encrypted', rule.log_prefix)
+            common.yield_result(task, rule, 'File is encrypted: '.. why,
+                0.0, 'encrypted')
+          else
+            common.yield_result(task, rule, 'unhandled response:' .. data, 0.0, 'fail')
+          end
+        else
+          rspamd_logger.errx(task, '%s: unhandled response: %s', rule.log_prefix, data)
+          common.yield_result(task, rule, 'unhandled response:' .. data, 0.0, 'fail')
+        end
+          if cached then
+          common.save_cache(task, digest, rule, cached)
+          end
 
       end
     end