]> source.dussan.org Git - rspamd.git/commitdiff
[Minor] lua_scanners - try dynamic scan
authorCarsten Rosenberg <c.rosenberg@heinlein-support.de>
Mon, 28 Jan 2019 10:30:33 +0000 (11:30 +0100)
committerCarsten Rosenberg <c.rosenberg@heinlein-support.de>
Mon, 29 Apr 2019 18:10:12 +0000 (20:10 +0200)
12 files changed:
lualib/lua_scanners/clamav.lua
lualib/lua_scanners/dcc.lua
lualib/lua_scanners/fprot.lua
lualib/lua_scanners/icap.lua
lualib/lua_scanners/kaspersky_av.lua
lualib/lua_scanners/oletools.lua
lualib/lua_scanners/savapi.lua
lualib/lua_scanners/sophos.lua
lualib/lua_scanners/spamassassin.lua
lualib/lua_scanners/vadesecure.lua
src/plugins/lua/antivirus.lua
src/plugins/lua/external_services.lua

index 1ff3cdc4fdeae1c522f32a8a58cf04f90f54bb07..01386cfe71f189aeeadcdc81a65373044b8b2f80 100644 (file)
@@ -156,6 +156,14 @@ local function clamav_check(task, content, digest, rule)
       end
     end
 
+    if rule.dynamic_scan then
+      local pre_check, pre_check_msg = common.check_metric_results(task, rule)
+      if pre_check then
+        rspamd_logger.infox(task, '%s: aborting: %s', rule.log_prefix, pre_check_msg)
+        return true
+      end
+    end
+
     tcp.request({
       task = task,
       host = addr:to_string(),
index e775d698b6fef74b4ec750c276b42d2ccc65559e..d1bec769b757b565be6016e7dd995ac395bbd493 100644 (file)
@@ -226,6 +226,14 @@ local function dcc_check(task, content, digest, rule)
       end
     end
 
+    if rule.dynamic_scan then
+      local pre_check, pre_check_msg = common.check_metric_results(task, rule)
+      if pre_check then
+        rspamd_logger.infox(task, '%s: aborting: %s', rule.log_prefix, pre_check_msg)
+        return true
+      end
+    end
+
     tcp.request({
       task = task,
       host = addr:to_string(),
index e624bc6fd0e3e7da595e825ec08f7b896cc56845..907fab13996473294ce8147b95f8d6487ef64270 100644 (file)
@@ -149,6 +149,14 @@ local function fprot_check(task, content, digest, rule)
       end
     end
 
+    if rule.dynamic_scan then
+      local pre_check, pre_check_msg = common.check_metric_results(task, rule)
+      if pre_check then
+        rspamd_logger.infox(task, '%s: aborting: %s', rule.log_prefix, pre_check_msg)
+        return true
+      end
+    end
+
     tcp.request({
       task = task,
       host = addr:to_string(),
index 6ddd5fee660d7bcb2dec33fec8155a03313cf690..d00954f419d24ea46a7a0c356293c369a532df4b 100644 (file)
@@ -242,6 +242,14 @@ local function icap_check(task, content, digest, rule)
       end
     end
 
+    if rule.dynamic_scan then
+      local pre_check, pre_check_msg = common.check_metric_results(task, rule)
+      if pre_check then
+        rspamd_logger.infox(task, '%s: aborting: %s', rule.log_prefix, pre_check_msg)
+        return true
+      end
+    end
+
     tcp.request({
       task = task,
       host = addr:to_string(),
index d87f78886b77f2bb2fedc67f658c32038bd3ca12..87411c3b97b49f6a2639b21bf06fd4a7dcd3c6bc 100644 (file)
@@ -167,6 +167,14 @@ local function kaspersky_check(task, content, digest, rule)
       end
     end
 
+    if rule.dynamic_scan then
+      local pre_check, pre_check_msg = common.check_metric_results(task, rule)
+      if pre_check then
+        rspamd_logger.infox(task, '%s: aborting: %s', rule.log_prefix, pre_check_msg)
+        return true
+      end
+    end
+
     tcp.request({
       task = task,
       host = addr:to_string(),
index d16c1877f45ec75b3b6394f23c919d2db5c57916..236e1903c051777ab99f56d588fb3ec9c9f8d7a9 100644 (file)
@@ -225,6 +225,14 @@ local function oletools_check(task, content, digest, rule)
       end
     end
 
+    if rule.dynamic_scan then
+      local pre_check, pre_check_msg = common.check_metric_results(task, rule)
+      if pre_check then
+        rspamd_logger.infox(task, '%s: aborting: %s', rule.log_prefix, pre_check_msg)
+        return true
+      end
+    end
+
     tcp.request({
       task = task,
       host = addr:to_string(),
@@ -263,6 +271,8 @@ local function oletools_config(opts)
     default_score = 1,
     action = false,
     extended = false,
+    symbol_type = 'postfilter',
+    dynamic_scan = true,
   }
 
   oletools_conf = lua_util.override_defaults(oletools_conf, opts)
index 13dbb7136782b714cee5f840bd667d8d6ac843e8..65a9c825c2a28324626f55352e1454e264dcd222 100644 (file)
@@ -237,6 +237,14 @@ local function savapi_check(task, content, digest, rule)
       end
     end
 
+    if rule.dynamic_scan then
+      local pre_check, pre_check_msg = common.check_metric_results(task, rule)
+      if pre_check then
+        rspamd_logger.infox(task, '%s: aborting: %s', rule.log_prefix, pre_check_msg)
+        return true
+      end
+    end
+
     tcp.request({
       task = task,
       host = addr:to_string(),
index 159e8abdc5e567477fc7f05d9df3ee365f2c48e5..59facc84528a17bb20fbb787838773486fd87506 100644 (file)
@@ -41,9 +41,7 @@ local function sophos_config(opts)
     retransmits = 2,
     cache_expire = 3600, -- expire redis in one hour
     message = default_message,
-    savdi_report_encrypted = false,
     detection_category = "virus",
-    savdi_report_oversize = false,
   }
 
   sophos_conf = lua_util.override_defaults(sophos_conf, opts)
@@ -159,6 +157,14 @@ local function sophos_check(task, content, digest, rule)
       end
     end
 
+    if rule.dynamic_scan then
+      local pre_check, pre_check_msg = common.check_metric_results(task, rule)
+      if pre_check then
+        rspamd_logger.infox(task, '%s: aborting: %s', rule.log_prefix, pre_check_msg)
+        return true
+      end
+    end
+
     tcp.request({
       task = task,
       host = addr:to_string(),
index eae934610c66b8c96f05ffaaa82ff1588c49b97b..2227de235995f0002310f345d95f091599594b81 100644 (file)
@@ -136,6 +136,14 @@ local function spamassassin_check(task, content, digest, rule)
       end
     end
 
+    if rule.dynamic_scan then
+      local pre_check, pre_check_msg = common.check_metric_results(task, rule)
+      if pre_check then
+        rspamd_logger.infox(task, '%s: aborting: %s', rule.log_prefix, pre_check_msg)
+        return true
+      end
+    end
+
     tcp.request({
       task = task,
       host = addr:to_string(),
@@ -172,6 +180,8 @@ local function spamassassin_config(opts)
     default_score = 1,
     action = false,
     extended = false,
+    symbol_type = 'postfilter',
+    dynamic_scan = true,
   }
 
   spamassassin_conf = lua_util.override_defaults(spamassassin_conf, opts)
index 64660ff411263bfc902dcab14e8547567807dca2..5c986970e6c782c98991a570c05fac5c76f84039 100644 (file)
@@ -24,6 +24,7 @@ local http = require "rspamd_http"
 local upstream_list = require "rspamd_upstream_list"
 local rspamd_logger = require "rspamd_logger"
 local ucl = require "ucl"
+local common = require "lua_scanners/common"
 
 local N = 'vadesecure'
 
@@ -181,6 +182,14 @@ local function vade_check(task, content, digest, rule)
     end
   end
 
+  if rule.dynamic_scan then
+    local pre_check, pre_check_msg = common.check_metric_results(task, rule)
+    if pre_check then
+      rspamd_logger.infox(task, '%s: aborting: %s', rule.log_prefix, pre_check_msg)
+      return true
+    end
+  end
+
   request_data.callback = vade_callback
   http.request(request_data)
 end
index 70549719f6b94e5fcffeef83ea9cc3ed2c0cfa06..cb89a264f7ca227cc085c5e693184165934ccad8 100644 (file)
@@ -149,13 +149,23 @@ if opts and type(opts) == 'table' then
       if not cb then
         rspamd_logger.errx(rspamd_config, 'cannot add rule: "' .. k .. '"')
       else
-        local id = rspamd_config:register_symbol({
-          type = 'normal',
-          name = m['symbol'],
+
+        local t = {
+          name = m.symbol,
           callback = cb,
           score = 0.0,
           group = N
-        })
+        }
+
+        if m.symbol_type == 'postfilter' then
+          t.type = 'postfilter'
+          t.priority = 3
+        else
+          t.type = 'normal'
+        end
+
+        local id = rspamd_config:register_symbol(t)
+
         rspamd_config:register_symbol({
           type = 'virtual',
           name = m['symbol_fail'],
index 056eefcee5431c060b7d0071fa22fcd8f4a8c5a9..9aba7f8a62b839d2952a3a5ee87cf307f36fa510 100644 (file)
@@ -194,13 +194,23 @@ if opts and type(opts) == 'table' then
         rspamd_logger.errx(rspamd_config, 'cannot add rule: "' .. k .. '"')
       else
         m = nrule
-        local id = rspamd_config:register_symbol({
-          type = 'normal',
-          name = m['symbol'],
+
+        local t = {
+          name = m.symbol,
           callback = cb,
           score = 0.0,
           group = N
-        })
+        }
+
+        if m.symbol_type == 'postfilter' then
+          t.type = 'postfilter'
+          t.priority = 3
+        else
+          t.type = 'normal'
+        end
+
+        local id = rspamd_config:register_symbol(t)
+
         rspamd_config:register_symbol({
           type = 'virtual,nostat',
           name = m['symbol_fail'],