Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lua packetlib/v1 #12506

Closed
wants to merge 5 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions src/detect-lua.c
Original file line number Diff line number Diff line change
Expand Up @@ -474,9 +474,8 @@ static void *DetectLuaThreadInit(void *data)

if (lua->allow_restricted_functions) {
luaL_openlibs(t->luastate);
} else {
SCLuaSbLoadLibs(t->luastate);
}
SCLuaSbLoadLibs(t->luastate);
Comment on lines -488 to +478
Copy link
Member

@jasonish jasonish Jan 30, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Keep the if/else. In the case of allowing restricted libs it should look like:

    luaL_openlibs(luastate);
    SCLuaRequirefBuiltIns(luastate);

As SCLuaSbLoadLibs is going to override the requires, plus re-load in already loaded libs, then wipe the ones that are not allowed. SCLuaRequirefBuiltIns just augments the standard libs with ours.


LuaRegisterExtensions(t->luastate);

Expand Down Expand Up @@ -589,9 +588,8 @@ static int DetectLuaSetupPrime(DetectEngineCtx *de_ctx, DetectLuaData *ld, const
return -1;
if (ld->allow_restricted_functions) {
luaL_openlibs(luastate);
} else {
SCLuaSbLoadLibs(luastate);
}
SCLuaSbLoadLibs(luastate);

/* hackish, needed to allow unittests to pass buffers as scripts instead of files */
#ifdef UNITTESTS
Expand Down
Loading