Back to Monty

monty-fs

crates/monty-fs/README.md

0.0.212.4 KB
Original Source

monty-fs

Host-side filesystem mounts for Monty, the sandboxed Python interpreter.

Provides MountTable, which maps virtual POSIX paths inside the sandbox (e.g. /mnt/data) to real host directories with configurable access modes (read-write, read-only, or in-memory overlay).

The monty interpreter crate never performs filesystem I/O itself — sandboxed code suspends with an OsFunctionCall describing the requested operation, and a host holding a MountTable services it via MountTable::handle_os_call. Keeping that I/O in a separate crate means the interpreter (and worker artifacts built from it, such as the wasm worker) contain no host-filesystem code at all.

All path resolution goes through a single security boundary (path_security::resolve_path) enforcing canonicalization, mount-boundary checks, and symlink escape detection: the sandbox can never read, write, or learn anything about files outside the mounted directories.

Each mount has a configurable aggregate memory budget that defaults to 100 MB. Retained in-memory overlay data and transient filesystem results share that budget; oversized operations return MemoryError before an unbounded read.

Monty crates

  • monty — the core interpreter: Python parser, bytecode VM, and sandbox.
  • monty-types — the shared boundary data types (values, exceptions, OS calls, resource limits) hosts use without linking the interpreter.
  • monty-fs — host-side filesystem mounts: maps virtual sandbox paths to real host directories. this crate
  • monty-runtime — the monty binary: REPL, file runner, and subprocess worker mode.
  • monty-pool — an elastic pool of crash-isolated monty worker subprocesses.
  • monty-proto — the protobuf wire protocol spoken between pool parents and workers.
  • monty-type-checking — type checking of sandboxed code, powered by ty.
  • monty-typeshed — the trimmed typeshed stubs describing the stdlib subset Monty implements.
  • monty-macros — the proc macros behind monty's argument parsing.