[fuzzing] Allow hpack fuzzers to supply config (#33242)

<!--

If you know who should review your pull request, please assign it to
that
person, otherwise the pull request would get assigned randomly.

If your pull request is for a specific language, please add the
appropriate
lang label.

-->

---------

Co-authored-by: ctiller <ctiller@users.noreply.github.com>
pull/33610/head
Craig Tiller 2 years ago committed by GitHub
parent 5b880e3342
commit 43f67d3640
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 4
      test/core/transport/chttp2/BUILD
  2. 4
      test/core/transport/chttp2/hpack_parser_fuzzer.proto
  3. 4
      test/core/transport/chttp2/hpack_parser_fuzzer_test.cc
  4. 4
      test/core/transport/chttp2/hpack_sync_fuzzer.cc
  5. 3
      test/core/transport/chttp2/hpack_sync_fuzzer.proto

@ -25,10 +25,12 @@ grpc_proto_fuzzer(
srcs = ["hpack_parser_fuzzer_test.cc"],
corpus = "hpack_parser_corpus",
proto = "hpack_parser_fuzzer.proto",
proto_deps = ["//test/core/util:fuzz_config_vars_proto"],
tags = ["no_windows"],
uses_polling = False,
deps = [
"//:grpc",
"//test/core/util:fuzz_config_vars",
"//test/core/util:grpc_test_util",
],
)
@ -38,10 +40,12 @@ grpc_proto_fuzzer(
srcs = ["hpack_sync_fuzzer.cc"],
corpus = "hpack_sync_corpus",
proto = "hpack_sync_fuzzer.proto",
proto_deps = ["//test/core/util:fuzz_config_vars_proto"],
tags = ["no_windows"],
uses_polling = False,
deps = [
"//:grpc",
"//test/core/util:fuzz_config_vars",
"//test/core/util:grpc_test_util",
],
)

@ -16,6 +16,8 @@ syntax = "proto3";
package hpack_parser_fuzzer;
import "test/core/util/fuzz_config_vars.proto";
message Empty {}
message Frame {
@ -30,5 +32,5 @@ message Frame {
message Msg {
repeated Frame frames = 2;
grpc.testing.FuzzConfigVars config_vars = 3;
}

@ -30,6 +30,7 @@
#include <grpc/support/log.h>
#include "src/core/ext/transport/chttp2/transport/hpack_parser.h"
#include "src/core/lib/experiments/config.h"
#include "src/core/lib/gprpp/ref_counted_ptr.h"
#include "src/core/lib/gprpp/status_helper.h"
#include "src/core/lib/iomgr/error.h"
@ -40,6 +41,7 @@
#include "src/core/lib/transport/metadata_batch.h"
#include "src/libfuzzer/libfuzzer_macro.h"
#include "test/core/transport/chttp2/hpack_parser_fuzzer.pb.h"
#include "test/core/util/fuzz_config_vars.h"
// IWYU pragma: no_include <google/protobuf/repeated_ptr_field.h>
@ -50,6 +52,8 @@ static void dont_log(gpr_log_func_args* /*args*/) {}
DEFINE_PROTO_FUZZER(const hpack_parser_fuzzer::Msg& msg) {
if (squelch) gpr_set_log_function(dont_log);
grpc_core::ApplyFuzzConfigVars(msg.config_vars());
grpc_core::TestOnlyReloadExperimentsFromConfigVariables();
grpc_init();
auto cleanup = absl::MakeCleanup(grpc_shutdown);
auto memory_allocator = grpc_core::ResourceQuota::Default()

@ -33,6 +33,7 @@
#include "src/core/ext/transport/chttp2/transport/hpack_encoder_table.h"
#include "src/core/ext/transport/chttp2/transport/hpack_parser.h"
#include "src/core/ext/transport/chttp2/transport/hpack_parser_table.h"
#include "src/core/lib/experiments/config.h"
#include "src/core/lib/gprpp/ref_counted_ptr.h"
#include "src/core/lib/gprpp/status_helper.h"
#include "src/core/lib/iomgr/error.h"
@ -45,6 +46,7 @@
#include "src/core/lib/transport/metadata_batch.h"
#include "src/libfuzzer/libfuzzer_macro.h"
#include "test/core/transport/chttp2/hpack_sync_fuzzer.pb.h"
#include "test/core/util/fuzz_config_vars.h"
bool squelch = true;
bool leak_check = true;
@ -169,5 +171,7 @@ void FuzzOneInput(const hpack_sync_fuzzer::Msg& msg) {
DEFINE_PROTO_FUZZER(const hpack_sync_fuzzer::Msg& msg) {
if (squelch) gpr_set_log_function(dont_log);
grpc_core::ApplyFuzzConfigVars(msg.config_vars());
grpc_core::TestOnlyReloadExperimentsFromConfigVariables();
grpc_core::FuzzOneInput(msg);
}

@ -16,6 +16,8 @@ syntax = "proto3";
package hpack_sync_fuzzer;
import "test/core/util/fuzz_config_vars.proto";
message Empty {}
message StringKeyValue {
@ -40,4 +42,5 @@ message Header {
message Msg {
bool use_true_binary_metadata = 1;
repeated Header headers = 2;
grpc.testing.FuzzConfigVars config_vars = 3;
}

Loading…
Cancel
Save