From: Jason Ish Date: Fri, 24 May 2024 22:05:58 +0000 (-0600) Subject: lua: remove sandbox lib for now X-Git-Tag: suricata-8.0.0-beta1~1250 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=011f0ba9946c775313e499041757182231cd14f4;p=thirdparty%2Fsuricata.git lua: remove sandbox lib for now Not sure if I see a use for it, some extra debug logging might be just as useful for those writing Lua scripts. --- diff --git a/src/util-lua-sandbox.c b/src/util-lua-sandbox.c index c13fdaf5dd..192aacedc4 100644 --- a/src/util-lua-sandbox.c +++ b/src/util-lua-sandbox.c @@ -35,7 +35,6 @@ #define SANDBOX_CTX "SANDBOX_CTX" static void HookFunc(lua_State *L, lua_Debug *ar); -static int OpenSandbox(lua_State *L); /** * Lua allocator function provided to lua_newstate. @@ -364,99 +363,3 @@ void SCLuaSbResetInstructionCounter(lua_State *L) lua_sethook(L, HookFunc, LUA_MASKCOUNT, sb->hook_instruction_count); } } - -static void SetInstructionCount(lua_State *L, uint64_t instruction_limit) -{ - SCLuaSbState *ctx = SCLuaSbGetContext(L); - if (ctx != NULL) { - ctx->instruction_limit = instruction_limit; - } -} - -static uint64_t GetInstructionCount(lua_State *L) -{ - SCLuaSbState *ctx = SCLuaSbGetContext(L); - if (ctx != NULL) { - return ctx->instruction_count; - } - return 0; -} - -static int L_TotalAlloc(lua_State *L) -{ - SCLuaSbState *ctx = SCLuaSbGetContext(L); - if (ctx != NULL) { - lua_pushinteger(L, ctx->alloc_bytes); - } else { - lua_pushinteger(L, 0); - } - return 1; -} - -static int L_GetAllocLimit(lua_State *L) -{ - SCLuaSbState *ctx = SCLuaSbGetContext(L); - if (ctx != NULL) { - lua_pushinteger(L, ctx->alloc_limit); - } else { - lua_pushinteger(L, 0); - } - return 1; -} - -static int L_SetAllocLimit(lua_State *L) -{ - SCLuaSbState *ctx = SCLuaSbGetContext(L); - if (ctx != NULL) { - ctx->alloc_limit = luaL_checkinteger(L, 1); - } - return 0; -} - -static int L_GetInstructionCount(lua_State *L) -{ - lua_pushinteger(L, GetInstructionCount(L)); - return 1; -} - -static int L_GetInstructionLimit(lua_State *L) -{ - SCLuaSbState *ctx = SCLuaSbGetContext(L); - if (ctx != NULL) { - lua_pushinteger(L, ctx->instruction_limit); - } else { - lua_pushinteger(L, 0); - } - return 1; -} - -static int L_SetInstructionLimit(lua_State *L) -{ - SetInstructionCount(L, luaL_checkinteger(L, 1)); - return 0; -} - -static int L_ResetInstructionCount(lua_State *L) -{ - SCLuaSbResetInstructionCounter(L); - return 0; -} - -static const luaL_Reg sblib[] = { - // clang-format off - { "totalalloc", L_TotalAlloc }, - { "getalloclimit", L_GetAllocLimit }, - { "setalloclimit", L_SetAllocLimit }, - { "instructioncount", L_GetInstructionCount }, - { "getinstructionlimit", L_GetInstructionLimit }, - { "setinstructionlimit", L_SetInstructionLimit }, - { "resetinstructioncount", L_ResetInstructionCount }, - { NULL, NULL } - // clang-format on -}; - -static int OpenSandbox(lua_State *L) -{ - luaL_newlib(L, sblib); - return 1; -}