A production-quality CLI tool for inspecting and validating WebAssembly modules using WasmEdge.
-
wasm inspect- Inspect WASM module structure- List imports (module, name, type)
- List exports
- Show memory and table definitions
- Display custom sections
-
wasm validate- Validate modules against WebAssembly spec- Detect invalid sections
- Report type mismatches
- Find broken indices
-
wasm wasi-check- Analyze WASI usage- Detect WASI imports
- List required WASI capabilities
- Flag unsafe or privileged syscalls
-
wasm stats- Show module statistics- Code and data segment sizes
- Memory limits
- Function counts
- CMake 3.15 or later
- C++17 compatible compiler (g++, clang++)
- WasmEdge library installed
# macOS with Homebrew
brew install wasmedge
# Or install from source
curl -sSf https://raw.githubusercontent.com/WasmEdge/WasmEdge/master/utils/install.sh | bashgit clone https://github.com/yourusername/wasm-inspector-cli.git
cd wasm-inspector-cli
mkdir build && cd build
cmake ..
cmake --build .sudo cmake --install .# Human-readable output
wasm inspect module.wasm
# JSON output
wasm inspect module.wasm --jsonExample output:
Module: module.wasm
Imports (2):
env.print_i32 (function: (i32) -> ())
env.memory (memory: min=1 pages)
Exports (2):
add (function: (i32, i32) -> (i32))
memory (memory: min=1 pages)
Memories (1):
[0] min=1 pages
Tables (0):
(none)
Custom Sections (0):
(none)
wasm validate module.wasmExample output:
✓ module.wasm is valid
Or for invalid modules:
✗ module.wasm is invalid
Errors:
[Type section] Type mismatch in function signature
wasm wasi-check module.wasmExample output:
WASI Usage: Yes
Required Capabilities:
file_descriptor:
- fd_read
- fd_write ⚠️ PRIVILEGED
filesystem:
- path_open ⚠️ PRIVILEGED
clock:
- clock_time_get
Privileged Syscalls:
⚠️ fd_write
⚠️ path_open
wasm stats module.wasmExample output:
Module Statistics: module.wasm
Total File Size: 45234 bytes
Functions: 127
Imports: 5
Defined: 122
Memory:
Min: 2 pages (128 KB)
Max: 16 pages (1024 KB)
Tables: 1
[0] min=50, max=200
All commands support --json flag for machine-readable output:
wasm inspect module.wasm --json{
"module": "module.wasm",
"imports": [
{
"module": "env",
"name": "print_i32",
"type": "function",
"details": "(i32) -> ()"
}
],
"exports": [
{
"name": "add",
"type": "function",
"details": "(i32, i32) -> (i32)"
}
],
"memories": [],
"tables": [],
"custom_sections": []
}wasm-inspector-cli/
├── include/wasm_inspector/
│ ├── cli/ # CLI command implementations
│ └── wasm/ # WASM parsing and analysis
├── src/
│ ├── cli/ # Command implementations
│ ├── wasm/ # Core WASM functionality
│ └── main.cpp # CLI entry point
├── tests/
│ └── fixtures/ # Test WASM modules
└── CMakeLists.txt
The test fixtures are provided as .wat (WebAssembly Text) files. To compile them to .wasm:
# Install WABT (WebAssembly Binary Toolkit)
brew install wabt
# Compile WAT files
cd tests/fixtures
wat2wasm simple.wat -o simple.wasm
wat2wasm with_wasi.wat -o with_wasi.wasm
wat2wasm memory_table.wat -o memory_table.wasmMIT License - see LICENSE file for details
Contributions are welcome! Please open an issue or submit a pull request.
- Built with WasmEdge
- CLI parsing with CLI11
- JSON output with nlohmann/json