commit f95b1d9: [Minor] Reputation: Check results before setting

Vsevolod Stakhov vsevolod at highsecure.ru
Wed Jul 24 09:21:03 UTC 2019


Author: Vsevolod Stakhov
Date: 2019-07-24 10:14:07 +0100
URL: https://github.com/rspamd/rspamd/commit/f95b1d975c9f768b386299a352a740d7a855a982 (HEAD -> master)

[Minor] Reputation: Check results before setting

---
 src/plugins/lua/reputation.lua | 16 +++++++++-------
 1 file changed, 9 insertions(+), 7 deletions(-)

diff --git a/src/plugins/lua/reputation.lua b/src/plugins/lua/reputation.lua
index aa6697eab..9e28e876b 100644
--- a/src/plugins/lua/reputation.lua
+++ b/src/plugins/lua/reputation.lua
@@ -484,14 +484,16 @@ local function ip_reputation_idempotent(task, rule)
     end
   end
   local sc = extract_task_score(task, rule)
-  if asn then
-    rule.backend.set_token(task, rule, cfg.asn_prefix .. asn, sc)
-  end
-  if country then
-    rule.backend.set_token(task, rule, cfg.country_prefix .. country, sc)
-  end
+  if sc then
+    if asn then
+      rule.backend.set_token(task, rule, cfg.asn_prefix .. asn, sc)
+    end
+    if country then
+      rule.backend.set_token(task, rule, cfg.country_prefix .. country, sc)
+    end
 
-  rule.backend.set_token(task, rule, cfg.ip_prefix .. tostring(ip), sc)
+    rule.backend.set_token(task, rule, cfg.ip_prefix .. tostring(ip), sc)
+  end
 end
 
 -- Selectors are used to extract reputation tokens


More information about the Commits mailing list