client/sandbox.lua: Add a safe subset of the standard library to the sandbox environment
This commit is contained in:
parent
8ce035f9ed
commit
b991ce1149
@ -11,7 +11,37 @@ for _, name in ipairs(buildat_safe_list) do
|
||||
buildat_safe[name] = buildat[name]
|
||||
end
|
||||
|
||||
local sandbox = {}
|
||||
local sandbox = {
|
||||
-- Base sandbox from
|
||||
-- http://stackoverflow.com/questions/1224708/how-can-i-create-a-secure-lua-sandbox/6982080#6982080
|
||||
ipairs = ipairs,
|
||||
next = next,
|
||||
pairs = pairs,
|
||||
pcall = pcall,
|
||||
tonumber = tonumber,
|
||||
tostring = tostring,
|
||||
type = type,
|
||||
unpack = unpack,
|
||||
coroutine = { create = coroutine.create, resume = coroutine.resume,
|
||||
running = coroutine.running, status = coroutine.status,
|
||||
wrap = coroutine.wrap },
|
||||
string = { byte = string.byte, char = string.char, find = string.find,
|
||||
format = string.format, gmatch = string.gmatch, gsub = string.gsub,
|
||||
len = string.len, lower = string.lower, match = string.match,
|
||||
rep = string.rep, reverse = string.reverse, sub = string.sub,
|
||||
upper = string.upper },
|
||||
table = { insert = table.insert, maxn = table.maxn, remove = table.remove,
|
||||
sort = table.sort },
|
||||
math = { abs = math.abs, acos = math.acos, asin = math.asin,
|
||||
atan = math.atan, atan2 = math.atan2, ceil = math.ceil, cos = math.cos,
|
||||
cosh = math.cosh, deg = math.deg, exp = math.exp, floor = math.floor,
|
||||
fmod = math.fmod, frexp = math.frexp, huge = math.huge,
|
||||
ldexp = math.ldexp, log = math.log, log10 = math.log10, max = math.max,
|
||||
min = math.min, modf = math.modf, pi = math.pi, pow = math.pow,
|
||||
rad = math.rad, random = math.random, sin = math.sin, sinh = math.sinh,
|
||||
sqrt = math.sqrt, tan = math.tan, tanh = math.tanh },
|
||||
os = { clock = os.clock, difftime = os.difftime, time = os.time },
|
||||
}
|
||||
|
||||
sandbox.buildat = buildat
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user