diff --git a/flake.nix b/flake.nix index d002e47..cab25d2 100644 --- a/flake.nix +++ b/flake.nix @@ -44,5 +44,13 @@ export NIL_PATH="$(cargo metadata --format-version=1 | jq -r .target_directory)/release/nil" ''; }; + + devShells.fuzz = pkgs.mkShell { + packages = [ + rustPkgs.rust-nightly_2022-08-01 + pkgs.cargo-fuzz + ]; + RUST_BACKTRACE = 1; + }; }); } diff --git a/syntax/fuzz/.gitignore b/syntax/fuzz/.gitignore new file mode 100644 index 0000000..b9659e6 --- /dev/null +++ b/syntax/fuzz/.gitignore @@ -0,0 +1,4 @@ +target +corpus +artifacts +Cargo.lock diff --git a/syntax/fuzz/Cargo.toml b/syntax/fuzz/Cargo.toml new file mode 100644 index 0000000..56def88 --- /dev/null +++ b/syntax/fuzz/Cargo.toml @@ -0,0 +1,25 @@ +[package] +name = "syntax-fuzz" +version = "0.0.0" +authors = ["Automatically generated"] +publish = false +edition = "2018" + +[package.metadata] +cargo-fuzz = true + +[dependencies] +libfuzzer-sys = "0.4" + +[dependencies.syntax] +path = ".." + +# Prevent this from interfering with workspaces +[workspace] +members = ["."] + +[[bin]] +name = "parser" +path = "fuzz_targets/parser.rs" +test = false +doc = false diff --git a/syntax/fuzz/fuzz_targets/parser.rs b/syntax/fuzz/fuzz_targets/parser.rs new file mode 100644 index 0000000..f3f24dc --- /dev/null +++ b/syntax/fuzz/fuzz_targets/parser.rs @@ -0,0 +1,6 @@ +#![no_main] +use libfuzzer_sys::fuzz_target; + +fuzz_target!(|text: &str| { + syntax::parse_file(text); +});