aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/factoids/sandbox.lua
diff options
context:
space:
mode:
authorJokler <jokler.contact@gmail.com>2018-02-24 18:49:57 +0100
committerJokler <jokler.contact@gmail.com>2018-02-24 18:49:57 +0100
commit886bd6d4d77a941946bec0d7f8b5c422d206feea (patch)
tree794820b5f0766dfe85b04645f4a4c412c76c1375 /src/plugins/factoids/sandbox.lua
parentdb0f14a163a087261db7360a90d6ac70fb92e884 (diff)
downloadfrippy-886bd6d4d77a941946bec0d7f8b5c422d206feea.tar.gz
frippy-886bd6d4d77a941946bec0d7f8b5c422d206feea.zip
Extend Lua sandbox
Diffstat (limited to 'src/plugins/factoids/sandbox.lua')
-rw-r--r--src/plugins/factoids/sandbox.lua52
1 files changed, 37 insertions, 15 deletions
diff --git a/src/plugins/factoids/sandbox.lua b/src/plugins/factoids/sandbox.lua
index 3fde65e..31ef5cb 100644
--- a/src/plugins/factoids/sandbox.lua
+++ b/src/plugins/factoids/sandbox.lua
@@ -13,21 +13,43 @@ function sendln(text)
table.insert(output, "")
end
-local env = { print = send,
- println = sendln,
- args = args,
- input = input,
- user = user,
- channel = channel,
- request = download,
- pairs = pairs,
- table = table,
- string = string,
- tostring = tostring,
- tonumber = tonumber,
- math = math }
-
-local f, e = load(factoid, nil, nil, env)
+local sandbox_env = {
+ print = send,
+ println = sendln,
+ args = args,
+ input = input,
+ user = user,
+ channel = channel,
+ request = download,
+ string = string,
+ math = math,
+ table = table,
+ pairs = pairs,
+ ipairs = ipairs,
+ next = next,
+ select = select,
+ unpack = unpack,
+ tostring = tostring,
+ tonumber = tonumber,
+ type = type,
+ assert = assert,
+ error = error,
+ pcall = pcall,
+ xpcall = xpcall,
+ _VERSION = _VERSION
+}
+
+sandbox_env.os = {
+ clock = os.clock,
+ time = os.time,
+ difftime = os.difftime
+}
+
+sandbox_env.string.rep = nil
+sandbox_env.string.dump = nil
+sandbox_env.math.randomseed = nil
+
+local f, e = load(factoid, nil, nil, sandbox_env)
-- Check if the factoid timed out
function checktime(event, line)