aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2014-12-22 17:47:26 +0000
committerVsevolod Stakhov <vsevolod@highsecure.ru>2014-12-22 17:47:26 +0000
commitf912ce34c0fa3a4472f05a4428a3062bf537bd3d (patch)
treec15baefc1c57306ec524ae0050995e3302004816 /src
parent76243f9769c42055a5d5523a017b8540d10ceae4 (diff)
downloadrspamd-f912ce34c0fa3a4472f05a4428a3062bf537bd3d.tar.gz
rspamd-f912ce34c0fa3a4472f05a4428a3062bf537bd3d.zip
Fix shingles key init.
Diffstat (limited to 'src')
-rw-r--r--src/libserver/fuzzy_backend.c7
-rw-r--r--src/plugins/fuzzy_check.c5
2 files changed, 8 insertions, 4 deletions
diff --git a/src/libserver/fuzzy_backend.c b/src/libserver/fuzzy_backend.c
index 1c0ceb8b5..3a4c198a7 100644
--- a/src/libserver/fuzzy_backend.c
+++ b/src/libserver/fuzzy_backend.c
@@ -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);
}
}
}
diff --git a/src/plugins/fuzzy_check.c b/src/plugins/fuzzy_check.c
index 55e155bf4..7f70ae2d1 100644
--- a/src/plugins/fuzzy_check.c
+++ b/src/plugins/fuzzy_check.c
@@ -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) {