Skip to content

Commit

Permalink
[Minor] lua_scanners - try dynamic scan
Browse files Browse the repository at this point in the history
  • Loading branch information
c-rosenberg committed Mar 18, 2019
1 parent dbfdd2b commit 71d2b74
Show file tree
Hide file tree
Showing 12 changed files with 113 additions and 10 deletions.
8 changes: 8 additions & 0 deletions lualib/lua_scanners/clamav.lua
Expand Up @@ -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(),
Expand Down
8 changes: 8 additions & 0 deletions lualib/lua_scanners/dcc.lua
Expand Up @@ -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(),
Expand Down
8 changes: 8 additions & 0 deletions lualib/lua_scanners/fprot.lua
Expand Up @@ -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(),
Expand Down
8 changes: 8 additions & 0 deletions lualib/lua_scanners/icap.lua
Expand Up @@ -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(),
Expand Down
8 changes: 8 additions & 0 deletions lualib/lua_scanners/kaspersky_av.lua
Expand Up @@ -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(),
Expand Down
10 changes: 10 additions & 0 deletions lualib/lua_scanners/oletools.lua
Expand Up @@ -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(),
Expand Down Expand Up @@ -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)
Expand Down
8 changes: 8 additions & 0 deletions lualib/lua_scanners/savapi.lua
Expand Up @@ -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(),
Expand Down
10 changes: 8 additions & 2 deletions lualib/lua_scanners/sophos.lua
Expand Up @@ -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)
Expand Down Expand Up @@ -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(),
Expand Down
10 changes: 10 additions & 0 deletions lualib/lua_scanners/spamassassin.lua
Expand Up @@ -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(),
Expand Down Expand Up @@ -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)
Expand Down
9 changes: 9 additions & 0 deletions lualib/lua_scanners/vadesecure.lua
Expand Up @@ -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'
Expand Down Expand Up @@ -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
Expand Down
18 changes: 14 additions & 4 deletions src/plugins/lua/antivirus.lua
Expand Up @@ -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'],
Expand Down
18 changes: 14 additions & 4 deletions src/plugins/lua/external_services.lua
Expand Up @@ -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'],
Expand Down

0 comments on commit 71d2b74

Please sign in to comment.