Docs.rs
  • wasm-smith-0.232.0
    • wasm-smith 0.232.0
    • Permalink
    • Docs.rs crate page
    • Apache-2.0 WITH LLVM-exception OR Apache-2.0 OR MIT
    • Links
    • Repository
    • crates.io
    • Source
    • Owners
    • alexcrichton
    • fitzgen
    • github:bytecodealliance:wasmtime-publish
    • Dependencies
      • anyhow ^1.0.58 normal
      • arbitrary ^1.1.0 normal
      • clap ^4.0.0 normal optional
      • flagset ^0.4 normal
      • serde ^1.0.166 normal optional
      • serde_derive ^1.0.166 normal optional
      • wasm-encoder ^0.232.0 normal
      • wasmparser ^0.232.0 normal optional
      • wat ^1.232.0 normal optional
      • criterion ^0.5.1 dev
      • rand ^0.8.4 dev
      • wasmparser ^0.232.0 dev
      • wasmprinter ^0.232.0 dev
      • wat ^1.232.0 dev
      • libfuzzer-sys ^0.4.0 dev
    • Versions
    • 100% of the crate is documented
  • Platform
    • i686-pc-windows-msvc
    • i686-unknown-linux-gnu
    • x86_64-apple-darwin
    • x86_64-pc-windows-msvc
    • x86_64-unknown-linux-gnu
  • Feature flags
  • docs.rs
    • About docs.rs
    • Privacy policy
  • Rust
    • Rust website
    • The Book
    • Standard Library API Reference
    • Rust by Example
    • The Cargo Guide
    • Clippy Documentation

Crate wasm_smith

wasm_smith0.232.0

  • All Items

Sections

  • Usage
  • Design

Crate Items

  • Structs
  • Enums

Crates

  • wasm_smith

Crate wasm_smith

Source
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_target

Next, add wasm-smith to your dependencies:

$ cargo add wasm-smith

Then, 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_target

Note: For a real world example, also check out the validate fuzz target defined in this repository. Using the wasmparser crate, it checks that every module generated by wasm-smith validates successfully.

§Design

The design and implementation strategy of wasm-smith is outlined in this article.

Structs§

Componentcomponent-model
A pseudo-random WebAssembly component.
Config
Configuration for a generated module.
InstructionKinds
A container for the kinds of instructions that wasm-smith is allowed to emit.
MemoryOffsetChoices
This is a tuple (a, b, c) where
Module
A pseudo-random WebAssembly module.

Enums§

InstructionKind
Enumerate the categories of instructions defined in the WebAssembly specification.

Results

Settings
Help
No results :(
Try on DuckDuckGo?

Or try looking in one of these:
  • The Rust Reference for technical details about the language.
  • Rust By Example for expository code examples.
  • The Rust Book for introductions to language features and the language itself.
  • Docs.rs for documentation of crates released on crates.io.
No results :(
Try on DuckDuckGo?

Or try looking in one of these:
  • The Rust Reference for technical details about the language.
  • Rust By Example for expository code examples.
  • The Rust Book for introductions to language features and the language itself.
  • Docs.rs for documentation of crates released on crates.io.
No results :(
Try on DuckDuckGo?

Or try looking in one of these:
  • The Rust Reference for technical details about the language.
  • Rust By Example for expository code examples.
  • The Rust Book for introductions to language features and the language itself.
  • Docs.rs for documentation of crates released on crates.io.