commit f358aec: [Minor] Core: Add concept of mime only rules

Vsevolod Stakhov vsevolod at highsecure.ru
Sun Jan 6 17:07:03 UTC 2019


Author: Vsevolod Stakhov
Date: 2019-01-06 17:00:24 +0000
URL: https://github.com/rspamd/rspamd/commit/f358aec84f8bc2aa38c17a79d79b7a0b26faa4a0 (HEAD -> master)

[Minor] Core: Add concept of mime only rules

---
 src/libserver/rspamd_symcache.c | 3 ++-
 src/libserver/rspamd_symcache.h | 1 +
 src/libserver/task.h            | 1 +
 src/lua/lua_config.c            | 3 +++
 4 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/src/libserver/rspamd_symcache.c b/src/libserver/rspamd_symcache.c
index 62340af3b..f6487f4d8 100644
--- a/src/libserver/rspamd_symcache.c
+++ b/src/libserver/rspamd_symcache.c
@@ -1382,7 +1382,8 @@ rspamd_symcache_check_symbol (struct rspamd_task *task,
 	SET_START_BIT (checkpoint, dyn_item);
 
 	if (!item->enabled ||
-		(RSPAMD_TASK_IS_EMPTY (task) && !(item->type & SYMBOL_TYPE_EMPTY))) {
+		(RSPAMD_TASK_IS_EMPTY (task) && !(item->type & SYMBOL_TYPE_EMPTY)) ||
+		(item->type & SYMBOL_TYPE_MIME_ONLY && !RSPAMD_TASK_IS_MIME(task))) {
 		check = FALSE;
 	}
 	else if (item->specific.normal.condition_cb != -1) {
diff --git a/src/libserver/rspamd_symcache.h b/src/libserver/rspamd_symcache.h
index df495fc8e..ab9c568e1 100644
--- a/src/libserver/rspamd_symcache.h
+++ b/src/libserver/rspamd_symcache.h
@@ -47,6 +47,7 @@ enum rspamd_symbol_type {
 	SYMBOL_TYPE_IDEMPOTENT = (1 << 12), /* Symbol cannot change metric */
 	SYMBOL_TYPE_SQUEEZED = (1 << 13), /* Symbol is squeezed inside Lua */
 	SYMBOL_TYPE_TRIVIAL = (1 << 14), /* Symbol is trivial */
+	SYMBOL_TYPE_MIME_ONLY = (1 << 15), /* Symbol is mime only */
 };
 
 /**
diff --git a/src/libserver/task.h b/src/libserver/task.h
index 34e160dc0..7cdc09538 100644
--- a/src/libserver/task.h
+++ b/src/libserver/task.h
@@ -125,6 +125,7 @@ enum rspamd_task_stage {
 #define RSPAMD_TASK_IS_CLASSIFIED(task) (((task)->processed_stages & RSPAMD_TASK_STAGE_CLASSIFIERS))
 #define RSPAMD_TASK_IS_EMPTY(task) (((task)->flags & RSPAMD_TASK_FLAG_EMPTY))
 #define RSPAMD_TASK_IS_PROFILING(task) (((task)->flags & RSPAMD_TASK_FLAG_PROFILE))
+#define RSPAMD_TASK_IS_MIME(task) (((task)->flags & RSPAMD_TASK_FLAG_MIME))
 
 struct rspamd_email_address;
 struct rspamd_lang_detector;
diff --git a/src/lua/lua_config.c b/src/lua/lua_config.c
index 1965b4903..cc0ba7aed 100644
--- a/src/lua/lua_config.c
+++ b/src/lua/lua_config.c
@@ -1501,6 +1501,9 @@ lua_parse_symbol_flags (const gchar *str)
 		if (strstr (str, "trivial") != NULL) {
 			ret |= SYMBOL_TYPE_TRIVIAL;
 		}
+		if (strstr (str, "mime") != NULL) {
+			ret |= SYMBOL_TYPE_MIME_ONLY;
+		}
 	}
 
 	return ret;


More information about the Commits mailing list