commit 0e8dbac: [Fix] Fix AV scan logic
Vsevolod Stakhov
vsevolod at highsecure.ru
Mon Oct 7 20:21:08 UTC 2019
Author: Vsevolod Stakhov
Date: 2019-10-07 21:20:33 +0100
URL: https://github.com/rspamd/rspamd/commit/0e8dbac3d41dcf47c06ea05484a0df40b393660f (HEAD -> master)
[Fix] Fix AV scan logic
---
lualib/lua_scanners/clamav.lua | 2 +-
lualib/lua_scanners/common.lua | 12 ++++++------
lualib/lua_scanners/dcc.lua | 2 +-
lualib/lua_scanners/fprot.lua | 2 +-
lualib/lua_scanners/icap.lua | 2 +-
lualib/lua_scanners/kaspersky_av.lua | 2 +-
lualib/lua_scanners/kaspersky_se.lua | 4 +++-
lualib/lua_scanners/oletools.lua | 2 +-
lualib/lua_scanners/savapi.lua | 2 +-
lualib/lua_scanners/sophos.lua | 2 +-
lualib/lua_scanners/spamassassin.lua | 2 +-
lualib/lua_scanners/vadesecure.lua | 2 +-
src/plugins/lua/external_services.lua | 6 ++++--
13 files changed, 23 insertions(+), 19 deletions(-)
diff --git a/lualib/lua_scanners/clamav.lua b/lualib/lua_scanners/clamav.lua
index 90cd67cef..04856e079 100644
--- a/lualib/lua_scanners/clamav.lua
+++ b/lualib/lua_scanners/clamav.lua
@@ -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()
diff --git a/lualib/lua_scanners/common.lua b/lualib/lua_scanners/common.lua
index 8f72ce76b..103fce142 100644
--- a/lualib/lua_scanners/common.lua
+++ b/lualib/lua_scanners/common.lua
@@ -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
diff --git a/lualib/lua_scanners/dcc.lua b/lualib/lua_scanners/dcc.lua
index db1ac4497..ac7915990 100644
--- a/lualib/lua_scanners/dcc.lua
+++ b/lualib/lua_scanners/dcc.lua
@@ -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()
diff --git a/lualib/lua_scanners/fprot.lua b/lualib/lua_scanners/fprot.lua
index 4061251cb..c42618434 100644
--- a/lualib/lua_scanners/fprot.lua
+++ b/lualib/lua_scanners/fprot.lua
@@ -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()
diff --git a/lualib/lua_scanners/icap.lua b/lualib/lua_scanners/icap.lua
index 1f3ada5c9..42c32134b 100644
--- a/lualib/lua_scanners/icap.lua
+++ b/lualib/lua_scanners/icap.lua
@@ -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()
diff --git a/lualib/lua_scanners/kaspersky_av.lua b/lualib/lua_scanners/kaspersky_av.lua
index 767ff2a94..cb94c38da 100644
--- a/lualib/lua_scanners/kaspersky_av.lua
+++ b/lualib/lua_scanners/kaspersky_av.lua
@@ -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()
diff --git a/lualib/lua_scanners/kaspersky_se.lua b/lualib/lua_scanners/kaspersky_se.lua
index a1c8992c1..ecbe6236f 100644
--- a/lualib/lua_scanners/kaspersky_se.lua
+++ b/lualib/lua_scanners/kaspersky_se.lua
@@ -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
diff --git a/lualib/lua_scanners/oletools.lua b/lualib/lua_scanners/oletools.lua
index cc973d4d5..4bdf7747d 100644
--- a/lualib/lua_scanners/oletools.lua
+++ b/lualib/lua_scanners/oletools.lua
@@ -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()
diff --git a/lualib/lua_scanners/savapi.lua b/lualib/lua_scanners/savapi.lua
index b36e6e148..a8b7b6376 100644
--- a/lualib/lua_scanners/savapi.lua
+++ b/lualib/lua_scanners/savapi.lua
@@ -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()
diff --git a/lualib/lua_scanners/sophos.lua b/lualib/lua_scanners/sophos.lua
index 60a23c20b..e646daaea 100644
--- a/lualib/lua_scanners/sophos.lua
+++ b/lualib/lua_scanners/sophos.lua
@@ -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()
diff --git a/lualib/lua_scanners/spamassassin.lua b/lualib/lua_scanners/spamassassin.lua
index 06fcf5791..715a5e322 100644
--- a/lualib/lua_scanners/spamassassin.lua
+++ b/lualib/lua_scanners/spamassassin.lua
@@ -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()
diff --git a/lualib/lua_scanners/vadesecure.lua b/lualib/lua_scanners/vadesecure.lua
index 77a9e4dee..238120286 100644
--- a/lualib/lua_scanners/vadesecure.lua
+++ b/lualib/lua_scanners/vadesecure.lua
@@ -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()
diff --git a/src/plugins/lua/external_services.lua b/src/plugins/lua/external_services.lua
index 7b20e629c..4858979e1 100644
--- a/src/plugins/lua/external_services.lua
+++ b/src/plugins/lua/external_services.lua
@@ -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 {})
More information about the Commits
mailing list