Remove preventing of messing with global, as system modules mess with global
This commit is contained in:
9
Cargo.lock
generated
9
Cargo.lock
generated
@@ -1392,9 +1392,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "mlua"
|
||||
version = "0.10.2"
|
||||
version = "0.11.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9ea43c3ffac2d0798bd7128815212dd78c98316b299b7a902dabef13dc7b6b8d"
|
||||
checksum = "9be1c2bfc684b8a228fbaebf954af7a47a98ec27721986654a4cc2c40a20cc7e"
|
||||
dependencies = [
|
||||
"bstr",
|
||||
"either",
|
||||
@@ -1404,15 +1404,16 @@ dependencies = [
|
||||
"num-traits",
|
||||
"parking_lot",
|
||||
"rustc-hash",
|
||||
"rustversion",
|
||||
"serde",
|
||||
"serde-value",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "mlua-sys"
|
||||
version = "0.6.6"
|
||||
version = "0.8.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "63a11d485edf0f3f04a508615d36c7d50d299cf61a7ee6d3e2530651e0a31771"
|
||||
checksum = "3d4dc9cfc5a7698899802e97480617d9726f7da78c910db989d4d0fd4991d900"
|
||||
dependencies = [
|
||||
"cc",
|
||||
"cfg-if 1.0.0",
|
||||
|
||||
@@ -25,7 +25,7 @@ exe = "0.5"
|
||||
image = { version = "0.25", features = ["ico"] }
|
||||
urlencoding = "2.1"
|
||||
markdown = "1.0.0-alpha.16"
|
||||
mlua = { version = "0.10", features = ["lua54", "serialize", "async", "send"] }
|
||||
mlua = { version = "0.11", features = ["lua54", "serialize", "async", "send"] }
|
||||
reqwest = { version = "0.10", default-features = false, features = [
|
||||
"json",
|
||||
"rustls-tls",
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
FROM nickblah/lua:5.4-luarocks-alpine AS build
|
||||
RUN apk add --no-cache build-base rust cargo lua5.4-dev pkgconfig openssl-dev m4 bsd-compat-headers
|
||||
# Install lua modules here.
|
||||
RUN luarocks install luasec
|
||||
RUN luarocks install luasocket
|
||||
RUN luarocks install luasec
|
||||
RUN luarocks install lua-cjson
|
||||
RUN luarocks install base64
|
||||
RUN luarocks install inspect
|
||||
@@ -17,7 +17,7 @@ RUN cargo build --release
|
||||
# Deploy stage
|
||||
FROM alpine
|
||||
WORKDIR /app
|
||||
RUN apk update && apk add --no-cache ca-certificates openssl libgcc lua5.4-libs
|
||||
RUN apk update && apk add --no-cache ca-certificates openssl libgcc lua5.4-libs readline
|
||||
|
||||
COPY --from=build /usr/local/bin/lua /usr/local/bin/lua
|
||||
COPY --from=build /usr/local/bin/luarocks /usr/local/bin/luarocks
|
||||
|
||||
34
src/main.rs
34
src/main.rs
@@ -278,23 +278,23 @@ async fn file_handler(request: Request) -> impl IntoResponse {
|
||||
std::env::set_current_dir(full_base_path).unwrap();
|
||||
|
||||
// Before executing user-code, make sure they can't screw with `global`
|
||||
lua.load(
|
||||
r#"
|
||||
setmetatable(_G, {
|
||||
__newindex = function (_, n)
|
||||
error("attempt to write to undeclared variable "..n, 2)
|
||||
end,
|
||||
__index = function (_, n)
|
||||
error("attempt to read undeclared variable "..n, 2)
|
||||
end,
|
||||
})"#,
|
||||
)
|
||||
.exec()
|
||||
.map_err(|e| {
|
||||
std::env::set_current_dir(&*CWD).unwrap();
|
||||
eprintln!("Lua Error: {e:?}");
|
||||
render_lua_error(e)
|
||||
})?;
|
||||
// lua.load(
|
||||
// r#"
|
||||
// setmetatable(_G, {
|
||||
// __newindex = function (_, n)
|
||||
// error("attempt to write to undeclared variable "..n, 2)
|
||||
// end,
|
||||
// __index = function (_, n)
|
||||
// error("attempt to read undeclared variable "..n, 2)
|
||||
// end,
|
||||
// })"#,
|
||||
// )
|
||||
// .exec()
|
||||
// .map_err(|e| {
|
||||
// std::env::set_current_dir(&*CWD).unwrap();
|
||||
// eprintln!("Lua Error: {e:?}");
|
||||
// render_lua_error(e)
|
||||
// })?;
|
||||
|
||||
let script = lua.load(script).eval::<LuaValue>().map_err(|e| {
|
||||
std::env::set_current_dir(&*CWD).unwrap();
|
||||
|
||||
Reference in New Issue
Block a user