Skip to content

Spyder01/Zephir

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

19 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

🧭 Zephir CLI

Status GitHub Issues GitHub Pull Requests License Hacktoberfest


βš™οΈ Overview

Zephir is a Rust-based CLI tool for packaging, unpacking, and invoking application directories inside a sandboxed environment. It supports Native binaries, WebAssembly (WASM), and Lua scripts, offering fine-grained resource control and secure isolated execution.

Ideal for serverless runtimes, sandboxed compute, or local function testing.


✨ Features

  • πŸ—οΈ Init β€” Generate a default configuration file.
  • πŸ“¦ Package β€” Package a directory into a .zephir artifact.
  • πŸ“‚ Unpack β€” Unpack packaged artifacts to a sandbox directory.
  • βš™οΈ Invoke β€” Run unpacked artifacts inside an isolated sandbox.
  • πŸš€ Run β€” Full pipeline: unpack β†’ sandbox β†’ invoke.
  • πŸ”’ Sandboxing β€” CPU, memory, and storage limits for safe execution.
  • 🧹 Graceful Shutdown β€” Cleans up sandbox directories automatically.
  • πŸͺ΅ Logging β€” Structured logs with prefix and debug support.
  • 🌐 WASM Support β€” Run WebAssembly modules using a WASI-compliant runtime.
  • πŸŒ€ Lua Support β€” Execute sandboxed Lua scripts securely.

βš™οΈ Installation

Ensure Rust (v1.86+) is installed.

git clone https://github.com/spyder01/zephir-rs.git
cd zephir-rs
cargo build --release

The compiled binary will be available at:

target/release/zephir-rs

🧩 Configuration

Zephir uses a YAML configuration file (default: zephir.yaml).

Example Configuration

name: zephir-function
function:
  app:
    entry: ./main.lua
  bundle:
    packagePath: function.zephir
    artifactType: LUA   # NATIVE | WASM | LUA
  resources:
    memory: 134217728   # 128 MB
    storage: 536870912  # 512 MB
    cpuLimit: 10        # 10 seconds
storage:
  sandbox: zephir-sandbox/
  cache: zephir-cache/
logConfig:
  toFile: false
  toStdout: true
  prefix: "[Zephir]"
  debugEnabled: false

Supported artifactType values:

  • NATIVE β€” Compiled executables
  • WASM β€” WebAssembly modules
  • LUA β€” Lua scripts

🧭 CLI Commands

πŸ”§ Initialize configuration

zephir-rs init --output ./zephir.yaml

πŸ“¦ Package a directory

zephir-rs package --dir ./my-function --output ./function.zephir

πŸ“‚ Unpack an artifact

zephir-rs unpack --config ./zephir.yaml

βš™οΈ Invoke an artifact

zephir-rs invoke --sandbox ./zephir-sandbox --config ./zephir.yaml --args arg1 arg2

πŸš€ Run (Full Pipeline)

zephir-rs run --config ./zephir.yaml

πŸͺ΅ Logging Configuration

Option Description
toFile Write logs to a file
filePath Path to log file (if enabled)
toStdout Print logs to stdout
prefix Log prefix label
debugEnabled Enables verbose logging

🧱 Sandboxing

Zephir isolates execution using strict sandboxing controls:

  • CPU limit: via fuel counters or process control
  • Memory cap: on WASM, Lua, and native executables
  • Storage quota: per sandbox directory
  • Automatic cleanup: on completion or interruption

🧬 Execution Modes

πŸ”Ή Native Execution

artifactType: NATIVE
entry: ./my_binary

Runs local executables with real-time stdout/stderr streaming and enforced resource limits.


πŸ”Ή WebAssembly Execution

artifactType: WASM
entry: ./module.wasm
  • Uses Wasmtime + WASI
  • Preopens /sandbox directory
  • Enforces CPU, memory, and file I/O limits
  • Supports graceful shutdowns

πŸ”Ή Lua Execution

artifactType: LUA
entry: ./main.lua

Runs sandboxed Lua scripts using mlua with restricted standard libraries.

Example

print("Hello from Lua!")
print("Sandbox path:", sandbox_path)

local f = io.open(sandbox_path .. "/output.txt", "w")
f:write("Lua execution complete.")
f:close()

🧠 Development

cargo run -- <COMMAND>
cargo test

Project Layout

src/
β”œβ”€ main.rs          # CLI entrypoint
β”œβ”€ engine/          # Core execution logic
β”œβ”€ models/          # Config & data structures
β”œβ”€ utils/           # FS, YAML, OS helpers
β”œβ”€ logger/          # Logging setup
└─ compress/        # Zstd compression/decompression

🧰 Requirements

  • πŸ¦€ Rust 1.86+
  • 🧠 Linux / macOS (Unix sandboxing features)
  • 🧩 (Optional) Wasmtime for WASM runtime

🎯 Roadmap

  • Add network namespace sandboxing
  • WASM async I/O and streaming support
  • Lua execution timeout controls
  • Hermyx integration for cached artifact serving
  • Add example templates for NATIVE / WASM / LUA projects

πŸŽƒ Hacktoberfest 2025 β€” Contribute & Learn!

We’re participating in Hacktoberfest 2025! If you’re a systems, Rust, or WASM enthusiast β€” this is the perfect time to contribute πŸš€

🧩 Good First Issues

Check them out here πŸ‘‰ Good First Issues

πŸ›  Ways to Contribute

  • πŸ¦€ Implement new sandboxing features
  • βš™οΈ Improve WASM or Lua execution engines
  • πŸ§ͺ Add unit/integration tests
  • 🧾 Improve documentation and examples
  • 🧰 Build utility commands (e.g., resource inspector)
  • 🌐 Add demo projects for all artifact types

🧠 How to Get Started

  1. Fork the repo

  2. Clone your fork

    git clone https://github.com/<your-username>/zephir-rs.git
  3. Create a branch

    git checkout -b feature/add-wasm-limits
  4. Build & test

    cargo run -- init
    cargo test
  5. Commit & push

    git commit -m "Add CPU limit enforcement for WASM"
    git push origin feature/add-wasm-limits
  6. Open a Pull Request πŸŽ‰


πŸ§‘β€πŸ’» Maintainer

@spyder01


πŸ“„ License

Licensed under the MIT License β€” see LICENSE for details.


🌟 Support the Project

If you like Zephir, give it a ⭐ on GitHub! It helps others discover the project and supports ongoing development.

About

Zephir is a Rust-based CLI tool for packaging, unpacking, and invoking application directories in a sandboxed environment. It supports both native binaries and WebAssembly (WASM) artifacts. Zephir provides sandboxing features like CPU time, memory, and storage limits, as well as graceful shutdown.

Topics

Resources

License

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages