-
-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathwasmer.rs
74 lines (64 loc) · 2.01 KB
/
wasmer.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
/***********************************************
WASMER:
- https://github.com/wasmerio/wasmer
************************************************/
/// Fuzzing `wasmer::validate`
pub fn fuzz_wasmer_validate(data: &[u8]) -> bool {
/*
extern crate wasmer_runtime;
wasmer_runtime::validate(&data)
*/
true
}
/// Fuzzing wasmer::compile with Cranelift compiler backend
pub fn fuzz_wasmer_compile_clif(data: &[u8]) -> bool {
/*
use wasmer_runtime::compile;
compile(&data).is_ok()
*/
true
}
/// Fuzzing `wasmer::compile` with `SinglePass` compiler backend
pub fn fuzz_wasmer_compile_singlepass(data: &[u8]) -> bool {
/*
use wasmer_runtime::compile_with;
use wasmer_singlepass_backend::SinglePassCompiler;
compile_with(&data, &SinglePassCompiler::new()).is_ok()
*/
true
}
/// Fuzzing `wasmer::instantiate` with empty import_object
pub fn fuzz_wasmer_instantiate(data: &[u8]) -> bool {
/*
use wasmer_runtime::{imports, instantiate};
let import_object = imports! {};
*/
// allow_missing_functions should prevent wasmer to reject
// modules with imported functions but generate more false positive bugs
// import_object.allow_missing_functions = true;
/*
instantiate(&data, &import_object).is_ok()
*/
// TODO(RM3): improve or create new fuzz harness that iterate
// over module functions and call them all
true
}
/*
// TODO: LLVMCompiler not available throw crates.io
pub fn TODO_fuzz_wasmer_compile_llvm(data: &[u8]) {
extern crate wasmer_runtime;
use std::str::FromStr;
use wasmer_runtime::{compiler_for_backend, compile_with, Backend};
// LLVM backend
let backend = match Backend::from_str("llvm"){
Ok(backend) => backend,
_ => return,
};
let compiler = match compiler_for_backend(backend) {
Some(compiler) => compiler,
_ => return,
};
let _res = compile_with(&data, compiler.as_ref());
}
// TODO(RM3) - wasmer_runtime::validate_and_report_errors_with_features
*/