aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrew Lewis <nerf@judo.za.org>2016-09-01 17:25:12 +0200
committerAndrew Lewis <nerf@judo.za.org>2016-09-01 17:25:12 +0200
commitf552edd887794a5086dcf93d36f8f82d83553196 (patch)
tree3e4073dbcd20744cb02caa51d8b12d6e451bcae0
parent99c2eb287a15649c0dac67065b0254c2a94a768f (diff)
downloadrspamd-f552edd887794a5086dcf93d36f8f82d83553196.tar.gz
rspamd-f552edd887794a5086dcf93d36f8f82d83553196.zip
[Feature] Add common way to disable Lua modules
-rw-r--r--src/plugins/lua/antivirus.lua4
-rw-r--r--src/plugins/lua/asn.lua4
-rw-r--r--src/plugins/lua/dcc.lua4
-rw-r--r--src/plugins/lua/dmarc.lua5
-rw-r--r--src/plugins/lua/emails.lua4
-rw-r--r--src/plugins/lua/fann_scores.lua7
-rw-r--r--src/plugins/lua/forged_recipients.lua4
-rw-r--r--src/plugins/lua/greylist.lua4
-rw-r--r--src/plugins/lua/hfilter.lua4
-rw-r--r--src/plugins/lua/ip_score.lua4
-rw-r--r--src/plugins/lua/maillist.lua7
-rw-r--r--src/plugins/lua/mime_types.lua4
-rw-r--r--src/plugins/lua/multimap.lua4
-rw-r--r--src/plugins/lua/once_received.lua4
-rw-r--r--src/plugins/lua/phishing.lua7
-rw-r--r--src/plugins/lua/ratelimit.lua4
-rw-r--r--src/plugins/lua/rbl.lua5
-rw-r--r--src/plugins/lua/replies.lua41
-rw-r--r--src/plugins/lua/rspamd_update.lua6
-rw-r--r--src/plugins/lua/settings.lua8
-rw-r--r--src/plugins/lua/spamassassin.lua6
-rw-r--r--src/plugins/lua/trie.lua6
-rw-r--r--src/plugins/lua/whitelist.lua7
23 files changed, 133 insertions, 20 deletions
diff --git a/src/plugins/lua/antivirus.lua b/src/plugins/lua/antivirus.lua
index 96a723fe0..c46e7eeb4 100644
--- a/src/plugins/lua/antivirus.lua
+++ b/src/plugins/lua/antivirus.lua
@@ -273,6 +273,10 @@ end
-- Registration
local opts = rspamd_config:get_all_opt('antivirus')
if opts and type(opts) == 'table' then
+ if opts['enabled'] == false then
+ rspamd_logger.info('Module is disabled')
+ return
+ end
redis_params = rspamd_parse_redis_server('antivirus')
for k, m in pairs(opts) do
if type(m) == 'table' and m['type'] then
diff --git a/src/plugins/lua/asn.lua b/src/plugins/lua/asn.lua
index 25b684dc4..5fab04d8f 100644
--- a/src/plugins/lua/asn.lua
+++ b/src/plugins/lua/asn.lua
@@ -74,6 +74,10 @@ end
local configure_asn_module = function()
local opts = rspamd_config:get_all_opt('asn')
if opts then
+ if opts['enabled'] == false then
+ rspamd_logger.info('Module is disabled')
+ return
+ end
for k,v in pairs(opts) do
options[k] = v
end
diff --git a/src/plugins/lua/dcc.lua b/src/plugins/lua/dcc.lua
index 216139fab..ae6a3661a 100644
--- a/src/plugins/lua/dcc.lua
+++ b/src/plugins/lua/dcc.lua
@@ -116,6 +116,10 @@ end
-- Configuration
if opts and opts['host'] then
+ if opts['enabled'] == false then
+ logger.info('Module is disabled')
+ return
+ end
rspamd_config:register_symbol({
name = symbol_bulk,
callback = check_dcc
diff --git a/src/plugins/lua/dmarc.lua b/src/plugins/lua/dmarc.lua
index fc85c4766..8d04c4fbb 100644
--- a/src/plugins/lua/dmarc.lua
+++ b/src/plugins/lua/dmarc.lua
@@ -328,6 +328,11 @@ if not opts or type(opts) ~= 'table' then
return
end
+if opts['enabled'] == false then
+ rspamd_logger.info('Module is disabled')
+ return
+end
+
if opts['symbols'] then
for k,_ in pairs(dmarc_symbols) do
if opts['symbols'][k] then
diff --git a/src/plugins/lua/emails.lua b/src/plugins/lua/emails.lua
index 9d9a54d03..74358d1e2 100644
--- a/src/plugins/lua/emails.lua
+++ b/src/plugins/lua/emails.lua
@@ -81,6 +81,10 @@ end
local opts = rspamd_config:get_all_opt('emails', 'rule')
if opts and type(opts) == 'table' then
+ if opts['enabled'] == false then
+ logger.info('Module is disabled')
+ return
+ end
local r = opts['rule']
if r then
diff --git a/src/plugins/lua/fann_scores.lua b/src/plugins/lua/fann_scores.lua
index c62923521..cafa5befa 100644
--- a/src/plugins/lua/fann_scores.lua
+++ b/src/plugins/lua/fann_scores.lua
@@ -38,6 +38,13 @@ local max_trains = 1000
local max_epoch = 100
local use_settings = false
local opts = rspamd_config:get_all_opt("fann_scores")
+if not (opts and type(opts) == 'table') then
+ rspamd_logger.infox('Module is unconfigured')
+ return
+elseif opts['enabled'] == false then
+ rspamd_logger.info('Module is disabled')
+ return
+end
local function symbols_to_fann_vector(syms)
local learn_data = {}
diff --git a/src/plugins/lua/forged_recipients.lua b/src/plugins/lua/forged_recipients.lua
index 957491a56..5b7d71fc4 100644
--- a/src/plugins/lua/forged_recipients.lua
+++ b/src/plugins/lua/forged_recipients.lua
@@ -72,6 +72,10 @@ end
-- Configuration
local opts = rspamd_config:get_all_opt('forged_recipients')
if opts then
+ if opts['enabled'] == false then
+ logger.info('Module is disabled')
+ return
+ end
if opts['symbol_rcpt'] or opts['symbol_sender'] then
local id = rspamd_config:register_symbol({
callback = check_forged_headers,
diff --git a/src/plugins/lua/greylist.lua b/src/plugins/lua/greylist.lua
index 05afaeab6..ddb2da602 100644
--- a/src/plugins/lua/greylist.lua
+++ b/src/plugins/lua/greylist.lua
@@ -321,6 +321,10 @@ end
local opts = rspamd_config:get_all_opt('greylist')
if opts then
+ if opts['enabled'] == false then
+ rspamd_logger.info('Module is disabled')
+ return
+ end
if opts['whitelisted_ip'] then
whitelisted_ip = rspamd_config:add_radix_map(opts['whitelisted_ip'],
'Greylist whitelist ip map')
diff --git a/src/plugins/lua/hfilter.lua b/src/plugins/lua/hfilter.lua
index 34a679641..fad715607 100644
--- a/src/plugins/lua/hfilter.lua
+++ b/src/plugins/lua/hfilter.lua
@@ -481,6 +481,10 @@ local symbols_from = {
local opts = rspamd_config:get_all_opt('hfilter')
if opts then
+ if opts['enabled'] == false then
+ rspamd_logger.info('Module is disabled')
+ return
+ end
for k,v in pairs(opts) do
config[k] = v
end
diff --git a/src/plugins/lua/ip_score.lua b/src/plugins/lua/ip_score.lua
index 6b6ac900a..12430241b 100644
--- a/src/plugins/lua/ip_score.lua
+++ b/src/plugins/lua/ip_score.lua
@@ -317,6 +317,10 @@ end
local configure_ip_score_module = function()
local opts = rspamd_config:get_all_opt('ip_score')
if opts then
+ if opts['enabled'] == false then
+ rspamd_logger.info('Module is disabled')
+ return
+ end
for k,v in pairs(opts) do
options[k] = v
end
diff --git a/src/plugins/lua/maillist.lua b/src/plugins/lua/maillist.lua
index 42cdc9176..96807cd3d 100644
--- a/src/plugins/lua/maillist.lua
+++ b/src/plugins/lua/maillist.lua
@@ -270,7 +270,12 @@ end
-- Configuration
-local opts = rspamd_config:get_all_opt('maillist')if opts then
+local opts = rspamd_config:get_all_opt('maillist')
+if opts then
+ if opts['enabled'] == false then
+ rspamd_logger.info('Module is disabled')
+ return
+ end
if opts['symbol'] then
symbol = opts['symbol']
rspamd_config:register_symbol({
diff --git a/src/plugins/lua/mime_types.lua b/src/plugins/lua/mime_types.lua
index e1b2123f4..c6fb499df 100644
--- a/src/plugins/lua/mime_types.lua
+++ b/src/plugins/lua/mime_types.lua
@@ -200,6 +200,10 @@ end
local opts = rspamd_config:get_all_opt('mime_types')
if opts then
+ if opts['enabled'] == false then
+ rspamd_logger.info('Module is disabled')
+ return
+ end
for k,v in pairs(opts) do
settings[k] = v
end
diff --git a/src/plugins/lua/multimap.lua b/src/plugins/lua/multimap.lua
index f21bc5b11..7cba9fd3a 100644
--- a/src/plugins/lua/multimap.lua
+++ b/src/plugins/lua/multimap.lua
@@ -774,6 +774,10 @@ end
-- Registration
local opts = rspamd_config:get_all_opt('multimap')
if opts and type(opts) == 'table' then
+ if opts['enabled'] == false then
+ rspamd_logger.info('Module is disabled')
+ return
+ end
redis_params = rspamd_parse_redis_server('multimap')
for k,m in pairs(opts) do
if type(m) == 'table' and m['type'] then
diff --git a/src/plugins/lua/once_received.lua b/src/plugins/lua/once_received.lua
index 63de22776..3012205d6 100644
--- a/src/plugins/lua/once_received.lua
+++ b/src/plugins/lua/once_received.lua
@@ -142,6 +142,10 @@ end
-- Configuration
local opts = rspamd_config:get_all_opt('once_received')
if opts then
+ if opts['enabled'] == false then
+ rspamd_logger.info('Module is disabled')
+ return
+ end
if opts['symbol'] then
local symbol = opts['symbol']
diff --git a/src/plugins/lua/phishing.lua b/src/plugins/lua/phishing.lua
index ec9b9d2ad..c4ccfca3c 100644
--- a/src/plugins/lua/phishing.lua
+++ b/src/plugins/lua/phishing.lua
@@ -35,6 +35,13 @@ local phishtank_data = {}
local rspamd_logger = require "rspamd_logger"
local util = require "rspamd_util"
local opts = rspamd_config:get_all_opt('phishing')
+if not (opts and type(opts) == 'table') then
+ rspamd_logger.info('Module is unconfigured')
+ return
+elseif opts['enabled'] == false then
+ rspamd_logger.info('Module is disabled')
+ return
+end
local function phishing_cb(task)
local function check_phishing_map(map, url, symbol)
diff --git a/src/plugins/lua/ratelimit.lua b/src/plugins/lua/ratelimit.lua
index d8e53d4d0..0d3690cb3 100644
--- a/src/plugins/lua/ratelimit.lua
+++ b/src/plugins/lua/ratelimit.lua
@@ -442,6 +442,10 @@ end
local opts = rspamd_config:get_all_opt('ratelimit')
if opts then
+ if opts['enabled'] == false then
+ rspamd_logger.info('Module is disabled')
+ return
+ end
local rates = opts['limit']
if rates and type(rates) == 'table' then
fun.each(parse_limit, rates)
diff --git a/src/plugins/lua/rbl.lua b/src/plugins/lua/rbl.lua
index 13563f71b..d782d1c25 100644
--- a/src/plugins/lua/rbl.lua
+++ b/src/plugins/lua/rbl.lua
@@ -385,7 +385,10 @@ end
-- Configuration
local opts = rspamd_config:get_all_opt('rbl')
-if not opts or type(opts) ~= 'table' then
+if not (opts and type(opts) == 'table') then
+ rspamd_logger.info('Module is unconfigured')
+elseif opts['enabled'] == false then
+ rspamd_logger.info('Module is disabled')
return
end
diff --git a/src/plugins/lua/replies.lua b/src/plugins/lua/replies.lua
index 360f14ffe..39eb3705b 100644
--- a/src/plugins/lua/replies.lua
+++ b/src/plugins/lua/replies.lua
@@ -109,23 +109,30 @@ end
local opts = rspamd_config:get_all_opt('replies')
if opts then
- redis_params = rspamd_parse_redis_server('replies')
- if not redis_params then
- rspamd_logger.infox(rspamd_config, 'no servers are specified, disabling module')
- else
- rspamd_config:register_symbol({
- name = 'REPLIES_SET',
- type = 'postfilter',
- callback = replies_set,
- priority = 10
- })
- rspamd_config:register_symbol({
- name = 'REPLIES_CHECK',
- type = 'prefilter',
- callback = replies_check,
- priority = 10
- })
- end
+ if not (opts and type(opts) == 'table') then
+ rspamd_logger.info('Module is unconfigured')
+ return
+ elseif opts['enabled'] == false then
+ rspamd_logger.info('Module is disabled')
+ return
+ end
+ redis_params = rspamd_parse_redis_server('replies')
+ if not redis_params then
+ rspamd_logger.infox(rspamd_config, 'no servers are specified, disabling module')
+ else
+ rspamd_config:register_symbol({
+ name = 'REPLIES_SET',
+ type = 'postfilter',
+ callback = replies_set,
+ priority = 10
+ })
+ rspamd_config:register_symbol({
+ name = 'REPLIES_CHECK',
+ type = 'prefilter',
+ callback = replies_check,
+ priority = 10
+ })
+ end
for k,v in pairs(opts) do
settings[k] = v
diff --git a/src/plugins/lua/rspamd_update.lua b/src/plugins/lua/rspamd_update.lua
index 9af937263..c4f1a7e98 100644
--- a/src/plugins/lua/rspamd_update.lua
+++ b/src/plugins/lua/rspamd_update.lua
@@ -125,6 +125,10 @@ end
-- Configuration part
local section = rspamd_config:get_all_opt("rspamd_update")
if section then
+ if section['enabled'] == false then
+ rspamd_logger.info('Module is disabled')
+ return
+ end
local trusted_key
each(function(k, elt)
if k == 'priority' then
@@ -153,4 +157,6 @@ if section then
end
end
end, maps)
+else
+ rspamd_logger.infox('Module is unconfigured')
end
diff --git a/src/plugins/lua/settings.lua b/src/plugins/lua/settings.lua
index 1b632f747..e857d7f8e 100644
--- a/src/plugins/lua/settings.lua
+++ b/src/plugins/lua/settings.lua
@@ -18,7 +18,14 @@ limitations under the License.
-- Settings documentation can be found here:
-- https://rspamd.com/doc/configuration/settings.html
+local rspamd_logger = require "rspamd_logger"
local set_section = rspamd_config:get_all_opt("settings")
+if not (set_section and type(set_section) == 'table') then
+ rspamd_logger.infox('Module is unconfigured')
+elseif set_section['enabled'] == false then
+ rspamd_logger.infox('Module is disabled')
+ return
+end
local settings = {
[1] = {},
@@ -28,7 +35,6 @@ local settings = {
local settings_ids = {}
local settings_initialized = false
local max_pri = 0
-local rspamd_logger = require "rspamd_logger"
local rspamd_ip = require "rspamd_ip"
local rspamd_regexp = require "rspamd_regexp"
local ucl = require "ucl"
diff --git a/src/plugins/lua/spamassassin.lua b/src/plugins/lua/spamassassin.lua
index cf17aa247..533b83864 100644
--- a/src/plugins/lua/spamassassin.lua
+++ b/src/plugins/lua/spamassassin.lua
@@ -114,6 +114,12 @@ local sa_lists = {
local func_cache = {}
local section = rspamd_config:get_all_opt("spamassassin")
+if not (section and type(section) == 'table') then
+ rspamd_logger.info('Module is unconfigured')
+elseif section['enabled'] == false then
+ rspamd_logger.info('Module is disabled')
+ return
+end
-- Minimum score to treat symbols as meta
local meta_score_alpha = 0.5
diff --git a/src/plugins/lua/trie.lua b/src/plugins/lua/trie.lua
index da8bba560..ca5cbea54 100644
--- a/src/plugins/lua/trie.lua
+++ b/src/plugins/lua/trie.lua
@@ -130,6 +130,10 @@ end
local opts = rspamd_config:get_all_opt("trie")
if opts then
+ if opts['enabled'] == false then
+ rspamd_logger.info('Module is disabled')
+ return
+ end
for sym, opt in pairs(opts) do
process_trie_conf(sym, opt)
end
@@ -168,4 +172,6 @@ if opts then
})
end
end
+else
+ rspamd_logger.info("Module is disabled")
end
diff --git a/src/plugins/lua/whitelist.lua b/src/plugins/lua/whitelist.lua
index 946e47adf..b0b00114e 100644
--- a/src/plugins/lua/whitelist.lua
+++ b/src/plugins/lua/whitelist.lua
@@ -185,9 +185,16 @@ end
local configure_whitelist_module = function()
local opts = rspamd_config:get_all_opt('whitelist')
if opts then
+ if opts['enabled'] == false then
+ rspamd_logger.info('Module is disabled')
+ return
+ end
for k,v in pairs(opts) do
options[k] = v
end
+ else
+ rspamd_logger.info('Module is unconfigured')
+ return
end
if options['rules'] then