From d73be348acdf9f18479734fd09ddbfdb017c47bf Mon Sep 17 00:00:00 2001 From: Daniel Silverstone Date: Sat, 4 Aug 2012 13:05:50 +0100 Subject: SUPPLE: Basic instruction count and/or memory consumption limits for the sandbox --- example/simple-example.lua | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'example') 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")) -- cgit v1.2.1