commit 3203d0f: Merge pull request #2718 from HeinleinSupport/symbol_fail
GitHub
noreply at github.com
Fri Jan 18 15:14:05 UTC 2019
Author: Vsevolod Stakhov
Date: 2019-01-18 15:10:12 +0000
URL: https://github.com/rspamd/rspamd/commit/3203d0f4422fdab18a03abf7fc713c562f15f70e (HEAD -> master)
Merge pull request #2718 from HeinleinSupport/symbol_fail
[Minor] lua_scanners - use pattern for FAIL symbol
conf/modules.d/antivirus.conf | 4 ++++
lualib/lua_scanners/clamav.lua | 12 +++++++++---
lualib/lua_scanners/common.lua | 24 +++++++++++++++++++-----
lualib/lua_scanners/dcc.lua | 7 ++-----
lualib/lua_scanners/fprot.lua | 3 +--
lualib/lua_scanners/icap.lua | 10 +++++-----
lualib/lua_scanners/kaspersky_av.lua | 5 ++---
lualib/lua_scanners/oletools.lua | 9 +++++----
lualib/lua_scanners/savapi.lua | 4 +++-
lualib/lua_scanners/sophos.lua | 25 +++++++------------------
src/plugins/lua/antivirus.lua | 1 +
src/plugins/lua/external_services.lua | 1 +
12 files changed, 59 insertions(+), 46 deletions(-)
diff --combined src/plugins/lua/external_services.lua
index c5889112f,8215279c7..de6615c86
--- a/src/plugins/lua/external_services.lua
+++ b/src/plugins/lua/external_services.lua
@@@ -148,6 -148,7 +148,7 @@@ local function add_scanner_rule(sym, op
end
rule.patterns = common.create_regex_table(opts.patterns or {})
+ rule.patterns_fail = common.create_regex_table(opts.patterns_fail or {})
rule.mime_parts_filter_regex = common.create_regex_table(opts.mime_parts_filter_regex or {})
@@@ -157,7 -158,7 +158,7 @@@
rule.whitelist = rspamd_config:add_hash_map(opts.whitelist)
end
- return function(task)
+ local function scan_cb(task)
if rule.scan_mime_parts then
fun.each(function(p)
@@@ -171,11 -172,6 +172,11 @@@
cfg.check(task, task:get_content(), task:get_digest(), rule)
end
end
+
+ rspamd_logger.infox(rspamd_config, 'registered external services rule: %s',
+ rule.name)
+
+ return scan_cb, rule
end
-- Registration
@@@ -187,12 -183,11 +188,12 @@@ if opts and type(opts) == 'table' the
if type(m) == 'table' and m.servers then
if not m.type then m.type = k end
if not m.name then m.name = k end
- local cb = add_scanner_rule(k, m)
+ local cb, nrule = add_scanner_rule(k, m)
if not cb then
rspamd_logger.errx(rspamd_config, 'cannot add rule: "' .. k .. '"')
else
+ m = nrule
local id = rspamd_config:register_symbol({
type = 'normal',
name = m['symbol'],
@@@ -239,44 -234,6 +240,44 @@@
end
end
end
+
+ if m.symbols then
+ local function reg_symbols(tbl)
+ for _,sym in pairs(tbl) do
+ if type(sym) == 'string' then
+ rspamd_config:register_symbol({
+ type = 'virtual',
+ name = sym,
+ parent = id,
+ group = N
+ })
+ elseif type(sym) == 'table' then
+ if sym.symbol then
+ rspamd_config:register_symbol({
+ type = 'virtual',
+ name = sym.symbol,
+ parent = id,
+ group = N
+ })
+
+ if sym.score then
+ rspamd_config:set_metric_symbol({
+ name = sym.symbol,
+ score = sym.score,
+ description = sym.description,
+ group = sym.group or N,
+ })
+ end
+ else
+ reg_symbols(sym)
+ end
+ end
+ end
+ end
+
+ reg_symbols(m.symbols)
+ end
+
if m['score'] then
-- Register metric symbol
local description = 'external services symbol'
More information about the Commits
mailing list