Sandboxing Lua Code

Sandboxing Lua Code

Postby v-rob » Wed Feb 27, 2019 11:31 pm

So, Mesecons has the luacontroller which can run Lua code, but it has protections against things like infinite loops/recursion, memory usage, io/os function calls, and program execution time. How does it protect against these, and how could I do the same thing?

Essentially, I want to have user-inputted Lua code that is sandboxed against malicious code as to not crash servers.
v-rob
Member
 
Posts: 620
Joined: Thu Mar 24, 2016 3:19 am
GitHub: v-rob

Re: Sandboxing Lua Code

Postby wziard » Thu Feb 28, 2019 11:19 am

Use the source, luke!

https://github.com/minetest-mods/meseco ... r/init.lua

I'm not yet really fluent enough in lua to understand everything that's going on there so I can't really tell you how I think it works, because I might be wrong. But if you want to use it you'll have to learn how it works yourself anyway. Slog through that init.lua , looking up everything you don't understand. Then you know how it works. Then you can use it.
wziard
Member
 
Posts: 131
Joined: Mon Oct 29, 2018 7:12 pm

Re: Sandboxing Lua Code

Postby ShadMOrdre » Thu Feb 28, 2019 6:08 pm

wziard, this is classic advise.
Use the source, luke!


v-rob,

Other examples to look at are Micus' micupack mod, and the Digilines mods.

micupack, IIRC, has a sandboxed Lua controller. The varous Digilines mods also have interaction with the mesecons controller, and include their own brand of controller.

As wziard said, lots of code reading.....and May the Source be with you!
ShadMOrdre
Member
 
Posts: 297
Joined: Mon Dec 29, 2014 8:07 am
GitHub: ShadMOrdre
In-game: shadmordre

Re: Sandboxing Lua Code

Postby micu » Thu Mar 21, 2019 10:54 pm

Hello all,

Sorry to answer a topic that is almost a month old, but I had to correct one thing about my modpack:
micupack, IIRC, has a sandboxed Lua controller.

I can't take any credit for that - this is Joe7575's modpack Techpack that has such computer (please check safer_lua and sl_controller sources).

Cheers!
Micu
micu
Member
 
Posts: 18
Joined: Fri Oct 19, 2018 7:50 am
GitHub: realmicu

Re: Sandboxing Lua Code

Postby ShadMOrdre » Fri Mar 22, 2019 6:51 pm

Micu,

Thank you for clarifying this info. I hope v-rob can find what he's looking for.
ShadMOrdre
Member
 
Posts: 297
Joined: Mon Dec 29, 2014 8:07 am
GitHub: ShadMOrdre
In-game: shadmordre



Return to Modding Discussion



Who is online

Users browsing this forum: Bing Bot [Bot] and 0 guests