WeaselGames / godot_luaAPI

Godot LuaAPI
https://luaapi.weaselgames.info
Other
347 stars 27 forks source link

Feature Request/question: a way to limit execution time? #183

Closed JasonTable closed 7 months ago

JasonTable commented 8 months ago

Is your feature request related to a problem? Please describe. one of the selling points of this plugin is its sandboxing capabilities. So if i were to use it to run untrusted user created code, one minor exploit they could do is freeze the software with a while true loop. It's a minor nuisance at worst but i would still like to mitigate it if possible.

Describe the solution you'd like Is there a way to limit the execution time of the lua code so this can't happen?

Trey2k commented 8 months ago

This can be done using Lua hooks. The example on the wiki for set_hook shows how to force a coroutine to yield every 8 cycles. But you can also do things like raise an error to stop execution if you are no using coroutines.

RadiantUwU commented 8 months ago

This can be done using Lua hooks. The example on the wiki for set_hook shows how to force a coroutine to yield ever 8 cycles. But you can also do things like raise an error to stop execution if you are no using coroutines.

I thought you cannot yield from lua hooks?

RadiantUwU commented 8 months ago

Nvm. image

RadiantUwU commented 8 months ago

Nvm. image

Trey2k commented 7 months ago

I am going to close this as complete as there has been no follow up. Feel free to re open if you are still having issues.