From 12837049babed98df543000e395618a7eb8b112d Mon Sep 17 00:00:00 2001 From: Amine Alami <43780877+Alami-Amine@users.noreply.github.com> Date: Thu, 5 Sep 2024 20:43:16 +0200 Subject: [PATCH] [Fuzzing] Adding all-clusters-app fuzz test to OSS-Fuzz (#35408) * Added a base38 rountrip Fuzzer to fuzz the encoding and decoding in base38 Added a base38 decoder Fuzzer to fuzz the function decoding base38 strings Added a dependancy in TLV-Reader config to correct the build error * adding all clusters * Restyled by gn * Moving this back * Restyled by gn * Update src/setup_payload/tests/FuzzBase38.cpp Co-authored-by: Boris Zbarsky * Update src/setup_payload/tests/FuzzBase38.cpp Co-authored-by: Boris Zbarsky * Update src/setup_payload/tests/FuzzBase38.cpp Co-authored-by: Boris Zbarsky * Removing this * Updating * Update src/setup_payload/tests/FuzzBase38Decode.cpp Co-authored-by: Boris Zbarsky * restrict activation of enable_fuzz_test_targets --------- Co-authored-by: Justin Wood Co-authored-by: Restyled.io Co-authored-by: Boris Zbarsky --- BUILD.gn | 1 + build/chip/fuzz_test.gni | 7 +++++-- examples/all-clusters-app/linux/BUILD.gn | 11 +++++++++++ 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/BUILD.gn b/BUILD.gn index 4efa25007aa523..9a0654a5dfc0aa 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -52,6 +52,7 @@ if (current_toolchain != "${dir_pw_toolchain}/default:default") { if (enable_fuzz_test_targets) { group("fuzz_tests") { deps = [ + "${chip_root}/examples/all-clusters-app/linux:fuzz-chip-all-clusters-app", "${chip_root}/src/credentials/tests:fuzz-chip-cert", "${chip_root}/src/lib/core/tests:fuzz-tlv-reader", "${chip_root}/src/lib/dnssd/minimal_mdns/tests:fuzz-minmdns-packet-parsing", diff --git a/build/chip/fuzz_test.gni b/build/chip/fuzz_test.gni index 98def1dab0463d..b48c3182b1b724 100644 --- a/build/chip/fuzz_test.gni +++ b/build/chip/fuzz_test.gni @@ -21,9 +21,12 @@ import("${chip_root}/build/chip/tests.gni") import("${dir_pw_unit_test}/test.gni") declare_args() { - enable_fuzz_test_targets = is_clang && chip_build_tests && - (current_os == "linux" || current_os == "mac") + #Fuzz testing using libfuzzer + enable_fuzz_test_targets = + (is_libfuzzer || oss_fuzz) && is_clang && chip_build_tests && + (current_os == "linux" || current_os == "mac") + #Fuzz testing using pw_fuzzer and FuzzTest Framework pw_enable_fuzz_test_targets = false } diff --git a/examples/all-clusters-app/linux/BUILD.gn b/examples/all-clusters-app/linux/BUILD.gn index 5c61b4db461942..0e16c64c41de13 100644 --- a/examples/all-clusters-app/linux/BUILD.gn +++ b/examples/all-clusters-app/linux/BUILD.gn @@ -19,6 +19,7 @@ import("${build_root}/config/compiler/compiler.gni") import("${chip_root}/src/lib/lib.gni") import("${chip_root}/src/platform/device.gni") +import("${chip_root}/build/chip/fuzz_test.gni") import("${chip_root}/examples/common/pigweed/pigweed_rpcs.gni") if (chip_enable_pw_rpc) { @@ -201,3 +202,13 @@ group("linux") { group("default") { deps = [ ":linux" ] } + +if (enable_fuzz_test_targets) { + chip_fuzz_target("fuzz-chip-all-clusters-app") { + sources = [ "fuzzing-main.cpp" ] + public_deps = [ + ":chip-all-clusters-common", + "${chip_root}/examples/platform/linux:app-main", + ] + } +}