]> source.dussan.org Git - rspamd.git/commitdiff
Pre filters should actually skip processing
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Thu, 4 Feb 2016 15:49:45 +0000 (15:49 +0000)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Thu, 4 Feb 2016 15:49:45 +0000 (15:49 +0000)
src/libmime/filter.c
src/libserver/task.h
src/lua/lua_task.c

index 8ec0c704e8e410fa93b77c7e05dba1f9ea4d36a4..11d9f85d1ebc165432fcc6daa4c61292d657dab9 100644 (file)
@@ -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;
        }
index a509c88de65b8a8c8b96aff6f98d182b23a1aea9..44a71b289e759b1e178619f5f65e43e15ed254d7 100644 (file)
@@ -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                                                      */
 
index 7acedb15372c2fc0e3ed4576350cd10e51b39931..6e644b0da4c04de16ff35cfcf95e77f9387b9755 100644 (file)
@@ -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;