]> source.dussan.org Git - rspamd.git/commitdiff
Allow to skip unknown flags in fuzzy_check module.
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Thu, 5 Dec 2013 12:03:47 +0000 (12:03 +0000)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Thu, 5 Dec 2013 12:03:47 +0000 (12:03 +0000)
conf/metrics.conf
conf/modules.conf
src/plugins/fuzzy_check.c

index 9dfdb1c00b9487325502bdb5ff6cba11383a71b6..62c633bee27b836f2e8c962037a6859a6b7b7ef9 100644 (file)
@@ -408,9 +408,9 @@ metric {
         name = "BAYES_HAM";
     }
     symbol {
-        weight = 10.0;
+        weight = 5.0;
         description = "Generic fuzzy hash match";
-        name = "R_FUZZY";
+        name = "FUZZY_UNKNOWN";
     }
     symbol {
         weight = 10.0;
index a6a2adbeddeb2ff3c4a083c2f0012f0fbd6785e8..b007ae8b5419b8a87831fc114635dfb1faa690fb 100644 (file)
@@ -3,9 +3,9 @@ fuzzy_check {
     min_bytes = 300;
        rule {
                servers = "highsecure.ru:11335";
-               symbol = "R_FUZZY";
+               symbol = "FUZZY_UNKNOWN";
                mime_types = "application/pdf";
-               max_score = 10;
+               max_score = 10.0;
                read_only = yes;
                fuzzy_map = {
                        FUZZY_DENIED {
index 1a165787895e05c124d45ebcadf9144cbd976e49..db1325d15693db98d1113d646ac53d045d8a875d 100644 (file)
@@ -85,6 +85,7 @@ struct fuzzy_rule {
        GList *mime_types;
        double max_score;
        gboolean read_only;
+       gboolean skip_unknown;
 };
 
 struct fuzzy_ctx {
@@ -345,9 +346,15 @@ fuzzy_parse_rule (struct config_file *cfg, ucl_object_t *obj)
        if ((value = ucl_object_find_key (obj, "max_score")) != NULL) {
                rule->max_score = ucl_obj_todouble (value);
        }
+       if ((value = ucl_object_find_key (obj,  "symbol")) != NULL) {
+               rule->symbol = ucl_obj_tostring (value);
+       }
        if ((value = ucl_object_find_key (obj, "read_only")) != NULL) {
                rule->read_only = ucl_obj_toboolean (value);
        }
+       if ((value = ucl_object_find_key (obj, "skip_unknown")) != NULL) {
+               rule->skip_unknown = ucl_obj_toboolean (value);
+       }
 
        if ((value = ucl_object_find_key (obj, "servers")) != NULL) {
                if (value->type == UCL_ARRAY) {
@@ -541,11 +548,14 @@ fuzzy_io_callback (gint fd, short what, void *arg)
                                symbol = map->symbol;
                                nval = fuzzy_normalize (value, map->weight);
                        }
-                       msg_info ("<%s>, found fuzzy hash '%s' with weight: %.2f, in list: %s:%d",
-                                       session->task->message_id, fuzzy_to_string (session->h), nval, symbol, flag);
-                       rspamd_snprintf (buf, sizeof (buf), "%d: %d / %.2f", flag, value, nval);
-                       insert_result (session->task, symbol, nval, g_list_prepend (NULL, 
+                       msg_info ("<%s>, found fuzzy hash '%s' with weight: %.2f, in list: %s:%d%s",
+                                       session->task->message_id, fuzzy_to_string (session->h), nval, symbol,
+                                       flag, map == NULL ? "(unknown)" : "");
+                       if (map != NULL || !session->rule->skip_unknown) {
+                               rspamd_snprintf (buf, sizeof (buf), "%d: %d / %.2f", flag, value, nval);
+                               insert_result (session->task, symbol, nval, g_list_prepend (NULL,
                                                memory_pool_strdup (session->task->task_pool, buf)));
+                       }
                }
                goto ok;
        }