-
Notifications
You must be signed in to change notification settings - Fork 4.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding an HTTP/2 integration fuzzer (#10321)
Adding an HTTP/2 integration fuzzer that checks different kind of frames handling in both Downstream and Upstream Risk Level: Low - a new test Testing: It is a new fuzz test Signed-off-by: Adi Suissa-Peleg <[email protected]>
- Loading branch information
Showing
9 changed files
with
707 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
#include "envoy/extensions/filters/network/http_connection_manager/v3/http_connection_manager.pb.h" | ||
|
||
#include "test/integration/h2_fuzz.h" | ||
|
||
namespace Envoy { | ||
|
||
void H2FuzzIntegrationTest::initialize() { | ||
const std::string body = "Response body"; | ||
const std::string file_path = TestEnvironment::writeStringToFileForTest("test_envoy", body); | ||
const std::string prefix("/"); | ||
const Http::Code status(Http::Code::OK); | ||
|
||
setDownstreamProtocol(Http::CodecClient::Type::HTTP2); | ||
setUpstreamProtocol(FakeHttpConnection::Type::HTTP2); | ||
|
||
config_helper_.addConfigModifier( | ||
[&file_path, &prefix]( | ||
envoy::extensions::filters::network::http_connection_manager::v3::HttpConnectionManager& | ||
hcm) -> void { | ||
auto* route_config = hcm.mutable_route_config(); | ||
// adding direct response mode to the default route | ||
auto* default_route = | ||
hcm.mutable_route_config()->mutable_virtual_hosts(0)->mutable_routes(0); | ||
default_route->mutable_match()->set_prefix(prefix); | ||
default_route->mutable_direct_response()->set_status(static_cast<uint32_t>(status)); | ||
default_route->mutable_direct_response()->mutable_body()->set_filename(file_path); | ||
// adding headers to the default route | ||
auto* header_value_option = route_config->mutable_response_headers_to_add()->Add(); | ||
header_value_option->mutable_header()->set_value("direct-response-enabled"); | ||
header_value_option->mutable_header()->set_key("x-direct-response-header"); | ||
}); | ||
HttpIntegrationTest::initialize(); | ||
} | ||
|
||
DEFINE_PROTO_FUZZER(const test::integration::H2CaptureFuzzTestCase& input) { | ||
RELEASE_ASSERT(!TestEnvironment::getIpVersionsForTest().empty(), ""); | ||
const auto ip_version = TestEnvironment::getIpVersionsForTest()[0]; | ||
PERSISTENT_FUZZ_VAR H2FuzzIntegrationTest h2_fuzz_integration_test(ip_version); | ||
h2_fuzz_integration_test.replay(input, true); | ||
} | ||
|
||
} // namespace Envoy |
Oops, something went wrong.