Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
bshastry committed Nov 15, 2023
1 parent 79d1b68 commit a8e1e57
Show file tree
Hide file tree
Showing 3 changed files with 85 additions and 0 deletions.
39 changes: 39 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 18 additions & 0 deletions crates/fuzzers/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
[package]
authors = ["The Fe Developers <snakecharmers@ethereum.org>"]
edition = "2021"
name = "fe-fuzzers"
version = "0.26.0"
license = "GPL-3.0-or-later"
repository = "https://github.com/ethereum/fe"

[dependencies]
fe-common = {path = "../common", version = "^0.26.0"}
fe-driver = {path = "../driver", version = "^0.26.0"}
libfuzzer-sys = "0.4"

dir-test = "^0.1"

[lib]
name = "single_file_fuzzer"
path = "src/single_file_fuzzer.rs"
28 changes: 28 additions & 0 deletions crates/fuzzers/src/single_file_fuzzer.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#![no_main]

use libfuzzer_sys::fuzz_target;
use fe_common::diagnostics::print_diagnostics;

fuzz_target!(|data: &[u8]| {
// Convert the fuzzing engine input to a string
let input = String::from_utf8_lossy(data);

// Create a mutable database
let mut db = fe_driver::Db::default();

// Call the `compile_single_file` API with the input
let _ = match fe_driver::compile_single_file(
&mut db,
"dummy",
&input,
/*with_bytecode=*/ true,
/*with_runtime_bytecode=*/ true,
/*optimize=*/ true,
) {
Ok(_) => (),
Err(error) => {
eprintln!("Unable to compile input.");
print_diagnostics(&db, &error.0);
}
};
});

0 comments on commit a8e1e57

Please sign in to comment.