Replies: 2 comments
-
You can attach to a chunk an environment table with allowed Lua functions/modules. let lua = Lua::new_with(StdLib::NONE, LuaOptions::default())?;
let globals = lua.globals();
let env: Vec<(_, Value)> = vec![
("print", globals.get("print")?),
];
lua.load(
r#"
print("hello")
print(require) -- prints nil
"#,
)
.set_environment(lua.create_table_from(env)?)?
.exec()?; |
Beta Was this translation helpful? Give feedback.
0 replies
-
Though sandboxing should NOT be relied on as a very secure measure per se. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
How would sandboxing be done with
mlua
? I don't want scripts to be able to access any files, do any program execution, etc.Beta Was this translation helpful? Give feedback.
All reactions