mirror of
https://github.com/TangentFoxy/lua-sandbox.git
synced 2025-07-28 02:52:22 +00:00
feat(sandbox) explicitly drop support of quotas on LuaJIT
The solution we use in PUC Rio Lua (with debug.sethook) simply does not work in LuaJIT. * We have added a `sandbox.quota_supported` field to signal this feature (or lack of thereof) * We explicitly return an error if `options.quota` is passed on a LuaJIT environment, in order to prevent LuaJIT users from believing that they are protected against infinite loops.
This commit is contained in:
committed by
Enrique García Cota
parent
50bfa4abca
commit
485a14697c
@@ -65,7 +65,7 @@ sandbox.run('while true do end') -- raise errors after 500000 instructions
|
||||
sandbox.run('while true do end', {quota=10000}) -- raise error after 10000 instructions
|
||||
```
|
||||
|
||||
Note that if the quota is low enough, sandboxed functions that do lots of calculations might fail:
|
||||
If the quota is low enough, sandboxed functions that do lots of calculations might fail:
|
||||
|
||||
``` lua
|
||||
local f = function()
|
||||
@@ -77,6 +77,8 @@ end
|
||||
sandbox.run(f, {quota=100}) -- raises error before the function ends
|
||||
```
|
||||
|
||||
Note: This feature is not available in LuaJIT
|
||||
|
||||
### options.env
|
||||
|
||||
Use the `env` option to inject additional variables to the environment in which the sandboxed function is executed.
|
||||
|
Reference in New Issue
Block a user