local env = {
type = type,
tonumber = tonumber,
tostring = tostring,
select = select,
unpack = unpack,
next = next,
pairs = pairs,
ipairs = ipairs,
assert = assert,
error = error,
pcall = pcall,
xpcall = xpcall,
string = {
byte = string.byte,
char = string.char,
-- no string.dump
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 = {
concat = table.concat,
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,
-- no math.random
-- no math.randomseed
sin = math.sin,
sinh = math.sinh,
sqrt = math.sqrt,
tan = math.tan,
tanh = math.tanh,
}
}
Evaluating
plugin.luawill probably look something like this:I think it goes without saying that it probably shouldn't be evaluated with full unrestricted access to the global environment. The question is should it be evaluated with a completely clean environment, without access to anything, or with a subset of lua stdlib like for example this:
env
cc @lewis6991