From: Vsevolod Stakhov Date: Thu, 4 Feb 2016 15:49:45 +0000 (+0000) Subject: Pre filters should actually skip processing X-Git-Tag: 1.1.3~3 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=27ccaaa8c7021eae7816474423209296bb9146a9;p=rspamd.git Pre filters should actually skip processing --- diff --git a/src/libmime/filter.c b/src/libmime/filter.c index 8ec0c704e..11d9f85d1 100644 --- a/src/libmime/filter.c +++ b/src/libmime/filter.c @@ -323,6 +323,10 @@ rspamd_action_from_str (const gchar *data, gint *result) sizeof ("soft reject") - 1) == 0) { *result = METRIC_ACTION_NOACTION; } + else if (g_ascii_strncasecmp (data, "accept", + sizeof ("accept") - 1) == 0) { + *result = METRIC_ACTION_NOACTION; + } else { return FALSE; } diff --git a/src/libserver/task.h b/src/libserver/task.h index a509c88de..44a71b289 100644 --- a/src/libserver/task.h +++ b/src/libserver/task.h @@ -187,7 +187,7 @@ struct rspamd_task { gpointer checkpoint; /**< Opaque checkpoint data */ struct { - enum rspamd_metric_action action; /**< Action of pre filters */ + guint32 action; /**< Action of pre filters */ gchar *str; /**< String describing action */ } pre_result; /**< Result of pre-filters */ diff --git a/src/lua/lua_task.c b/src/lua/lua_task.c index 7acedb153..6e644b0da 100644 --- a/src/lua/lua_task.c +++ b/src/lua/lua_task.c @@ -101,6 +101,7 @@ LUA_FUNCTION_DEF (task, insert_result); * - `add header`: add spam header * - `rewrite subject`: rewrite subject to spam subject * - `greylist`: greylist message + * - `accept` or `no action`: whitelist message * @param {rspamd_action or string} action a numeric or string action value * @param {string} description optional descripton @example @@ -812,16 +813,16 @@ lua_task_set_pre_result (lua_State * L) else if (lua_type (L, 2) == LUA_TSTRING) { rspamd_action_from_str (lua_tostring (L, 2), &action); } - if (action < (gint)task->pre_result.action && - action < METRIC_ACTION_MAX && - action >= METRIC_ACTION_REJECT) { + if (action < METRIC_ACTION_MAX && action >= METRIC_ACTION_REJECT) { /* We also need to set the default metric to that result */ mres = rspamd_create_metric_result (task, DEFAULT_METRIC); if (mres != NULL) { mres->score = mres->metric->actions[action].score; mres->action = action; } + task->pre_result.action = action; + if (lua_gettop (L) >= 3) { action_str = rspamd_mempool_strdup (task->task_pool, luaL_checkstring (L, 3)); @@ -834,6 +835,12 @@ lua_task_set_pre_result (lua_State * L) msg_info_task ("<%s>: set pre-result to %s: '%s'", task->message_id, rspamd_action_to_str (action), task->pre_result.str); + + /* Don't classify or filter message if pre-filter sets results */ + task->processed_stages |= (RSPAMD_TASK_STAGE_FILTERS | + RSPAMD_TASK_STAGE_CLASSIFIERS | + RSPAMD_TASK_STAGE_CLASSIFIERS_PRE | + RSPAMD_TASK_STAGE_CLASSIFIERS_POST); } } return 0;