eryx-vfs
Virtual Filesystem for the Eryx Python sandbox.
This crate provides a custom wasi:filesystem implementation backed by pluggable storage backends, allowing sandboxed Python code to read and write files that persist across sandbox executions.
Architecture
The VFS consists of several key components:
VfsStorage- A trait for pluggable storage backendsInMemoryStorage- An in-memory implementation for testing and ephemeral useHybridVfsCtx- Combines real filesystem access with virtual storageScrubbingStorage- A wrapper that scrubs secret placeholders from writes
Usage
Basic In-Memory VFS
use ;
use Arc;
// Create storage
let storage = new;
// Create VFS context
let vfs_ctx = new;
// Add to wasmtime linker (after adding wasmtime-wasi)
add_to_linker_async?;
add_vfs_to_linker?;
Hybrid Filesystem
The hybrid VFS allows combining real filesystem access with virtual storage:
use ;
let hybrid_ctx = new
.with_preopen;
Secret Scrubbing
The ScrubbingStorage wrapper can automatically scrub secret placeholders from file writes, preventing accidental leakage of sensitive data:
use ;
use HashMap;
let storage = new;
let mut secrets = new;
secrets.insert;
let scrubbing_storage = new;
Scrubbing Policies
VfsFileScrubPolicy::All- Scrub all files (default)VfsFileScrubPolicy::None- Disable scrubbingVfsFileScrubPolicy::Except(paths)- Scrub all except specified paths (future)VfsFileScrubPolicy::Only(paths)- Only scrub specified paths (future)
Testing