Skip to main content

Module panic_paths

Module panic_paths 

Source
Expand description

Panic Path Detection Linter (PROBAR-WASM-006)

Static analysis to detect panic-inducing patterns in WASM code.

§Motivation

In WASM, panic paths cause wasm_bindgen::throw_str which terminates the entire WASM instance. Unlike native Rust where panics can be caught, WASM panics are unrecoverable and break the user experience.

§Detection Rules

Rule IDDescriptionSeverity
WASM-PANIC-001unwrap() callError
WASM-PANIC-002expect() callError
WASM-PANIC-003panic!() macroError
WASM-PANIC-004unreachable!() macroWarning
WASM-PANIC-005todo!() macroError
WASM-PANIC-006unimplemented!() macroError
WASM-PANIC-007Index access without bounds checkWarning

§Example

// BAD: Will panic in WASM
let value = some_option.unwrap();

// GOOD: Proper error handling
let value = some_option.ok_or(MyError::Missing)?;

Structs§

PanicPathSummary
Summary of panic path analysis
PanicPathVisitor
AST visitor for detecting panic paths

Functions§

lint_panic_paths
Lint source code for panic paths