return FALSE;
}
-static gboolean
+gboolean
rspamd_symcache_is_item_allowed (struct rspamd_task *task,
struct rspamd_symcache_item *item)
{
+ /* Static checks */
+ if (!item->enabled ||
+ (RSPAMD_TASK_IS_EMPTY (task) && !(item->type & SYMBOL_TYPE_EMPTY)) ||
+ (item->type & SYMBOL_TYPE_MIME_ONLY && !RSPAMD_TASK_IS_MIME(task))) {
+ return FALSE;
+ }
+
+ /* Settings checks */
if (task->settings_elt != 0) {
guint32 id = task->settings_elt->id;
id);
}
}
+ else if (item->type & SYMBOL_TYPE_EXPLICIT_ENABLE) {
+ msg_debug_cache_task ("deny execution of %s as it must be explicitly enabled",
+ item->symbol);
+ return FALSE;
+ }
/* Allow all symbols with no settings id */
return TRUE;
/* Check has been started */
SET_START_BIT (checkpoint, dyn_item);
- if (!item->enabled || /* Static flag */
- !rspamd_symcache_is_item_allowed (task, item) || /* Dynamic id */
- (RSPAMD_TASK_IS_EMPTY (task) && !(item->type & SYMBOL_TYPE_EMPTY)) ||
- (item->type & SYMBOL_TYPE_MIME_ONLY && !RSPAMD_TASK_IS_MIME(task))) {
+ if (!rspamd_symcache_is_item_allowed (task, item)) {
msg_debug_cache_task ("disable execution of symbol %s", item->symbol);
check = FALSE;
}
SYMBOL_TYPE_MIME_ONLY = (1u << 15u), /* Symbol is mime only */
SYMBOL_TYPE_EXPLICIT_DISABLE = (1u << 16u), /* Symbol should be disabled explicitly only */
SYMBOL_TYPE_IGNORE_PASSTHROUGH = (1u << 17u), /* Symbol ignores passthrough result */
- SYMBOL_TYPE_USE_CORO = (1u << 18u), /* Symbol uses lua coroutines */
+ SYMBOL_TYPE_EXPLICIT_ENABLE = (1u << 18u), /* Symbol should be enabled explicitly only */
+ SYMBOL_TYPE_USE_CORO = (1u << 19u), /* Symbol uses lua coroutines */
};
/**
void rspamd_symcache_process_settings_elt (struct rspamd_symcache *cache,
struct rspamd_config_settings_elt *elt);
+/**
+ * Check if a symbol is allowed for execution/insertion
+ * @param task
+ * @param item
+ * @return
+ */
+gboolean rspamd_symcache_is_item_allowed (struct rspamd_task *task,
+ struct rspamd_symcache_item *item);
+
#endif
if (strstr (str, "explicit_disable") != NULL) {
ret |= SYMBOL_TYPE_EXPLICIT_DISABLE;
}
+ if (strstr (str, "explicit_enable") != NULL) {
+ ret |= SYMBOL_TYPE_EXPLICIT_ENABLE;
+ }
if (strstr (str, "coro") != NULL) {
ret |= SYMBOL_TYPE_USE_CORO;
}
lua_rawseti (L, -2, i++);
}
+ if (flags & SYMBOL_TYPE_EXPLICIT_ENABLE) {
+ lua_pushstring (L, "explicit_enable");
+ lua_rawseti (L, -2, i++);
+ }
+
if (flags & SYMBOL_TYPE_IGNORE_PASSTHROUGH) {
lua_pushstring (L, "ignore_passthrough");
lua_rawseti (L, -2, i++);