aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/regexp.c
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2018-12-03 14:19:39 +0000
committerVsevolod Stakhov <vsevolod@highsecure.ru>2018-12-03 14:19:39 +0000
commit2bcf32721918984cb21ec2ed2d6d38fe08e060b7 (patch)
treec567c2d64c7762265f494a65b8ff8553db3d57eb /src/plugins/regexp.c
parent5f7111cfe60622a9ea7d6d9503fcd04c900f21fe (diff)
downloadrspamd-2bcf32721918984cb21ec2ed2d6d38fe08e060b7.tar.gz
rspamd-2bcf32721918984cb21ec2ed2d6d38fe08e060b7.zip
[Feature] Implement more strict configuration tests
Diffstat (limited to 'src/plugins/regexp.c')
-rw-r--r--src/plugins/regexp.c75
1 files changed, 66 insertions, 9 deletions
diff --git a/src/plugins/regexp.c b/src/plugins/regexp.c
index b40c9c468..897bbd277 100644
--- a/src/plugins/regexp.c
+++ b/src/plugins/regexp.c
@@ -279,39 +279,96 @@ regexp_module_config (struct rspamd_config *cfg)
elt = ucl_object_lookup (value, "score");
if (elt) {
- score = ucl_object_todouble (elt);
+ if (ucl_object_type (elt) != UCL_FLOAT && ucl_object_type (elt) != UCL_INT) {
+ msg_err_config (
+ "score attribute is not numeric for symbol: '%s'",
+ cur_item->symbol);
+
+ res = FALSE;
+ }
+ else {
+ score = ucl_object_todouble (elt);
+ }
}
elt = ucl_object_lookup (value, "one_shot");
if (elt) {
- if (ucl_object_toboolean (elt)) {
- nshots = 1;
+ if (ucl_object_type (elt) != UCL_BOOLEAN) {
+ msg_err_config (
+ "one_shot attribute is not numeric for symbol: '%s'",
+ cur_item->symbol);
+
+ res = FALSE;
+ }
+ else {
+ if (ucl_object_toboolean (elt)) {
+ nshots = 1;
+ }
}
}
if ((elt = ucl_object_lookup (value, "any_shot")) != NULL) {
- if (ucl_object_toboolean (elt)) {
- nshots = -1;
+ if (ucl_object_type (elt) != UCL_BOOLEAN) {
+ msg_err_config (
+ "any_shot attribute is not numeric for symbol: '%s'",
+ cur_item->symbol);
+
+ res = FALSE;
+ }
+ else {
+ if (ucl_object_toboolean (elt)) {
+ nshots = -1;
+ }
}
}
if ((elt = ucl_object_lookup (value, "nshots")) != NULL) {
- nshots = ucl_object_toint (elt);
+ if (ucl_object_type (elt) != UCL_FLOAT && ucl_object_type (elt) != UCL_INT) {
+ msg_err_config (
+ "nshots attribute is not numeric for symbol: '%s'",
+ cur_item->symbol);
+
+ res = FALSE;
+ }
+ else {
+ nshots = ucl_object_toint (elt);
+ }
}
elt = ucl_object_lookup (value, "one_param");
if (elt) {
- if (ucl_object_toboolean (elt)) {
- flags |= RSPAMD_SYMBOL_FLAG_ONEPARAM;
+ if (ucl_object_type (elt) != UCL_BOOLEAN) {
+ msg_err_config (
+ "one_param attribute is not numeric for symbol: '%s'",
+ cur_item->symbol);
+
+ res = FALSE;
+ }
+ else {
+ if (ucl_object_toboolean (elt)) {
+ flags |= RSPAMD_SYMBOL_FLAG_ONEPARAM;
+ }
}
}
elt = ucl_object_lookup (value, "priority");
if (elt) {
- priority = ucl_object_toint (elt);
+ if (ucl_object_type (elt) != UCL_FLOAT && ucl_object_type (elt) != UCL_INT) {
+ msg_err_config (
+ "priority attribute is not numeric for symbol: '%s'",
+ cur_item->symbol);
+
+ res = FALSE;
+ }
+ else {
+ priority = ucl_object_toint (elt);
+ }
+ }
+ else {
+ priority = ucl_object_get_priority (value) + 1;
}
rspamd_config_add_symbol (cfg, cur_item->symbol,