mirror of
https://github.com/luanti-org/luanti.git
synced 2025-06-27 16:36:03 +00:00
remove os.date and string.dump
This commit is contained in:
parent
8cfc8d8c60
commit
1be9c614d1
2 changed files with 25 additions and 11 deletions
|
@ -232,14 +232,6 @@ if core.set_read_node and core.set_push_node then
|
||||||
core.set_read_node = nil
|
core.set_read_node = nil
|
||||||
|
|
||||||
local function push_node(content, param1, param2)
|
local function push_node(content, param1, param2)
|
||||||
if false then -- TODO: tmp
|
|
||||||
print(dump(debug.traceback()))
|
|
||||||
--~ error()
|
|
||||||
for i = 0, 10 do
|
|
||||||
print("i="..i)
|
|
||||||
print(dump(debug.getinfo(i)))
|
|
||||||
end
|
|
||||||
end
|
|
||||||
return {name = content2name[content], param1 = param1, param2 = param2}
|
return {name = content2name[content], param1 = param1, param2 = param2}
|
||||||
end
|
end
|
||||||
core.set_push_node(push_node)
|
core.set_push_node(push_node)
|
||||||
|
|
|
@ -408,19 +408,33 @@ void ScriptApiSecurity::initializeSecuritySSCSM()
|
||||||
"xpcall",
|
"xpcall",
|
||||||
// Completely safe libraries
|
// Completely safe libraries
|
||||||
"coroutine",
|
"coroutine",
|
||||||
"string", //TODO: string.dump?
|
|
||||||
"table",
|
"table",
|
||||||
"math",
|
"math",
|
||||||
"bit",
|
"bit",
|
||||||
};
|
};
|
||||||
static const char *os_whitelist[] = {
|
static const char *os_whitelist[] = {
|
||||||
"date", // TODO: can crash? (<http://lua-users.org/wiki/SandBoxes>)
|
|
||||||
"difftime",
|
"difftime",
|
||||||
"time"
|
"time"
|
||||||
};
|
};
|
||||||
static const char *debug_whitelist[] = {
|
static const char *debug_whitelist[] = {
|
||||||
"getinfo", // used by builtin and unset before mods load //TODO
|
"getinfo", // used by builtin and unset before mods load //TODO
|
||||||
"traceback" //TODO: is this fine, or does it print paths of C functions?
|
"traceback"
|
||||||
|
};
|
||||||
|
static const char *string_whitelist[] = { // all but string.dump
|
||||||
|
"byte",
|
||||||
|
"char",
|
||||||
|
"dump",
|
||||||
|
"find",
|
||||||
|
"format",
|
||||||
|
"gmatch",
|
||||||
|
"gsub",
|
||||||
|
"len",
|
||||||
|
"lower",
|
||||||
|
"match",
|
||||||
|
"rep",
|
||||||
|
"reverse",
|
||||||
|
"sub",
|
||||||
|
"upper"
|
||||||
};
|
};
|
||||||
#if USE_LUAJIT
|
#if USE_LUAJIT
|
||||||
static const char *jit_whitelist[] = {
|
static const char *jit_whitelist[] = {
|
||||||
|
@ -479,6 +493,14 @@ void ScriptApiSecurity::initializeSecuritySSCSM()
|
||||||
lua_pop(L, 1); // Pop old debug
|
lua_pop(L, 1); // Pop old debug
|
||||||
|
|
||||||
|
|
||||||
|
// Copy safe string functions
|
||||||
|
lua_getglobal(L, "string");
|
||||||
|
lua_newtable(L);
|
||||||
|
copy_safe(L, string_whitelist, sizeof(string_whitelist));
|
||||||
|
lua_setfield(L, -3, "string");
|
||||||
|
lua_pop(L, 1); // Pop old string
|
||||||
|
|
||||||
|
|
||||||
#if USE_LUAJIT
|
#if USE_LUAJIT
|
||||||
// Copy safe jit functions, if they exist
|
// Copy safe jit functions, if they exist
|
||||||
lua_getglobal(L, "jit");
|
lua_getglobal(L, "jit");
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue