From 0d9a8f106748d1c8c2ee38f0d6e6e34a151ab08c Mon Sep 17 00:00:00 2001 From: arvidn Date: Mon, 21 Nov 2022 15:54:00 +0100 Subject: [PATCH] fuzzers --- .github/workflows/build-test.yml | 4 ++ chia-protocol/fuzz/Cargo.toml | 49 +++++++++++++++++++ .../fuzz/fuzz_targets/parse-foliage.rs | 9 ++++ .../fuzz/fuzz_targets/parse-full-block.rs | 9 ++++ .../fuzz/fuzz_targets/parse-header-block.rs | 9 ++++ .../fuzz/fuzz_targets/parse-program.rs | 9 ++++ .../fuzz/fuzz_targets/parse-tx-info.rs | 9 ++++ 7 files changed, 98 insertions(+) create mode 100644 chia-protocol/fuzz/Cargo.toml create mode 100644 chia-protocol/fuzz/fuzz_targets/parse-foliage.rs create mode 100644 chia-protocol/fuzz/fuzz_targets/parse-full-block.rs create mode 100644 chia-protocol/fuzz/fuzz_targets/parse-header-block.rs create mode 100644 chia-protocol/fuzz/fuzz_targets/parse-program.rs create mode 100644 chia-protocol/fuzz/fuzz_targets/parse-tx-info.rs diff --git a/.github/workflows/build-test.yml b/.github/workflows/build-test.yml index f6eeca212..043d9aaf5 100644 --- a/.github/workflows/build-test.yml +++ b/.github/workflows/build-test.yml @@ -317,6 +317,10 @@ jobs: run: | cd clvm-utils cargo +nightly fuzz build + - name: cargo fuzz (chia-protocol) + run: | + cd chia-protocol + cargo +nightly fuzz build unit_tests: runs-on: ${{ matrix.os }} diff --git a/chia-protocol/fuzz/Cargo.toml b/chia-protocol/fuzz/Cargo.toml new file mode 100644 index 000000000..a7c487968 --- /dev/null +++ b/chia-protocol/fuzz/Cargo.toml @@ -0,0 +1,49 @@ +[package] +name = "chia-protocol-fuzz" +version = "0.0.0" +authors = ["Automatically generated"] +publish = false +edition = "2021" + +[package.metadata] +cargo-fuzz = true + +[dependencies] +libfuzzer-sys = "0.4" + +[dependencies.chia-protocol] +path = ".." + +# Prevent this from interfering with workspaces +[workspace] +members = ["."] + +[[bin]] +name = "parse-full-block" +path = "fuzz_targets/parse-full-block.rs" +test = false +doc = false + +[[bin]] +name = "parse-header-block" +path = "fuzz_targets/parse-header-block.rs" +test = false +doc = false + +[[bin]] +name = "parse-foliage" +path = "fuzz_targets/parse-foliage.rs" +test = false +doc = false + +[[bin]] +name = "parse-tx-info" +path = "fuzz_targets/parse-tx-info.rs" +test = false +doc = false + +[[bin]] +name = "parse-program" +path = "fuzz_targets/parse-program.rs" +test = false +doc = false diff --git a/chia-protocol/fuzz/fuzz_targets/parse-foliage.rs b/chia-protocol/fuzz/fuzz_targets/parse-foliage.rs new file mode 100644 index 000000000..4f3622b54 --- /dev/null +++ b/chia-protocol/fuzz/fuzz_targets/parse-foliage.rs @@ -0,0 +1,9 @@ +#![no_main] +use libfuzzer_sys::fuzz_target; +use std::io::Cursor; +use chia_protocol::Foliage; +use chia_protocol::Streamable; + +fuzz_target!(|data: &[u8]| { + let _ret = ::parse(&mut Cursor::<&[u8]>::new(data)); +}); diff --git a/chia-protocol/fuzz/fuzz_targets/parse-full-block.rs b/chia-protocol/fuzz/fuzz_targets/parse-full-block.rs new file mode 100644 index 000000000..dc555446a --- /dev/null +++ b/chia-protocol/fuzz/fuzz_targets/parse-full-block.rs @@ -0,0 +1,9 @@ +#![no_main] +use libfuzzer_sys::fuzz_target; +use std::io::Cursor; +use chia_protocol::FullBlock; +use chia_protocol::Streamable; + +fuzz_target!(|data: &[u8]| { + let _ret = ::parse(&mut Cursor::<&[u8]>::new(data)); +}); diff --git a/chia-protocol/fuzz/fuzz_targets/parse-header-block.rs b/chia-protocol/fuzz/fuzz_targets/parse-header-block.rs new file mode 100644 index 000000000..5b1f29a38 --- /dev/null +++ b/chia-protocol/fuzz/fuzz_targets/parse-header-block.rs @@ -0,0 +1,9 @@ +#![no_main] +use libfuzzer_sys::fuzz_target; +use std::io::Cursor; +use chia_protocol::HeaderBlock; +use chia_protocol::Streamable; + +fuzz_target!(|data: &[u8]| { + let _ret = ::parse(&mut Cursor::<&[u8]>::new(data)); +}); diff --git a/chia-protocol/fuzz/fuzz_targets/parse-program.rs b/chia-protocol/fuzz/fuzz_targets/parse-program.rs new file mode 100644 index 000000000..b0822c53b --- /dev/null +++ b/chia-protocol/fuzz/fuzz_targets/parse-program.rs @@ -0,0 +1,9 @@ +#![no_main] +use libfuzzer_sys::fuzz_target; +use std::io::Cursor; +use chia_protocol::Program; +use chia_protocol::Streamable; + +fuzz_target!(|data: &[u8]| { + let _ret = ::parse(&mut Cursor::<&[u8]>::new(data)); +}); diff --git a/chia-protocol/fuzz/fuzz_targets/parse-tx-info.rs b/chia-protocol/fuzz/fuzz_targets/parse-tx-info.rs new file mode 100644 index 000000000..4ca20fd82 --- /dev/null +++ b/chia-protocol/fuzz/fuzz_targets/parse-tx-info.rs @@ -0,0 +1,9 @@ +#![no_main] +use libfuzzer_sys::fuzz_target; +use std::io::Cursor; +use chia_protocol::TransactionsInfo; +use chia_protocol::Streamable; + +fuzz_target!(|data: &[u8]| { + let _ret = ::parse(&mut Cursor::<&[u8]>::new(data)); +});