Expand description
A WebAssembly test case generator.
§Usage
First, use cargo fuzz to define
a new fuzz target:
$ cargo fuzz add my_wasm_smith_fuzz_targetNext, add wasm-smith to your dependencies:
$ cargo add wasm-smithThen, define your fuzz target so that it takes arbitrary
wasm_smith::Modules as an argument, convert the module into serialized
Wasm bytes via the to_bytes method, and then feed it into your system:
// fuzz/fuzz_targets/my_wasm_smith_fuzz_target.rs
#![no_main]
use libfuzzer_sys::fuzz_target;
use wasm_smith::Module;
fuzz_target!(|module: Module| {
let wasm_bytes = module.to_bytes();
// Your code here...
});Finally, start fuzzing:
$ cargo fuzz run my_wasm_smith_fuzz_targetNote: For a real world example, also check out the
validatefuzz target defined in this repository. Using thewasmparsercrate, it checks that every module generated bywasm-smithvalidates successfully.
§Design
The design and implementation strategy of wasm-smith is outlined in this article.
Structs§
- Component
component-model - A pseudo-random WebAssembly component.
- Config
- Configuration for a generated module.
- Instruction
Kinds - A container for the kinds of instructions that wasm-smith is allowed to emit.
- Memory
Offset Choices - This is a tuple
(a, b, c)where - Module
- A pseudo-random WebAssembly module.
Enums§
- Instruction
Kind - Enumerate the categories of instructions defined in the WebAssembly specification.