]> 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, 18 Mar 2019 09:45:16 +0000 (10:45 +0100)
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 b3a1b20f21c1db67eb6e20b138f6933d9037073b..43a5ff4c2c3457c2bd0ecdd838bafa75fb7cc435 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 577b79863abe68ef2ffa43c381d8f9d3d385b946..df3c3eb636c61ba0e5d441b1c869359d9591663a 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 99ac19b3082f1e9a1672b33437601b59099cc740..c1d2335c51f128ea9295752bda34ad0b1e317e8e 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 68dcedb64b31f3e17b11b2eec63071967ba90ee1..02886d4dedd9e39465a5c4b262ae88504e09610b 100644 (file)
@@ -144,13 +144,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 de6615c863a0bcbca9fdaeb8e8a5236fba173783..fe2748192feefbd68fdd1bd4507b6ed70f920e14 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',
           name = m['symbol_fail'],