summaryrefslogtreecommitdiffstats
path: root/lualib
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@rspamd.com>2023-10-26 11:06:25 +0100
committerGitHub <noreply@github.com>2023-10-26 11:06:25 +0100
commitd2f250ae1ea421d423b1e07bbafcf7ef3560a191 (patch)
treee7232a272be99e5152bfde5303a2eab640817626 /lualib
parent6491804e19f1771bb1b4146420a2a3b98939d516 (diff)
parent15e3f277fad7c692b641423b38d6b508b764a3f8 (diff)
downloadrspamd-d2f250ae1ea421d423b1e07bbafcf7ef3560a191.tar.gz
rspamd-d2f250ae1ea421d423b1e07bbafcf7ef3560a191.zip
Merge pull request #4657 from fatalbanana/rbl_matchers
[Feature] rbl: support use of different matchers for return codes
Diffstat (limited to 'lualib')
-rw-r--r--lualib/plugins/rbl.lua16
1 files changed, 16 insertions, 0 deletions
diff --git a/lualib/plugins/rbl.lua b/lualib/plugins/rbl.lua
index 02d0d3338..320fd7725 100644
--- a/lualib/plugins/rbl.lua
+++ b/lualib/plugins/rbl.lua
@@ -130,6 +130,7 @@ local rule_schema_tbl = {
return_codes = return_codes_schema:is_optional(),
returnbits = return_bits_schema:is_optional(),
returncodes = return_codes_schema:is_optional(),
+ returncodes_matcher = ts.one_of { "equality", "glob", "luapattern", "radix", "regexp" }:is_optional(),
selector = ts.one_of { ts.string, ts.table }:is_optional(),
selector_flatten = ts.boolean:is_optional(),
symbol = ts.string:is_optional(),
@@ -199,6 +200,21 @@ local function convert_checks(rule)
rule.from = true
end
+ if rule.returncodes and not rule.returncodes_matcher then
+ for _, v in pairs(rule.returncodes) do
+ for _, e in ipairs(v) do
+ if e:find('%', 1, true) then
+ rspamd_logger.info(rspamd_config, 'implicitly enabling luapattern returncodes_matcher for rule %s', rule.symbol)
+ rule.returncodes_matcher = 'luapattern'
+ break
+ end
+ end
+ if rule.returncodes_matcher then
+ break
+ end
+ end
+ end
+
return rule
end