commit 9a7f377: [Feature] Rbl: Make config checks much more strict
Vsevolod Stakhov
vsevolod at highsecure.ru
Mon Sep 30 15:14:08 UTC 2019
Author: Vsevolod Stakhov
Date: 2019-09-30 16:07:45 +0100
URL: https://github.com/rspamd/rspamd/commit/9a7f377edfe557a926e080ca9ecdbbd15b1cd7ce (HEAD -> master)
[Feature] Rbl: Make config checks much more strict
---
lualib/lua_cfg_transform.lua | 1 +
src/plugins/lua/rbl.lua | 15 ++++++++++-----
2 files changed, 11 insertions(+), 5 deletions(-)
diff --git a/lualib/lua_cfg_transform.lua b/lualib/lua_cfg_transform.lua
index 17e77645d..ae7d8997c 100644
--- a/lualib/lua_cfg_transform.lua
+++ b/lualib/lua_cfg_transform.lua
@@ -257,6 +257,7 @@ local function surbl_section_convert(cfg, section)
if k == 'suffix' then k = 'rbl' end
if k == 'ips' then k = 'returncodes' end
if k == 'bits' then k = 'returnbits' end
+ if k == 'noip' then k = 'no_ip' end
-- Crappy legacy
if k == 'options' then
if v == 'noip' or v == 'no_ip' then
diff --git a/src/plugins/lua/rbl.lua b/src/plugins/lua/rbl.lua
index 59ac8f7e1..a3a9ffb63 100644
--- a/src/plugins/lua/rbl.lua
+++ b/src/plugins/lua/rbl.lua
@@ -1017,6 +1017,7 @@ local default_options = {
['default_no_ip'] = false,
['default_images'] = false,
['default_replyto'] = false,
+ ['default_dkim_match_from'] = false,
}
opts = lua_util.override_defaults(default_options, opts)
@@ -1048,7 +1049,7 @@ local return_bits_schema = ts.map_of(
)
)
-local rule_schema = ts.shape({
+local rule_schema_tbl = {
enabled = ts.boolean:is_optional(),
disabled = ts.boolean:is_optional(),
rbl = ts.string,
@@ -1070,11 +1071,15 @@ local rule_schema = ts.shape({
requests_limit = (ts.integer + ts.string / tonumber):is_optional(),
process_script = ts.string:is_optional(),
emails_delimiter = ts.string:is_optional(),
+ ignore_defaults = ts.boolean:is_optional(),
symbols_prefixes = ts.map_of(ts.string, ts.string):is_optional(),
-}, {
- -- Covers boolean defaults
- extra_fields = ts.map_of(ts.string, ts.boolean)
-})
+}
+-- Add default boolean flags to the schema
+for def_k,_ in pairs(default_options) do
+ rule_schema_tbl[def_k:sub(#('default_') + 1)] = ts.boolean:is_optional()
+end
+
+local rule_schema = ts.shape(rule_schema_tbl)
for key,rbl in pairs(opts.rbls or opts.rules) do
if type(rbl) ~= 'table' or rbl.disabled == true or rbl.enabled == false then
More information about the Commits
mailing list