aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2016-07-12 17:36:58 +0100
committerVsevolod Stakhov <vsevolod@highsecure.ru>2016-07-12 17:36:58 +0100
commit2785fadecc3d0a2a849ba17bc0ab14a48bee7e4c (patch)
treea056a26243c8c251b7fe8f864abe949e32dcaaf6 /src
parent437727abc962967796b726814dcdf9d3c713a475 (diff)
downloadrspamd-2785fadecc3d0a2a849ba17bc0ab14a48bee7e4c.tar.gz
rspamd-2785fadecc3d0a2a849ba17bc0ab14a48bee7e4c.zip
[Feature] Allow to disable composite rules from settings
Diffstat (limited to 'src')
-rw-r--r--src/libserver/composites.c30
-rw-r--r--src/libserver/symbols_cache.c25
-rw-r--r--src/libserver/symbols_cache.h10
3 files changed, 55 insertions, 10 deletions
diff --git a/src/libserver/composites.c b/src/libserver/composites.c
index 8e2df32f7..917d1d0c3 100644
--- a/src/libserver/composites.c
+++ b/src/libserver/composites.c
@@ -258,18 +258,28 @@ composites_foreach_callback (gpointer key, gpointer value, void *data)
cd->composite = comp;
- rc = rspamd_process_expression (comp->expr, RSPAMD_EXPRESSION_FLAG_NOOPT, cd);
+ if (!isset (cd->checked, cd->composite->id * 2)) {
+ if (rspamd_symbols_cache_is_checked (cd->task, cd->task->cfg->cache,
+ key)) {
+ setbit (cd->checked, comp->id * 2);
+ clrbit (cd->checked, comp->id * 2 + 1);
+ }
+ else {
+ rc = rspamd_process_expression (comp->expr,
+ RSPAMD_EXPRESSION_FLAG_NOOPT, cd);
- /* Checked bit */
- setbit (cd->checked, comp->id * 2);
+ /* Checked bit */
+ setbit (cd->checked, comp->id * 2);
- /* Result bit */
- if (rc) {
- setbit (cd->checked, comp->id * 2 + 1);
- rspamd_task_insert_result_single (cd->task, key, 1.0, NULL);
- }
- else {
- clrbit (cd->checked, comp->id * 2 + 1);
+ /* Result bit */
+ if (rc) {
+ setbit (cd->checked, comp->id * 2 + 1);
+ rspamd_task_insert_result_single (cd->task, key, 1.0, NULL);
+ }
+ else {
+ clrbit (cd->checked, comp->id * 2 + 1);
+ }
+ }
}
}
diff --git a/src/libserver/symbols_cache.c b/src/libserver/symbols_cache.c
index f74982ff6..c38496ecc 100644
--- a/src/libserver/symbols_cache.c
+++ b/src/libserver/symbols_cache.c
@@ -2003,3 +2003,28 @@ rspamd_symbols_cache_set_cbdata (struct symbols_cache *cache,
return TRUE;
}
+
+gboolean
+rspamd_symbols_cache_is_checked (struct rspamd_task *task,
+ struct symbols_cache *cache, const gchar *symbol)
+{
+ gint id;
+ struct cache_savepoint *checkpoint;
+
+ g_assert (cache != NULL);
+ g_assert (symbol != NULL);
+
+ id = rspamd_symbols_cache_find_symbol_parent (cache, symbol);
+
+ if (id < 0) {
+ return FALSE;
+ }
+
+ checkpoint = task->checkpoint;
+
+ if (checkpoint) {
+ return isset (checkpoint->processed_bits, id * 2);
+ }
+
+ return FALSE;
+}
diff --git a/src/libserver/symbols_cache.h b/src/libserver/symbols_cache.h
index 1a4c0c3ed..290e754d0 100644
--- a/src/libserver/symbols_cache.h
+++ b/src/libserver/symbols_cache.h
@@ -231,4 +231,14 @@ gboolean rspamd_symbols_cache_set_cbdata (struct symbols_cache *cache,
gboolean rspamd_symbols_cache_process_settings (struct rspamd_task *task,
struct symbols_cache *cache);
+
+/**
+ * Checks if a symbol specified has been checked (or disabled)
+ * @param task
+ * @param cache
+ * @param symbol
+ * @return
+ */
+gboolean rspamd_symbols_cache_is_checked (struct rspamd_task *task,
+ struct symbols_cache *cache, const gchar *symbol);
#endif