aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@rspamd.com>2024-09-07 14:42:15 +0100
committerVsevolod Stakhov <vsevolod@rspamd.com>2024-09-07 14:42:15 +0100
commit59f5dd04d6b30ab32e35801dac4ba659dc8149a0 (patch)
tree7921a9025bf42468eb5bf645a2ad2f8d58a44683
parentf0c6643468c2cd4345fa4b96e7c6d829d94b0312 (diff)
downloadrspamd-59f5dd04d6b30ab32e35801dac4ba659dc8149a0.tar.gz
rspamd-59f5dd04d6b30ab32e35801dac4ba659dc8149a0.zip
[Fix] Another fix for Redis schema
Issue: #5112
-rw-r--r--lualib/lua_redis.lua10
-rw-r--r--src/plugins/lua/aws_s3.lua2
-rw-r--r--src/plugins/lua/bimi.lua4
-rw-r--r--src/plugins/lua/history_redis.lua2
4 files changed, 10 insertions, 8 deletions
diff --git a/lualib/lua_redis.lua b/lualib/lua_redis.lua
index 2c77c100a..43acfee65 100644
--- a/lualib/lua_redis.lua
+++ b/lualib/lua_redis.lua
@@ -24,11 +24,12 @@ local exports = {}
local E = {}
local N = "lua_redis"
+local db_schema = (ts.number / tostring + ts.string):is_optional():describe("Database number")
local common_schema = {
timeout = (ts.number + ts.string / lutil.parse_time_interval):is_optional():describe("Connection timeout"),
- db = ts.string:is_optional():describe("Database number"),
- database = ts.string:is_optional():describe("Database number"),
- dbname = ts.string:is_optional():describe("Database number"),
+ db = db_schema,
+ database = db_schema,
+ dbname = db_schema,
prefix = ts.string:is_optional():describe("Key prefix"),
username = ts.string:is_optional():describe("Username"),
password = ts.string:is_optional():describe("Password"),
@@ -64,7 +65,8 @@ local server_schema = lutil.table_merge({
local enrich_schema = function(external)
return ts.one_of {
- ts.shape(external), -- no specific redis parameters
+ ts.shape(lutil.table_merge(common_schema,
+ external)), -- no specific redis servers (e.g when global settings are used)
ts.shape(lutil.table_merge(read_schema, external)), -- read_servers specified
ts.shape(lutil.table_merge(write_schema, external)), -- write_servers specified
ts.shape(lutil.table_merge(rw_schema, external)), -- both read and write servers defined
diff --git a/src/plugins/lua/aws_s3.lua b/src/plugins/lua/aws_s3.lua
index 30e88d2cd..ac344d86c 100644
--- a/src/plugins/lua/aws_s3.lua
+++ b/src/plugins/lua/aws_s3.lua
@@ -238,7 +238,7 @@ settings = lua_util.override_defaults(settings, opts)
local res, err = settings_schema:transform(settings)
if not res then
- rspamd_logger.warnx(rspamd_config, 'plugin is misconfigured: %s', err)
+ rspamd_logger.warnx(rspamd_config, 'plugin %s is misconfigured: %s', N, err)
lua_util.disable_module(N, "config")
return
end
diff --git a/src/plugins/lua/bimi.lua b/src/plugins/lua/bimi.lua
index 278359069..78949a5c0 100644
--- a/src/plugins/lua/bimi.lua
+++ b/src/plugins/lua/bimi.lua
@@ -265,7 +265,7 @@ local function check_bimi_vmc(task, domain, record)
end
if redis_params.username then
if redis_params.password then
- password = string.format( '%s:%s@', redis_params.username, redis_params.password)
+ password = string.format('%s:%s@', redis_params.username, redis_params.password)
else
rspamd_logger.warnx(task, "Redis requires a password when username is supplied")
end
@@ -358,7 +358,7 @@ settings = lua_util.override_defaults(settings, opts)
local res, err = settings_schema:transform(settings)
if not res then
- rspamd_logger.warnx(rspamd_config, 'plugin is misconfigured: %s', err)
+ rspamd_logger.warnx(rspamd_config, 'plugin %s is misconfigured: %s', N, err)
local err_msg = string.format("schema error: %s", res)
lua_util.config_utils.push_config_error(N, err_msg)
lua_util.disable_module(N, "failed", err_msg)
diff --git a/src/plugins/lua/history_redis.lua b/src/plugins/lua/history_redis.lua
index fff9f46b3..a3fdb0ec4 100644
--- a/src/plugins/lua/history_redis.lua
+++ b/src/plugins/lua/history_redis.lua
@@ -281,7 +281,7 @@ if opts then
local res, err = settings_schema:transform(settings)
if not res then
- rspamd_logger.warnx(rspamd_config, '%s: plugin is misconfigured: %s', N, err)
+ rspamd_logger.warnx(rspamd_config, 'plugin %s is misconfigured: %s', N, err)
lua_util.disable_module(N, "config")
return
end