From 22f8a1e66c19254516453b53fc38c699c673f3f5 Mon Sep 17 00:00:00 2001 From: Vsevolod Stakhov Date: Tue, 6 Dec 2016 18:07:40 +0000 Subject: [PATCH] [Feature] Use normalized images in fuzzy hashes --- src/plugins/fuzzy_check.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/plugins/fuzzy_check.c b/src/plugins/fuzzy_check.c index 507d224ccc..e3ccd814d9 100644 --- a/src/plugins/fuzzy_check.c +++ b/src/plugins/fuzzy_check.c @@ -2128,6 +2128,22 @@ fuzzy_generate_commands (struct rspamd_task *task, struct fuzzy_rule *rule, if (io) { g_ptr_array_add (res, io); } + + if (image->normalized_data) { + guchar norm_digest[rspamd_cryptobox_HASHBYTES]; + + rspamd_cryptobox_hash (norm_digest, + image->normalized_data->data, + image->normalized_data->len * sizeof (gint), + NULL, 0); + /* TODO: add shingles here */ + io = fuzzy_cmd_from_data_part (rule, c, flag, value, + task->task_pool, + norm_digest); + if (io) { + g_ptr_array_add (res, io); + } + } } } } -- 2.47.3