]> source.dussan.org Git - rspamd.git/commitdiff
[Fix] Allow to have negative actions limits
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Sat, 18 Nov 2017 22:03:54 +0000 (22:03 +0000)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Sat, 18 Nov 2017 22:03:54 +0000 (22:03 +0000)
lualib/rspamd_config_transform.lua
src/libmime/filter.c

index bca42691af83be0a7f04c9b38e338fd5e2825111..4f656ca9c1c20928fbef558a15c621b9b0eb6da0 100644 (file)
@@ -251,6 +251,24 @@ return function(cfg)
     logger.errx('no actions defined')
   end
 
+  -- Perform sanity check for actions
+  local actions_defs = {'greylist', 'add header', 'add_header',
+    'rewrite subject', 'rewrite_subject', 'reject'}
+
+  if not cfg.actions['no action'] and not cfg.actions['no_action'] and
+      not cfg.actions['accept'] then
+    for _,d in ipairs(actions_defs) do
+      if cfg.actions[d] then
+        if cfg.actions[d] < 0 then
+          cfg.actions['no action'] = cfg.actions[d] - 0.001
+          logger.infox('set no action score to: %s, as action %s has negative score',
+              cfg.actions['no action'], d)
+          break
+        end
+      end
+    end
+  end
+
   if not cfg.group then
     logger.errx('no symbol groups defined')
   else
index ecbfd24dbe6c6d0c9486dce761718f629000c6b7..fbd6d9f97f73e05d2b7f39374f5a0837e4d2db01 100644 (file)
@@ -351,7 +351,7 @@ enum rspamd_action_type
 rspamd_check_action_metric (struct rspamd_task *task, struct rspamd_metric_result *mres)
 {
        struct rspamd_action *action, *selected_action = NULL;
-       double max_score = 0, sc;
+       double max_score = -(G_MAXDOUBLE), sc;
        int i;
 
        if (task->pre_result.action == METRIC_ACTION_MAX) {