77
88#include < CommonUtils.h>
99#include < Result.h>
10+ #include < Telemetry.h>
1011#include < iostream>
1112#include < map>
1213#include < memory>
@@ -75,6 +76,7 @@ Result<Status> LuaEvaluator::Evaluate(const string& script, IndicatorsTree& indi
7576 error += lua_tostring (L, -1 );
7677 }
7778 OsConfigLogError (log, " %s" , error.c_str ());
79+ OSConfigTelemetryStatusTrace (" luaL_loadstring" , -1 );
7880 lua_pop (L, 1 );
7981 return Error (error);
8082 }
@@ -86,6 +88,7 @@ Result<Status> LuaEvaluator::Evaluate(const string& script, IndicatorsTree& indi
8688 if (!upvalueName)
8789 {
8890 OsConfigLogError (log, " Could not set restricted Lua environment" );
91+ OSConfigTelemetryStatusTrace (" lua_setupvalue" , -1 );
8992 lua_pop (L, 1 );
9093 lua_settop (L, 0 );
9194 return Error (" Could not set restricted Lua environment" );
@@ -100,6 +103,7 @@ Result<Status> LuaEvaluator::Evaluate(const string& script, IndicatorsTree& indi
100103 lua_pop (L, 1 );
101104 lua_settop (L, 0 );
102105 OsConfigLogError (log, " Restricted Lua environment not found" );
106+ OSConfigTelemetryStatusTrace (" lua_getfield" , -1 );
103107 return Error (" Restricted Lua environment not found" );
104108 }
105109
@@ -112,6 +116,7 @@ Result<Status> LuaEvaluator::Evaluate(const string& script, IndicatorsTree& indi
112116 error += lua_tostring (L, -1 );
113117 }
114118 OsConfigLogError (log, " %s" , error.c_str ());
119+ OSConfigTelemetryStatusTrace (" lua_pcall" , result);
115120 luaL_traceback (L, L, NULL , 1 );
116121 const char * traceback = lua_tostring (L, -1 );
117122 if (traceback)
@@ -130,6 +135,7 @@ Result<Status> LuaEvaluator::Evaluate(const string& script, IndicatorsTree& indi
130135 {
131136 lua_settop (L, 0 );
132137 OsConfigLogError (log, " Lua script did not return a value" );
138+ OSConfigTelemetryStatusTrace (" lua_gettop" , -1 );
133139 return Error (" Lua script did not return a value" );
134140 }
135141
@@ -295,6 +301,7 @@ int LuaEvaluator::LuaProcedureWrapper(lua_State* L)
295301 if (!lua_isstring (L, -1 ))
296302 {
297303 OsConfigLogError (log, " Failed to get procedure name from upvalue" );
304+ OSConfigTelemetryStatusTrace (" lua_upvalueindex" , -1 );
298305 lua_pushstring (L, " Failed to get procedure name from upvalue" );
299306 lua_error (L);
300307 return 0 ;
@@ -305,6 +312,7 @@ int LuaEvaluator::LuaProcedureWrapper(lua_State* L)
305312 if ((callContext->action != ComplianceEngine::Action::Remediate) && (procedureName.substr (0 , 9 ) == " Remediate" ))
306313 {
307314 OsConfigLogError (log, " Remediation not allowed in audit mode" );
315+ OSConfigTelemetryStatusTrace (" action" , EPERM);
308316 lua_pushstring (L, " Remediation not allowed in audit mode" );
309317 lua_error (L);
310318 return 0 ;
@@ -314,6 +322,7 @@ int LuaEvaluator::LuaProcedureWrapper(lua_State* L)
314322 if (!lua_islightuserdata (L, -1 ))
315323 {
316324 OsConfigLogError (log, " Failed to get function pointer from upvalue" );
325+ OSConfigTelemetryStatusTrace (" lua_islightuserdata" , -1 );
317326 lua_pushstring (L, " Failed to get function pointer from upvalue" );
318327 lua_error (L);
319328 return 0 ;
@@ -324,6 +333,7 @@ int LuaEvaluator::LuaProcedureWrapper(lua_State* L)
324333 if (!actionFunc)
325334 {
326335 OsConfigLogError (log, " No function for procedure %s" , procedureName.c_str ());
336+ OSConfigTelemetryStatusTrace (" actionFunc" , ENOENT);
327337 lua_pushstring (L, (" No function for procedure: " + procedureName).c_str ());
328338 lua_error (L);
329339 return 0 ;
0 commit comments