enum rspamd_symbol_flags {
RSPAMD_SYMBOL_FLAG_NORMAL = 0,
- RSPAMD_SYMBOL_FLAG_IGNORE = (1 << 1),
+ RSPAMD_SYMBOL_FLAG_IGNORE_METRIC = (1 << 1),
RSPAMD_SYMBOL_FLAG_ONEPARAM = (1 << 2),
RSPAMD_SYMBOL_FLAG_UNGROUPPED = (1 << 3),
+ RSPAMD_SYMBOL_FLAG_DISABLED = (1 << 4),
};
/**
}
if (ucl_object_toboolean (elt)) {
- flags |= RSPAMD_SYMBOL_FLAG_IGNORE;
+ flags |= RSPAMD_SYMBOL_FLAG_IGNORE_METRIC;
+ }
+ }
+
+ if ((elt = ucl_object_lookup (obj, "enabled")) != NULL) {
+ if (ucl_object_type (elt) != UCL_BOOLEAN) {
+ g_set_error (err,
+ CFG_RCL_ERROR,
+ EINVAL,
+ "enabled attribute is not boolean for symbol: '%s'",
+ key);
+
+ return FALSE;
+ }
+
+ if (ucl_object_toboolean (elt)) {
+ flags |= RSPAMD_SYMBOL_FLAG_DISABLED;
}
}
ignore_symbol = FALSE;
sym_def = v;
- if (sym_def && (sym_def->flags & RSPAMD_SYMBOL_FLAG_IGNORE)) {
+ if (sym_def && (sym_def->flags &
+ (RSPAMD_SYMBOL_FLAG_IGNORE_METRIC|RSPAMD_SYMBOL_FLAG_DISABLED))) {
ignore_symbol = TRUE;
}
}
}
}
+ else if (sym_def->flags & RSPAMD_SYMBOL_FLAG_DISABLED) {
+ item = g_hash_table_lookup (cache->items_by_symbol, k);
+
+ if (item) {
+ item->enabled = FALSE;
+ }
+ }
}
return ret;
nshots = 1;
}
if (strstr (flags_str, "ignore") != NULL) {
- flags |= RSPAMD_SYMBOL_FLAG_IGNORE;
+ flags |= RSPAMD_SYMBOL_FLAG_IGNORE_METRIC;
}
if (strstr (flags_str, "one_param") != NULL) {
flags |= RSPAMD_SYMBOL_FLAG_ONEPARAM;
lua_pushstring (L, "flags");
lua_createtable (L, 0, 3);
- if (s->flags & RSPAMD_SYMBOL_FLAG_IGNORE) {
+ if (s->flags & RSPAMD_SYMBOL_FLAG_IGNORE_METRIC) {
lua_pushstring (L, "ignore");
lua_pushboolean (L, true);
lua_settable (L, -3);
lua_pushboolean (L, true);
lua_settable (L, -3);
}
+ if (s->flags & RSPAMD_SYMBOL_FLAG_DISABLED) {
+ lua_pushstring (L, "disabled");
+ lua_pushboolean (L, true);
+ lua_settable (L, -3);
+ }
if (s->cache_item) {
guint sflags = rspamd_symcache_get_symbol_flags (cbd->cfg->cache, sym);
0.0,
"DKIM check callback",
"policies",
- RSPAMD_SYMBOL_FLAG_IGNORE,
+ RSPAMD_SYMBOL_FLAG_IGNORE_METRIC,
1,
1);
rspamd_config_add_symbol_group (cfg, "DKIM_CHECK", "dkim");
0.0,
"DKIM trace symbol",
"policies",
- RSPAMD_SYMBOL_FLAG_IGNORE,
+ RSPAMD_SYMBOL_FLAG_IGNORE_METRIC,
1,
1);
rspamd_config_add_symbol_group (cfg, "DKIM_TRACE", "dkim");
0.0,
"Fuzzy check callback",
"fuzzy",
- RSPAMD_SYMBOL_FLAG_IGNORE,
+ RSPAMD_SYMBOL_FLAG_IGNORE_METRIC,
1,
1);
0.0,
"SPF check callback",
"policies",
- RSPAMD_SYMBOL_FLAG_IGNORE,
+ RSPAMD_SYMBOL_FLAG_IGNORE_METRIC,
1,
1);
rspamd_config_add_symbol_group (cfg, "SPF_CHECK", "spf");