commit c143670: [Minor] Regexp: Allow to add mime only regexp rules

Vsevolod Stakhov vsevolod at highsecure.ru
Mon Jan 7 16:14:04 UTC 2019


Author: Vsevolod Stakhov
Date: 2019-01-07 15:41:34 +0000
URL: https://github.com/rspamd/rspamd/commit/c143670bcacd9039a3d782de3a6b5beda53cc760

[Minor] Regexp: Allow to add mime only regexp rules

---
 src/plugins/regexp.c | 30 ++++++++++++++++++++++++++----
 1 file changed, 26 insertions(+), 4 deletions(-)

diff --git a/src/plugins/regexp.c b/src/plugins/regexp.c
index 897bbd277..01c086169 100644
--- a/src/plugins/regexp.c
+++ b/src/plugins/regexp.c
@@ -245,12 +245,34 @@ regexp_module_config (struct rspamd_config *cfg)
 			}
 
 			if (cur_item && (is_lua || valid_expression)) {
+
+				flags = SYMBOL_TYPE_NORMAL;
+				elt = ucl_object_lookup (value, "mime_only");
+
+				if (elt) {
+					if (ucl_object_type (elt) != UCL_BOOLEAN) {
+						msg_err_config (
+								"mime_only attribute is not boolean for symbol: '%s'",
+								cur_item->symbol);
+
+						res = FALSE;
+					}
+					else {
+						if (ucl_object_toboolean (elt)) {
+							flags |= SYMBOL_TYPE_MIME_ONLY;
+						}
+					}
+				}
+
 				id = rspamd_symcache_add_symbol (cfg->cache,
 						cur_item->symbol,
 						0,
 						process_regexp_item,
 						cur_item,
-						SYMBOL_TYPE_NORMAL, -1);
+						flags, -1);
+
+				/* Reset flags */
+				flags = 0;
 
 				elt = ucl_object_lookup (value, "condition");
 
@@ -296,7 +318,7 @@ regexp_module_config (struct rspamd_config *cfg)
 				if (elt) {
 					if (ucl_object_type (elt) != UCL_BOOLEAN) {
 						msg_err_config (
-								"one_shot attribute is not numeric for symbol: '%s'",
+								"one_shot attribute is not boolean for symbol: '%s'",
 								cur_item->symbol);
 
 						res = FALSE;
@@ -311,7 +333,7 @@ regexp_module_config (struct rspamd_config *cfg)
 				if ((elt = ucl_object_lookup (value, "any_shot")) != NULL) {
 					if (ucl_object_type (elt) != UCL_BOOLEAN) {
 						msg_err_config (
-								"any_shot attribute is not numeric for symbol: '%s'",
+								"any_shot attribute is not boolean for symbol: '%s'",
 								cur_item->symbol);
 
 						res = FALSE;
@@ -341,7 +363,7 @@ regexp_module_config (struct rspamd_config *cfg)
 				if (elt) {
 					if (ucl_object_type (elt) != UCL_BOOLEAN) {
 						msg_err_config (
-								"one_param attribute is not numeric for symbol: '%s'",
+								"one_param attribute is not boolean for symbol: '%s'",
 								cur_item->symbol);
 
 						res = FALSE;


More information about the Commits mailing list