aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/lua
diff options
context:
space:
mode:
authorAndrew Lewis <nerf@judo.za.org>2016-09-30 15:13:38 +0200
committerAndrew Lewis <nerf@judo.za.org>2016-09-30 15:13:38 +0200
commitb561e9b9cbd86191aec1e51cc776d083b66b14b5 (patch)
tree75f11a5a2a4d4ea3ed65a8480d47d073395806e7 /src/plugins/lua
parent81a01f43d3c1de562273b30025b018d38a5aadf6 (diff)
downloadrspamd-b561e9b9cbd86191aec1e51cc776d083b66b14b5.tar.gz
rspamd-b561e9b9cbd86191aec1e51cc776d083b66b14b5.zip
[Minor] Allow for re-enabling default-disabled checks
Diffstat (limited to 'src/plugins/lua')
-rw-r--r--src/plugins/lua/dmarc.lua15
-rw-r--r--src/plugins/lua/hfilter.lua16
-rw-r--r--src/plugins/lua/ip_score.lua13
-rw-r--r--src/plugins/lua/once_received.lua15
4 files changed, 54 insertions, 5 deletions
diff --git a/src/plugins/lua/dmarc.lua b/src/plugins/lua/dmarc.lua
index caf20b2fd..da5837d2b 100644
--- a/src/plugins/lua/dmarc.lua
+++ b/src/plugins/lua/dmarc.lua
@@ -22,6 +22,8 @@ local rspamd_logger = require "rspamd_logger"
local rspamd_redis = require "rspamd_redis"
local upstream_list = require "rspamd_upstream_list"
local rspamd_util = require "rspamd_util"
+local check_local = false
+local check_authed = false
local symbols = {
spf_allow_symbol = 'R_SPF_ALLOW',
@@ -78,7 +80,8 @@ local function dmarc_callback(task)
local dmarc_domain
local ip_addr = task:get_ip()
- if task:get_user() or (ip_addr and ip_addr:is_local()) then
+ if ((not check_user and task:get_user()) or
+ (not check_local and ip_addr and ip_addr:is_local())) then
rspamd_logger.infox(task, "skip DMARC checks for local networks and authorized users");
return
end
@@ -345,6 +348,16 @@ local function dmarc_callback(task)
forced = true})
end
+local opts = rspamd_config:get_all_opt('options')
+if opts and type(opts) ~= 'table' then
+ if type(opts['check_local']) == 'boolean' then
+ check_local = opts['check_local']
+ end
+ if type(opts['check_authed']) == 'boolean' then
+ check_authed = opts['check_authed']
+ end
+end
+
local opts = rspamd_config:get_all_opt('dmarc')
if not opts or type(opts) ~= 'table' then
return
diff --git a/src/plugins/lua/hfilter.lua b/src/plugins/lua/hfilter.lua
index c1d0e22b2..61595c253 100644
--- a/src/plugins/lua/hfilter.lua
+++ b/src/plugins/lua/hfilter.lua
@@ -113,6 +113,9 @@ local config = {
['url_enabled'] = false
}
+local check_local = false
+local check_authed = false
+
local function check_regexp(str, regexp_text)
if not compiled_regexp[regexp_text] then
compiled_regexp[regexp_text] = rspamd_regexp.create(regexp_text, 'i')
@@ -296,7 +299,8 @@ local function hfilter(task)
--No more checks for auth user or local network
local rip = task:get_from_ip()
- if task:get_user() or (rip and rip:is_local()) then
+ if ((not check_user and task:get_user()) or
+ (not check_local and rip and rip:is_local())) then
return false
end
@@ -479,6 +483,16 @@ local symbols_from = {
"HFILTER_FROM_BOUNCE"
}
+local opts = rspamd_config:get_all_opt('options')
+if opts and type(opts) ~= 'table' then
+ if type(opts['check_local']) == 'boolean' then
+ check_local = opts['check_local']
+ end
+ if type(opts['check_authed']) == 'boolean' then
+ check_authed = opts['check_authed']
+ end
+end
+
local opts = rspamd_config:get_all_opt('hfilter')
if opts then
for k,v in pairs(opts) do
diff --git a/src/plugins/lua/ip_score.lua b/src/plugins/lua/ip_score.lua
index c1489717e..140109e5e 100644
--- a/src/plugins/lua/ip_score.lua
+++ b/src/plugins/lua/ip_score.lua
@@ -26,6 +26,7 @@ local _ = require "fun"
local redis_params = nil
local whitelist = nil
local asn_cc_whitelist = nil
+local check_authed = false
local options = {
actions = { -- how each action is treated in scoring
@@ -315,7 +316,13 @@ end
-- Configuration options
local configure_ip_score_module = function()
- local opts = rspamd_config:get_all_opt('ip_score')
+ local opts = rspamd_config:get_all_opt('options')
+ if opts and type(opts) ~= 'table' then
+ if type(opts['check_authed']) == 'boolean' then
+ check_authed = opts['check_authed']
+ end
+ end
+ opts = rspamd_config:get_all_opt('ip_score')
if opts then
for k,v in pairs(opts) do
options[k] = v
@@ -324,6 +331,8 @@ local configure_ip_score_module = function()
if not redis_params then
rspamd_logger.infox(rspamd_config, 'no servers are specified')
end
+ else
+ return false
end
if options['whitelist'] then
whitelist = rspamd_config:add_radix_map(opts['whitelist'])
@@ -334,7 +343,7 @@ local configure_ip_score_module = function()
end
-configure_ip_score_module()
+if not configure_ip_score_module() then return end
if redis_params then
-- Register ip_score module
rspamd_config:register_symbol({
diff --git a/src/plugins/lua/once_received.lua b/src/plugins/lua/once_received.lua
index 86ada799a..202041869 100644
--- a/src/plugins/lua/once_received.lua
+++ b/src/plugins/lua/once_received.lua
@@ -24,6 +24,8 @@ local bad_hosts = {}
local good_hosts = {}
local whitelist = nil
local rspamd_logger = require "rspamd_logger"
+local check_local = false
+local check_authed = false
local function check_quantity_received (task)
local recvh = task:get_received_headers()
@@ -61,7 +63,9 @@ local function check_quantity_received (task)
local task_ip = task:get_ip()
- if task:get_user() or (task_ip and task_ip:is_local()) then
+ if ((not check_user and task:get_user()) or
+ (not check_local and ip_addr and ip_addr:is_local())) then
+ rspamd_logger.infox(task, 'Skipping once_received for authenticated user or local network')
return
end
if whitelist and task_ip and whitelist:get_key(task_ip) then
@@ -134,6 +138,15 @@ if type(rspamd_config.get_api_version) ~= 'nil' then
end
end
+local opts = rspamd_config:get_all_opt('options')
+if opts and type(opts) ~= 'table' then
+ if type(opts['check_local']) == 'boolean' then
+ check_local = opts['check_local']
+ end
+ if type(opts['check_authed']) == 'boolean' then
+ check_authed = opts['check_authed']
+ end
+end
-- Configuration
local opts = rspamd_config:get_all_opt('once_received')
if opts then