summaryrefslogtreecommitdiff
path: root/example
diff options
context:
space:
mode:
authorDaniel Silverstone <dsilvers@digital-scurf.org>2012-08-04 13:05:50 +0100
committerDaniel Silverstone <dsilvers@digital-scurf.org>2012-08-04 13:05:50 +0100
commitd73be348acdf9f18479734fd09ddbfdb017c47bf (patch)
treec16b7cf6336ab0293eec6257698cfda735cabc5c /example
parenta1547bb047dfe66cffa4811d05fb08d98c6d81c6 (diff)
downloadsupple-d73be348acdf9f18479734fd09ddbfdb017c47bf.tar.gz
SUPPLE: Basic instruction count and/or memory consumption limits for the sandbox
Diffstat (limited to 'example')
-rw-r--r--example/simple-example.lua16
1 files changed, 15 insertions, 1 deletions
diff --git a/example/simple-example.lua b/example/simple-example.lua
index af19499..c385474 100644
--- a/example/simple-example.lua
+++ b/example/simple-example.lua
@@ -67,7 +67,7 @@ lprint(supple.host.run("local f = ... f()", "@test-code", function() unknown() e
-- And now, one where we pass an error from sandbox to host to sandbox and back
lprint(supple.host.run("local f = ... f(function() unknown() end)", "@test-code", function(ff) ff() end))
--- And finally, a reasonable traceback via named functions on each end...
+-- Next , a reasonable traceback via named functions on each end...
local errsrc = [[
function raises()
@@ -93,3 +93,17 @@ end
lprint(supple.host.run(errsrc, "@error-code", loopback))
+-- Now we try the sandboxing limits
+
+local long_run = [[
+ local s = ""
+ for i = 1, 10000 do
+ s = s .. "FISHFISHFISHFISHFISH"
+ end
+ return #s
+]]
+
+supple.host.set_limits { count = 100 }
+lprint(supple.host.run(long_run, "@long-code"))
+supple.host.set_limits { memory = 1000 }
+lprint(supple.host.run(long_run, "@big-code"))