Skip to content

Commit

Permalink
fuzz: Adding lazy map threshold conf to headermap fuzzer (envoyproxy#…
Browse files Browse the repository at this point in the history
…13402)

Adding lazy map threshold config to headermap fuzzer
Signed-off-by: Adi Suissa-Peleg <[email protected]>
  • Loading branch information
adisuissa authored Oct 8, 2020
1 parent 5d12b67 commit 850a0f2
Show file tree
Hide file tree
Showing 4 changed files with 252 additions and 0 deletions.
1 change: 1 addition & 0 deletions test/common/http/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,7 @@ envoy_cc_fuzz_test(
":header_map_impl_fuzz_proto_cc_proto",
"//source/common/http:header_map_lib",
"//test/fuzz:utility_lib",
"//test/test_common:test_runtime_lib",
],
)

Expand Down
236 changes: 236 additions & 0 deletions test/common/http/header_map_impl_corpus/example_lazymap

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

6 changes: 6 additions & 0 deletions test/common/http/header_map_impl_fuzz.proto
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,12 @@ message Action {
}
}

message Config {
uint32 lazy_map_min_size = 1;
}

message HeaderMapImplFuzzTestCase {
repeated Action actions = 1;
// Optional threshold value configuration for the lazy header-map.
Config config = 2;
}
9 changes: 9 additions & 0 deletions test/common/http/header_map_impl_fuzz_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include "test/common/http/header_map_impl_fuzz.pb.h"
#include "test/fuzz/fuzz_runner.h"
#include "test/fuzz/utility.h"
#include "test/test_common/test_runtime.h"

#include "absl/strings/ascii.h"

Expand All @@ -16,6 +17,14 @@ namespace Envoy {

// Fuzz the header map implementation.
DEFINE_PROTO_FUZZER(const test::common::http::HeaderMapImplFuzzTestCase& input) {
TestScopedRuntime runtime;
// Set the lazy header-map threshold if found.
if (input.has_config()) {
Runtime::LoaderSingleton::getExisting()->mergeValues(
{{"envoy.http.headermap.lazy_map_min_size",
absl::StrCat(input.config().lazy_map_min_size())}});
}

auto header_map = Http::RequestHeaderMapImpl::create();
std::vector<std::unique_ptr<Http::LowerCaseString>> lower_case_strings;
std::vector<std::unique_ptr<std::string>> strings;
Expand Down

0 comments on commit 850a0f2

Please sign in to comment.