From: Vsevolod Stakhov Date: Fri, 20 Jul 2018 16:37:00 +0000 (+0100) Subject: [Minor] Use hashes in SPF reputation selector X-Git-Tag: 1.7.9~73 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=d56de7442ac7437d889b873afe3a23ab829c3fd0;p=rspamd.git [Minor] Use hashes in SPF reputation selector --- diff --git a/src/plugins/lua/reputation.lua b/src/plugins/lua/reputation.lua index 3c733a45c..536710f13 100644 --- a/src/plugins/lua/reputation.lua +++ b/src/plugins/lua/reputation.lua @@ -554,6 +554,11 @@ local function spf_reputation_filter(task, rule) -- Don't care about bad/missing spf if not spf_record or not spf_allow then return end + local cr = require "rspamd_cryptobox_hash" + local hkey = cr.create(spf_record):base32():sub(1, 32) + + rspamd_logger.debugm(N, task, 'check spf record %s -> %s', spf_record, hkey) + local function tokens_cb(err, token, values) if values then local score = generic_reputation_calc(token, rule, values) @@ -565,7 +570,7 @@ local function spf_reputation_filter(task, rule) end end - rule.backend.get_token(task, rule, spf_record, tokens_cb) + rule.backend.get_token(task, rule, hkey, tokens_cb) end local function spf_reputation_idempotent(task, rule) @@ -588,7 +593,12 @@ local function spf_reputation_idempotent(task, rule) end if need_set then - rule.backend.set_token(task, rule, spf_record, token) + local cr = require "rspamd_cryptobox_hash" + local hkey = cr.create(spf_record):base32():sub(1, 32) + + rspamd_logger.debugm(N, task, 'set spf record %s -> %s = %s', + spf_record, hkey, token) + rule.backend.set_token(task, rule, hkey, token) end end