diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2018-03-16 17:27:09 +0000 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2018-03-16 17:27:09 +0000 |
commit | b53a152e069882acca3127ac591fbe2f15c7911f (patch) | |
tree | 18c09767bbc8b1629308f835bc4f729f877275d4 | |
parent | d8c5f3adff9b2b347172ae04577a826d186821ed (diff) | |
download | rspamd-b53a152e069882acca3127ac591fbe2f15c7911f.tar.gz rspamd-b53a152e069882acca3127ac591fbe2f15c7911f.zip |
[Minor] Try to deal with squeezed symbols with a special care
-rw-r--r-- | lualib/lua_squeeze_rules.lua | 1 | ||||
-rw-r--r-- | src/libserver/symbols_cache.c | 10 | ||||
-rw-r--r-- | src/libserver/symbols_cache.h | 1 | ||||
-rw-r--r-- | src/lua/lua_config.c | 3 |
4 files changed, 12 insertions, 3 deletions
diff --git a/lualib/lua_squeeze_rules.lua b/lualib/lua_squeeze_rules.lua index e310986d6..f43d7383a 100644 --- a/lualib/lua_squeeze_rules.lua +++ b/lualib/lua_squeeze_rules.lua @@ -230,6 +230,7 @@ exports.squeeze_init = function() rspamd_config:register_symbol{ type = 'virtual', name = k, + flags = 'squeezed', parent = squeeze_function_ids[v.order], no_squeeze = true, -- to avoid infinite recursion } diff --git a/src/libserver/symbols_cache.c b/src/libserver/symbols_cache.c index 5db23bd66..8d63b578b 100644 --- a/src/libserver/symbols_cache.c +++ b/src/libserver/symbols_cache.c @@ -626,7 +626,8 @@ rspamd_symbols_cache_load_items (struct symbols_cache *cache, const gchar *name) } } - if ((item->type & SYMBOL_TYPE_VIRTUAL) && item->parent != -1) { + if ((item->type & SYMBOL_TYPE_VIRTUAL) && + !(item->type & SYMBOL_TYPE_SQUEEZED) && item->parent != -1) { g_assert (item->parent < (gint)cache->items_by_id->len); parent = g_ptr_array_index (cache->items_by_id, item->parent); @@ -1077,7 +1078,8 @@ rspamd_symbols_cache_validate_cb (gpointer k, gpointer v, gpointer ud) item->priority ++; } - if ((item->type & SYMBOL_TYPE_VIRTUAL) && item->parent != -1) { + if ((item->type & SYMBOL_TYPE_VIRTUAL) && + !(item->type & SYMBOL_TYPE_SQUEEZED) && item->parent != -1) { g_assert (item->parent < (gint)cache->items_by_id->len); parent = g_ptr_array_index (cache->items_by_id, item->parent); @@ -1269,6 +1271,7 @@ rspamd_symbols_cache_check_symbol (struct rspamd_task *task, setbit (checkpoint->processed_bits, item->id * 2); if (!item->enabled || + (item->type & SYMBOL_TYPE_SQUEEZED) || (RSPAMD_TASK_IS_EMPTY (task) && !(item->type & SYMBOL_TYPE_EMPTY))) { check = FALSE; } @@ -1942,7 +1945,8 @@ rspamd_symbols_cache_counters_cb (gpointer v, gpointer ud) ucl_object_insert_key (obj, ucl_object_fromstring (item->symbol), "symbol", 0, false); - if ((item->type & SYMBOL_TYPE_VIRTUAL) && item->parent != -1) { + if ((item->type & SYMBOL_TYPE_VIRTUAL) && + !(item->type & SYMBOL_TYPE_SQUEEZED) && item->parent != -1) { g_assert (item->parent < (gint)cbd->cache->items_by_id->len); parent = g_ptr_array_index (cbd->cache->items_by_id, item->parent); diff --git a/src/libserver/symbols_cache.h b/src/libserver/symbols_cache.h index d959f905e..4e1c10dc5 100644 --- a/src/libserver/symbols_cache.h +++ b/src/libserver/symbols_cache.h @@ -42,6 +42,7 @@ enum rspamd_symbol_type { SYMBOL_TYPE_POSTFILTER = (1 << 10), SYMBOL_TYPE_NOSTAT = (1 << 11), /* Skip as statistical symbol */ SYMBOL_TYPE_IDEMPOTENT = (1 << 12), /* Symbol cannot change metric */ + SYMBOL_TYPE_SQUEEZED = (1 << 13), /* Symbol is squeezed inside Lua */ }; /** diff --git a/src/lua/lua_config.c b/src/lua/lua_config.c index 0941c0aa3..d6397efe6 100644 --- a/src/lua/lua_config.c +++ b/src/lua/lua_config.c @@ -1508,6 +1508,9 @@ lua_parse_symbol_flags (const gchar *str) if (strstr (str, "idempotent") != NULL) { ret |= SYMBOL_TYPE_IDEMPOTENT; } + if (strstr (str, "squeezed") != NULL) { + ret |= SYMBOL_TYPE_SQUEEZED; + } } return ret; |