]> source.dussan.org Git - rspamd.git/commitdiff
[Minor] Fixes for the previous project
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Tue, 9 Oct 2018 13:58:44 +0000 (14:58 +0100)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Tue, 9 Oct 2018 13:58:44 +0000 (14:58 +0100)
conf/composites.conf
src/libserver/composites.c
src/libutil/expression.c

index 6536aa42ba6098c0e9119bd15a5e722d3aef3350..431de669dcc0530e308171ed5d1afe76e572e07e 100644 (file)
@@ -119,9 +119,8 @@ composites {
     }
     BAD_REP_POLICIES {
       description = "Contains valid policies but are also marked by fuzzy/bayes";
-      expression = "(g-:policies) & (g+:fuzzy | g+:bayes)";
+      expression = "(~g-:policies) & (-g+:fuzzy | -g+:bayes)";
       score = 0.1;
-      policy = "remove_weight";
     }
 
     .include(try=true; priority=1; duplicate=merge) "$LOCAL_CONFDIR/local.d/composites.conf"
index d553ce7efeb7b5efcbd330ee63ba99d555c3e969..308383605df819aee537c1dbb5ea6772b9c6b62e 100644 (file)
@@ -21,6 +21,8 @@
 #include "filter.h"
 #include "composites.h"
 
+#include <math.h>
+
 #define msg_err_composites(...) rspamd_default_log_function (G_LOG_LEVEL_CRITICAL, \
         "composites", task->task_pool->tag.uid, \
         G_STRFUNC, \
@@ -180,6 +182,7 @@ rspamd_composite_process_symbol_removal (rspamd_expression_atom_t *atom,
 {
        gchar t;
        struct symbol_remove_data *rd, *nrd;
+       struct rspamd_task *task = cd->task;
 
        if (ms == NULL) {
                return;
@@ -239,9 +242,13 @@ rspamd_composite_process_symbol_removal (rspamd_expression_atom_t *atom,
        if (rd == NULL) {
                DL_APPEND (rd, nrd);
                g_hash_table_insert (cd->symbols_to_remove, (gpointer)ms->name, rd);
+               msg_debug_composites ("added symbol %s to removal: %d policy, from composite %s",
+                               ms->name, nrd->action, cd->composite->sym);
        }
        else {
                DL_APPEND (rd, nrd);
+               msg_debug_composites ("append symbol %s to removal: %d policy, from composite %s",
+                               ms->name, nrd->action, cd->composite->sym);
        }
 }
 
@@ -258,7 +265,7 @@ rspamd_composite_expr_process (struct rspamd_expr_process_data *process_data,
        struct rspamd_task *task = cd->task;
        GHashTableIter it;
        gpointer k, v;
-       gdouble rc = 0;
+       gdouble rc = 0, max = 0;
 
        if (isset (cd->checked, cd->composite->id * 2)) {
                /* We have already checked this composite, so just return its value */
@@ -302,9 +309,15 @@ rspamd_composite_expr_process (struct rspamd_expr_process_data *process_data,
                                                        cd,
                                                        ms,
                                                        beg);
+
+                                       if (fabs (rc) > max) {
+                                               max = fabs (rc);
+                                       }
                                }
                        }
                }
+
+               rc = max;
        }
        else if (strncmp (sym, "g+:", 3) == 0) {
                /* Group, positive symbols only */
@@ -326,13 +339,19 @@ rspamd_composite_expr_process (struct rspamd_expr_process_data *process_data,
                                                                cd,
                                                                ms,
                                                                beg);
+
+                                               if (fabs (rc) > max) {
+                                                       max = fabs (rc);
+                                               }
                                        }
                                }
                        }
+
+                       rc = max;
                }
        }
        else if (strncmp (sym, "g-:", 3) == 0) {
-               /* Group, positive symbols only */
+               /* Group, negative symbols only */
                gr = g_hash_table_lookup (cd->task->cfg->groups, sym + 3);
 
                if (gr != NULL) {
@@ -349,9 +368,15 @@ rspamd_composite_expr_process (struct rspamd_expr_process_data *process_data,
                                                                cd,
                                                                ms,
                                                                beg);
+
+                                               if (fabs (rc) > max) {
+                                                       max = fabs (rc);
+                                               }
                                        }
                                }
                        }
+
+                       rc = max;
                }
        }
        else {
@@ -365,6 +390,9 @@ rspamd_composite_expr_process (struct rspamd_expr_process_data *process_data,
                }
        }
 
+       msg_debug_composites ("final result for composite %s is %.2f",
+                       cd->composite->sym, rc);
+
        return rc;
 }
 
index 463e3165a29e02b54160cced9e02c6d7f6ec15e5..bf5bb467c86c1ed2bf79b81818bce7ef0b473cfd 100644 (file)
@@ -619,8 +619,7 @@ rspamd_parse_expression (const gchar *line, gsize len,
                                if (p + 1 < end) {
                                        gchar t = *(p + 1);
 
-                                       if (g_ascii_isspace (t) || g_ascii_isalnum (t) ||
-                                                       rspamd_expr_is_operation_symbol (t)) {
+                                       if (t != ':') {
                                                state = PARSE_OP;
                                                continue;
                                        }