luerl_sandbox (luerl v1.5.1)
View SourceSandboxed execution environment for Luerl with reduction counting. This module provides a way to run Lua code with controlled execution, limiting the number of reductions (computational steps) to prevent excessive resource consumption.
The ControlFlags is a map or keyword list which can contain the
following fields
#{max_time => MaxTime, % 100 msecs
max_reductions => MaxReds, % none
spawn_opts => SpawnOpts} % []MaxReds limits the number of reductions (default no max) and
MaxTime (default 100 msecs) limits the maximum time to run the
string. SpawnOpts are spawn options to the process running the
evaluation. The default values are shown as comments. Any other fields
are ignored.
Summary
Functions
Create a new Luerl state with the standard sandboxing.
Take an existing Luerl state and run the default sandboxing on it. Or create a new Luerl state and run a sandboxing table on it.
Take an existing Luerl state and run the TablePaths on it to control the sandboxing.
Run the Lua expression controlled by the default ControlFlags in a
new LuaState with the default sandboxing.
Run the Lua expression controlled by the default ControlFlags in the
LuaState.
Run the Lua expression controlled by the ControlFlags in the LuaState.
Types
Functions
-spec init() -> LuaState when LuaState :: luerlstate().
Create a new Luerl state with the standard sandboxing.
-spec init(LuaState) -> LuaState when LuaState :: luerlstate(); (TablePaths) -> LuaState when LuaState :: luerlstate(), TablePaths :: sandboxtable().
Take an existing Luerl state and run the default sandboxing on it. Or create a new Luerl state and run a sandboxing table on it.
-spec init(LuaState, TablePaths) -> LuaState when LuaState :: luerlstate(), TablePaths :: [[atom()]].
Take an existing Luerl state and run the TablePaths on it to control the sandboxing.
-spec run(Expression) -> {Reply, LuaState} when Expression :: string(), LuaState :: luerlstate(), Reply :: {ok, Result, LuaState} | Error, Result :: luerldata(), Error :: term().
Run the Lua expression controlled by the default ControlFlags in a
new LuaState with the default sandboxing.
-spec run(Expression, LuaState) -> {Reply, LuaState} when Expression :: string(), LuaState :: luerlstate(), Reply :: {ok, Result, LuaState} | Error, Result :: luerldata(), Error :: term().
Run the Lua expression controlled by the default ControlFlags in the
LuaState.
-spec run(Expression, ControlFlags, LuaState) -> {Reply, LuaState} when Expression :: string(), ControlFlags :: controlflags(), LuaState :: luerlstate(), Reply :: {ok, Result, LuaState} | Error, Result :: luerldata(), Error :: term().
Run the Lua expression controlled by the ControlFlags in the LuaState.