plexus.cli.procedure.lua_dsl.lua_sandbox module
Lua Sandbox - Safe, restricted Lua execution environment.
Provides a sandboxed Lua runtime with: - No file system access (io, os removed) - No dangerous operations (debug, package, require removed) - Only whitelisted primitives available - Resource limits on CPU time and memory
- class plexus.cli.procedure.lua_dsl.lua_sandbox.LuaSandbox
Bases:
objectSandboxed Lua execution environment for procedure workflows.
Initialize the Lua sandbox.
- __init__()
Initialize the Lua sandbox.
- create_lua_table(python_dict: Dict[str, Any] | None = None) Any
Create a Lua table from a Python dictionary.
- Args:
python_dict: Python dictionary to convert (or None for empty table)
- Returns:
Lua table object
- eval(lua_expression: str) Any
Evaluate a Lua expression and return the result.
- Args:
lua_expression: Lua expression to evaluate
- Returns:
Result of the expression
- Raises:
LuaSandboxError: If evaluation fails
- execute(lua_code: str) Any
Execute Lua code in the sandbox.
- Args:
lua_code: Lua code string to execute
- Returns:
Result of the Lua code execution
- Raises:
LuaSandboxError: If execution fails
- get_global(name: str) Any
Get a value from Lua global scope.
- inject_primitive(name: str, primitive_obj: Any)
Inject a Python primitive object into Lua globals.
- Args:
name: Name of the primitive in Lua (e.g., “State”, “Worker”) primitive_obj: Python object to expose to Lua
- lua_table_to_dict(lua_table: Any) Dict[str, Any]
Convert a Lua table to a Python dictionary.
- Args:
lua_table: Lua table object
- Returns:
Python dictionary
- set_global(name: str, value: Any)
Set a value in Lua global scope.
- exception plexus.cli.procedure.lua_dsl.lua_sandbox.LuaSandboxError
Bases:
ExceptionRaised when Lua sandbox setup or execution fails.