7 Commits

Author SHA1 Message Date
1660780960 syntax highlighting in ReadMe options.env 2025-06-19 05:00:51 +00:00
e0710a284d ReadMe error in options.env example 2025-06-19 04:55:52 +00:00
Alan Boudreault
e04ddbe3ae chore(rockspec) fix the rockspec source url 2021-11-04 19:15:52 +01:00
Alan Boudreault
0108834dd3 chore(rockspec) switch to git+https protocol 2021-11-02 16:54:46 +01:00
Alan Boudreault
ee3285e2fd chore(*) luarocks only support git+ssh protocol 2021-11-02 15:59:48 +01:00
Alan Boudreault
07a01090e7 chore(*) fix rockspec source url 2021-11-02 15:44:45 +01:00
Enrique García Cota
35714d7a92 chore rockspec for 1.0.1 2021-01-07 18:55:19 +01:00
2 changed files with 18 additions and 13 deletions

View File

@@ -140,24 +140,29 @@ If you want to turn off the quota completely, pass `quota=false` instead.
Use the `env` option to inject additional variables to the environment in which the sandboxed code is executed.
local msg = sandbox.run('return foo', {env = {foo = 'This is a global var on the the environment'}})
```lua
local msg = sandbox.run('return foo', {env = {foo = 'This is a global var on the the environment'}})
```
The `env` variable will be used as an "index" by the sandbox environment, but it will *not* be modified at all (changes
to the environment are thus lost). The only way to "get information out" from the sandboxed environments are:
Through side effects, like writing to a database. You will have to provide the side-effects functions in `env`:
local val = 1
local env = { write_db = function(new_val) val = new_val end }
sandbox.run('write_db(2)')
assert(val = 2)
```lua
local val = 1
local env = { write_db = function(new_val) val = new_val end }
sandbox.run('write_db(2)', { env = env })
assert(val = 2)
```
Through returned values:
local env = { amount = 1 }
local result = sandbox.run('return amount + 1', { env = env })
assert(result = 2)
```lua
local env = { amount = 1 }
local result = sandbox.run('return amount + 1', { env = env })
assert(result = 2)
```
Installation
============

View File

@@ -1,15 +1,15 @@
package = "sandbox"
version = "1.0.0-0"
version = "1.0.1-4"
source = {
url = "git://github.com/kikito/sandbox.lua.git",
tag = "v1.0.0"
url = "git+https://github.com/kikito/lua-sandbox",
tag = "v1.0.1"
}
description = {
summary = "A pure-lua solution for running untrusted Lua code.",
homepage = "https://github.com/kikito/sandbox.lua",
homepage = "https://github.com/kikito/lua-sandbox",
}
dependencies = {