commit 6b9818e: [Minor] SURBL: Add failure symbols

Vsevolod Stakhov vsevolod at highsecure.ru
Fri Mar 22 12:21:04 UTC 2019


Author: Vsevolod Stakhov
Date: 2019-03-22 12:16:07 +0000
URL: https://github.com/rspamd/rspamd/commit/6b9818e6842cc0b1f684b5d5abcd30c995f939f9

[Minor] SURBL: Add failure symbols
Issue: #2801

---
 src/plugins/lua/rbl.lua |  2 +-
 src/plugins/surbl.c     | 23 ++++++++++++++++++++---
 2 files changed, 21 insertions(+), 4 deletions(-)

diff --git a/src/plugins/lua/rbl.lua b/src/plugins/lua/rbl.lua
index 5114ffeb9..0b53a4ca1 100644
--- a/src/plugins/lua/rbl.lua
+++ b/src/plugins/lua/rbl.lua
@@ -560,7 +560,7 @@ local function add_rbl(key, rbl)
 
   -- Failure symbol
   rspamd_config:register_symbol{
-    type = 'virtual',
+    type = 'virtual,nostat',
     name = rbl.symbol .. '_FAIL',
     parent = id,
     score = 0.0,
diff --git a/src/plugins/surbl.c b/src/plugins/surbl.c
index 11d3e35d9..cab816c50 100644
--- a/src/plugins/surbl.c
+++ b/src/plugins/surbl.c
@@ -853,7 +853,14 @@ surbl_module_parse_rule (const ucl_object_t* value, struct rspamd_config* cfg)
 				0, surbl_test_url, new_suffix, SYMBOL_TYPE_CALLBACK, -1);
 		rspamd_symcache_add_dependency (cfg->cache, cb_id,
 				SURBL_REDIRECTOR_CALLBACK);
+		/* Failure symbol */
+		g_string_append (sym, "_FAIL");
+		rspamd_symcache_add_symbol (cfg->cache, sym->str,
+				0, NULL, NULL, SYMBOL_TYPE_VIRTUAL|SYMBOL_TYPE_NOSTAT, cb_id);
+		rspamd_config_add_symbol (cfg, sym->str, 0.0, "SURBL failure symbol",
+				"surbl", 0, 0, 0);
 		g_string_free (sym, TRUE);
+
 		nrules++;
 		new_suffix->callback_id = cb_id;
 		cur = ucl_object_lookup (cur_rule, "bits");
@@ -1617,9 +1624,19 @@ surbl_dns_callback (struct rdns_reply *reply, gpointer arg)
 		}
 	}
 	else {
-		msg_debug_surbl ("<%s> domain [%s] is not in surbl %s",
-			param->task->message_id, param->host_resolve,
-			param->suffix->suffix);
+		if (reply->code == RDNS_RC_NXDOMAIN || reply->code == RDNS_RC_NOREC) {
+			msg_debug_surbl ("<%s> domain [%s] is not in surbl %s",
+					param->task->message_id, param->host_resolve,
+					param->suffix->suffix);
+		}
+		else {
+			/* Insert failure symbol */
+			GString *sym = g_string_new (param->suffix->symbol);
+
+			g_string_append (sym, "_FAIL");
+			rspamd_task_insert_result (task, sym->str, 1.0,
+					rdns_strerror (reply->code));
+		}
 	}
 
 	rspamd_symcache_item_async_dec_check (param->task, param->item, M);


More information about the Commits mailing list