]> source.dussan.org Git - rspamd.git/commitdiff
[Fix] Fix AV scan logic
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Mon, 7 Oct 2019 20:20:33 +0000 (21:20 +0100)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Mon, 7 Oct 2019 20:20:33 +0000 (21:20 +0100)
13 files changed:
lualib/lua_scanners/clamav.lua
lualib/lua_scanners/common.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/kaspersky_se.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/external_services.lua

index 90cd67cef51d3feb33292fb88fb23d4722f91713..04856e079e60d0dcd81f8c147f3a133123cce04c 100644 (file)
@@ -167,7 +167,7 @@ local function clamav_check(task, content, digest, rule)
     })
   end
 
-  if common.need_check(task, content, rule, digest, clamav_check_uncached) then
+  if common.condition_check_and_continue(task, content, rule, digest, clamav_check_uncached) then
     return
   else
     clamav_check_uncached()
index 8f72ce76bbc626c53a4c8b360f5b8895580ced3c..103fce142d3de176ff219cc294ebaded846d15fc 100644 (file)
@@ -212,10 +212,10 @@ local function need_check(task, content, rule, digest, fn)
       end
     end
 
-    local f_message_not_too_large = message_not_too_large(task, content, rule) or true
-    local f_message_not_too_small = message_not_too_small(task, content, rule) or true
-    local f_message_min_words = message_min_words(task, rule) or true
-    local f_dynamic_scan = dynamic_scan(task, rule) or true
+    local f_message_not_too_large = message_not_too_large(task, content, rule)
+    local f_message_not_too_small = message_not_too_small(task, content, rule)
+    local f_message_min_words = message_min_words(task, rule)
+    local f_dynamic_scan = dynamic_scan(task, rule)
 
     if uncached and
       f_message_not_too_large and
@@ -229,7 +229,7 @@ local function need_check(task, content, rule, digest, fn)
 
   end
 
-  if rule.redis_params then
+  if rule.redis_params and not rule.no_cache then
 
     key = rule.prefix .. key
 
@@ -439,7 +439,7 @@ end
 exports.log_clean = log_clean
 exports.yield_result = yield_result
 exports.match_patterns = match_patterns
-exports.need_check = need_check
+exports.condition_check_and_continue = need_check
 exports.save_cache = save_cache
 exports.create_regex_table = create_regex_table
 exports.check_parts_match = check_parts_match
index db1ac44979c410627ad897ed9d4b7d9858da7de2..ac79159901874ef2a64c1c111ea3a983b26da100 100644 (file)
@@ -298,7 +298,7 @@ local function dcc_check(task, content, digest, rule)
     })
   end
 
-  if common.need_check(task, content, rule, digest, dcc_check_uncached) then
+  if common.condition_check_and_continue(task, content, rule, digest, dcc_check_uncached) then
     return
   else
     dcc_check_uncached()
index 4061251cbaf63f97b31b7f5d648f4c4a37d07065..c4261843433a420035c4433a1100ea2c28dfc63c 100644 (file)
@@ -160,7 +160,7 @@ local function fprot_check(task, content, digest, rule)
     })
   end
 
-  if common.need_check(task, content, rule, digest, fprot_check_uncached) then
+  if common.condition_check_and_continue(task, content, rule, digest, fprot_check_uncached) then
     return
   else
     fprot_check_uncached()
index 1f3ada5c9d88221df97adc837bdad84517a6074f..42c32134b8c87e721afc9657176a3d1ce673c883 100644 (file)
@@ -385,7 +385,7 @@ local function icap_check(task, content, digest, rule)
     })
   end
 
-  if common.need_check(task, content, rule, digest, icap_check_uncached) then
+  if common.condition_check_and_continue(task, content, rule, digest, icap_check_uncached) then
     return
   else
     icap_check_uncached()
index 767ff2a942b0609a8ef4ac4218e3e7bc4ff4a4c8..cb94c38da94d34370a204864e98bc957bc65d9aa 100644 (file)
@@ -178,7 +178,7 @@ local function kaspersky_check(task, content, digest, rule)
     })
   end
 
-  if common.need_check(task, content, rule, digest, kaspersky_check_uncached) then
+  if common.condition_check_and_continue(task, content, rule, digest, kaspersky_check_uncached) then
     return
   else
     kaspersky_check_uncached()
index a1c8992c1ece955160e6672f9570af7d9eb80478..ecbe6236f51651b07401d30e249c389ed6e42f03 100644 (file)
@@ -250,9 +250,11 @@ local function kaspersky_se_check(task, content, digest, rule)
     http.request(request_data)
   end
 
-  if common.need_check(task, content, rule, digest, kaspersky_se_check_uncached) then
+  if common.condition_check_and_continue(task, content, rule, digest,
+      kaspersky_se_check_uncached) then
     return
   else
+
     kaspersky_se_check_uncached()
   end
 
index cc973d4d593f5ae25500db23ae657175b4ca3016..4bdf7747d29450ce8567dbcfc6d4da918e81962f 100644 (file)
@@ -304,7 +304,7 @@ local function oletools_check(task, content, digest, rule)
 
   end
 
-  if common.need_check(task, content, rule, digest, oletools_check_uncached) then
+  if common.condition_check_and_continue(task, content, rule, digest, oletools_check_uncached) then
     return
   else
     oletools_check_uncached()
index b36e6e1480fa5c37003e029bd8175a39cded0770..a8b7b63763b35d94137c06bf6c82600a0721863b 100644 (file)
@@ -247,7 +247,7 @@ local function savapi_check(task, content, digest, rule)
     })
   end
 
-  if common.need_check(task, content, rule, digest, savapi_check_uncached) then
+  if common.condition_check_and_continue(task, content, rule, digest, savapi_check_uncached) then
     return
   else
     savapi_check_uncached()
index 60a23c20bb409b34b3847cace68116c3edaa171f..e646daaeafd6cf344ae1a060b73d77524f77c591 100644 (file)
@@ -167,7 +167,7 @@ local function sophos_check(task, content, digest, rule)
     })
   end
 
-  if common.need_check(task, content, rule, digest, sophos_check_uncached) then
+  if common.condition_check_and_continue(task, content, rule, digest, sophos_check_uncached) then
     return
   else
     sophos_check_uncached()
index 06fcf5791d8e654967290fb826f42587b94b987d..715a5e322a1540de6c0fe7d90a2a305691b20800 100644 (file)
@@ -202,7 +202,7 @@ local function spamassassin_check(task, content, digest, rule)
     })
   end
 
-  if common.need_check(task, content, rule, digest, spamassassin_check_uncached) then
+  if common.condition_check_and_continue(task, content, rule, digest, spamassassin_check_uncached) then
     return
   else
     spamassassin_check_uncached()
index 77a9e4dee5d6c5eb8936ae60da49c718e71a477a..238120286b6b384485345277cf661b8df14f54c0 100644 (file)
@@ -310,7 +310,7 @@ local function vade_check(task, content, digest, rule)
     http.request(request_data)
   end
 
-  if common.need_check(task, content, rule, digest, vade_check_uncached) then
+  if common.condition_check_and_continue(task, content, rule, digest, vade_check_uncached) then
     return
   else
     vade_check_uncached()
index 7b20e629c3038cc36ef93e897324bfb7b8db9200..4858979e115eac95c9291735d0ffd8f4b2418c63 100644 (file)
@@ -144,8 +144,10 @@ local function add_scanner_rule(sym, opts)
 
   -- if any mime_part filter defined, do not scan all attachments
   if opts.mime_parts_filter_regex ~= nil
-    or opts.mime_parts_filter_ext ~= nil then
-      rule.scan_all_mime_parts = false
+      or opts.mime_parts_filter_ext ~= nil then
+    rule.scan_all_mime_parts = false
+  else
+    rule.scan_all_mime_parts = true
   end
 
   rule.patterns = common.create_regex_table(opts.patterns or {})