commit b2d80e6: [Minor] Lua_task: Log when an unknown symbol is inserted from Lua

Vsevolod Stakhov vsevolod at highsecure.ru
Thu Jun 11 13:49:06 UTC 2020


Author: Vsevolod Stakhov
Date: 2020-06-11 14:46:59 +0100
URL: https://github.com/rspamd/rspamd/commit/b2d80e6066657216572090743ce45604a2e6ccb6 (HEAD -> master)

[Minor] Lua_task: Log when an unknown symbol is inserted from Lua

---
 src/lua/lua_task.c | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/src/lua/lua_task.c b/src/lua/lua_task.c
index 6437b0dad..75c2f0a99 100644
--- a/src/lua/lua_task.c
+++ b/src/lua/lua_task.c
@@ -1944,6 +1944,15 @@ lua_task_insert_result_common (lua_State * L, struct rspamd_scan_result *result,
 
 		/* Get additional options */
 		if (s) {
+			if (s->sym == NULL) {
+				/* Unknown symbol, print traceback */
+				lua_pushfstring (L, "unknown symbol %s", symbol_name);
+				rspamd_lua_traceback (L);
+
+				msg_info_task ("symbol insertion issue: %s", lua_tostring (L, -1));
+
+				lua_pop (L, 1); /* Traceback string */
+			}
 			for (i = args_start + 2; i <= top; i++) {
 				gint ltype = lua_type (L, i);
 
@@ -2013,6 +2022,14 @@ lua_task_insert_result_common (lua_State * L, struct rspamd_scan_result *result,
 				}
 			}
 		}
+		else {
+			lua_pushfstring (L, "insertion failed for %s", symbol_name);
+			rspamd_lua_traceback (L);
+
+			msg_info_task ("symbol insertion issue: %s", lua_tostring (L, -1));
+
+			lua_pop (L, 2); /* Traceback string + error string */
+		}
 
 	}
 	else {


More information about the Commits mailing list