r/rust • Allsorts • Aug 24 '18

actix-lua - a safe scripting environment for Actix with the Lua Programming Language.

https://github.com/poga/actix-lua
37 Upvotes

5 comments sorted by

6

u/rm-f Aug 24 '18

What a conicidence! Thought about incorporating Lua code into actix's actors a few days ago and now you come along! Looks great! You have not implemented any sandboxing mechanisms by chance, i.e. does the Lua Actor have access to the enviroment (e.g. filesystem and os)?

22

u/matthieum [he/him] Aug 24 '18

does the Lua Actor have access to the enviroment (e.g. filesystem and os)?

When this question is asked by a user named rm -f, I shiver.

4

u/mitchtbaum Aug 24 '18

sandboxing mechanisms

That is part of rlua which has partial support, ongoing in Don't let Lua code cause panics or aborts.

2

u/devpoga Aug 25 '18

The "safe" here is about no undefined behaviour, which is ensured by the amazing rlua crate.

You can create a sandbox-ish enviroment by disabling the API(e.g. file, debug,...) you don't want lua scripts to access. It's not perfect. But IMO a perfect sandbox not something vanilla Lua can provide.

1

u/mitchtbaum Aug 24 '18 edited Aug 25 '18

poga, the author, described it further in Higher level scripting environment (comment):

Hi!

actix-lua, as you might already know, allows you to implement actix actors with Lua.

The motivation behind actix-lua is that I need to:

  1. process a large amount of realtime data.

  2. allows some customization on "how" to process the data.

For 1, actor model is a good fit since it's mostly IO-bound.

For 2, Lua is a well-known solution for embedded scripting. It also enable some nice feature like hot-reload.

I might put together a write-up for it in the future.

It could be extended to a complete solution like openresty. If you want to help or have any question, feel free to discuss on the actix-lua github repo.