]> source.dussan.org Git - rspamd.git/commitdiff
Fix shingles key init.
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Mon, 22 Dec 2014 17:47:26 +0000 (17:47 +0000)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Mon, 22 Dec 2014 17:47:26 +0000 (17:47 +0000)
src/libserver/fuzzy_backend.c
src/plugins/fuzzy_check.c

index 1c0ceb8b510b2648b1c71f9179cfc36df2f8a2fb..3a4c198a76d3b6690d7caa11a8e392ad2b7dd224 100644 (file)
@@ -144,14 +144,14 @@ static struct rspamd_fuzzy_stmts {
        },
        {
                .idx = RSPAMD_FUZZY_BACKEND_CHECK_SHINGLE,
-               .sql = "SELECT digest_id FROM shingles WHERE value=? AND number=?",
+               .sql = "SELECT digest_id FROM shingles WHERE value=?1 AND number=?2",
                .args = "IS",
                .stmt = NULL,
                .result = SQLITE_ROW
        },
        {
                .idx = RSPAMD_FUZZY_BACKEND_GET_DIGEST_BY_ID,
-               .sql = "SELECT digest, value, time, flag FROM digests WHERE id=?",
+               .sql = "SELECT digest, value, time, flag FROM digests WHERE id=?1",
                .args = "I",
                .stmt = NULL,
                .result = SQLITE_ROW
@@ -591,6 +591,7 @@ rspamd_fuzzy_backend_check (struct rspamd_fuzzy_backend *backend,
                        else {
                                shingle_values[i] = -1;
                        }
+                       msg_debug ("looking for shingle %d -> %L: %d", i, shcmd->sgl.hashes[i], rc);
                }
                qsort (shingle_values, RSPAMD_SHINGLE_SIZE, sizeof (gint64),
                                rspamd_fuzzy_backend_int64_cmp);
@@ -621,6 +622,7 @@ rspamd_fuzzy_backend_check (struct rspamd_fuzzy_backend *backend,
                if (sel_id != -1) {
                        /* We have some id selected here */
                        rep.prob = (gdouble)max_cnt / (gdouble)RSPAMD_SHINGLE_SIZE;
+                       msg_debug ("found fuzzy hash with probability %.2f", rep.prob);
                        rc = rspamd_fuzzy_backend_run_stmt (backend,
                                        RSPAMD_FUZZY_BACKEND_GET_DIGEST_BY_ID, sel_id);
                        if (rc == SQLITE_OK) {
@@ -680,6 +682,7 @@ rspamd_fuzzy_backend_add (struct rspamd_fuzzy_backend *backend,
                                        rspamd_fuzzy_backend_run_stmt (backend,
                                                        RSPAMD_FUZZY_BACKEND_INSERT_SHINGLE,
                                                        shcmd->sgl.hashes[i], i, id);
+                                       msg_debug ("add shingle %d -> %L: %d", i, shcmd->sgl.hashes[i], id);
                                }
                        }
                }
index 55e155bf43c9e296366744ee49dd3f3cc6a479a4..7f70ae2d1d0822c02884c1d4571beb6bfff7f83f 100644 (file)
@@ -383,8 +383,8 @@ fuzzy_parse_rule (struct rspamd_config *cfg, const ucl_object_t *obj)
                k = "rspamd";
        }
        rule->shingles_key = g_string_sized_new (16);
-       blake2 (rule->hash_key->str, k, NULL, 16, strlen (k), 0);
-       rule->hash_key->len = 16;
+       blake2 (rule->shingles_key->str, k, NULL, 16, strlen (k), 0);
+       rule->shingles_key->len = 16;
 
        if (rspamd_upstreams_count (rule->servers) == 0) {
                msg_err ("no servers defined for fuzzy rule with symbol: %s",
@@ -578,6 +578,7 @@ fuzzy_cmd_from_text_part (struct fuzzy_rule *rule,
                }
                blake2b_final (&st, shcmd->basic.digest, sizeof (shcmd->basic.digest));
 
+               msg_debug ("loading shingles with key %*xs", 16, rule->shingles_key->str);
                sh = rspamd_shingles_generate (part->words, rule->shingles_key->str,
                                pool, rspamd_shingles_default_filter, NULL);
                if (sh != NULL) {