Skip to content

luasandbox binary#166

Closed
sathieu wants to merge 4 commits intomozilla-services:masterfrom
sathieu:luasandbox_bin
Closed

luasandbox binary#166
sathieu wants to merge 4 commits intomozilla-services:masterfrom
sathieu:luasandbox_bin

Conversation

@sathieu
Copy link
Copy Markdown
Contributor

@sathieu sathieu commented Nov 20, 2016

This add a luasandbox binary with behavior similar to lua5.1.

- setprogdir and setpath (private) functions are back
- luaopen_package has an additionnal argument "sandboxed"
  - which defaults to false
  - which is set to true from lsb_init
- if sandboxed, behavior is not changed
- if not sandboxed:
  - cpath and path, are set in "lsb_config" hidden table
  - package has a metatable which only allow access to cpath, path and preload
    when not sandboxed.
@sathieu
Copy link
Copy Markdown
Contributor Author

sathieu commented Nov 20, 2016

Context: We need to run tests after a package is built.

This can now be done with something like (from lpeg source):

LUA_INIT=' package.path="sandbox-lpeg/?.lua;sandbox-lpeg/?/init.lua;"..package.path; package.cpath="sandbox-lpeg/?.so;"..package.cpath; ' luasandbox test.lua

This is how lua packages are tested in Debian after building [1]. Also, package.preload in used [2].

Additionally, LUA_CPATH and LUA_PATH environment variables are handled.

Refs:

@trink
Copy link
Copy Markdown
Contributor

trink commented Nov 20, 2016

Thanks for the submission but testing sandbox modules in an altered version of the sandbox is not an acceptable approach. Instead a proper host environment should be setup around the real sandbox (similar to the lpeg grammar tester (exposing the generic sandbox), the Hindsight admin plugin tester (exposing a Heka sandbox) and the sandbox module tests. See: mozilla-services/hindsight#19 (we would also need something similar for the generic sandbox). Ideally when this is generalized we could use this for the sandbox module tests instead of the custom test executables.

@trink trink closed this Nov 20, 2016
@sathieu
Copy link
Copy Markdown
Contributor Author

sathieu commented Nov 21, 2016

The thing is we want to use the same tests as lua5.1, this means using upstream tests (i.e not sandbox modules tests, but lua tests like https://github.com/LuaDist/lpeg/blob/master/test.lua).

Also, having an interactive CLI will help development of lua sandbox extensions.

I'm afraid I'll need to keep this patches in Debian anyway.

@bbinet
Copy link
Copy Markdown
Contributor

bbinet commented Nov 21, 2016

I also think it could be useful to have an interactive luasandbox CLI.

@trink
Copy link
Copy Markdown
Contributor

trink commented Nov 21, 2016

From a Heka sandbox perspective an interactive CLI is impractical since it requires two functions to be defined before execution. Have you used the Plugin tester UI. It allows you to test your code, capture and browse test input, view debug output, and capture and browse plugin output. The CLI wouldn't even come close to that level of usefulness for development. I have explored a number of approaches over the years the best one was a CLI plugin tester/profiler which worked well but in the end had very little user adoption.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants