Skip to content

Commit

Permalink
x
Browse files Browse the repository at this point in the history
  • Loading branch information
ctiller committed Jan 27, 2025
1 parent b4e9cc5 commit 07cb67b
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 15 deletions.
43 changes: 37 additions & 6 deletions test/core/end2end/fuzzers/connector_fuzzer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,12 @@
// See the License for the specific language governing permissions and
// limitations under the License.

#include <google/protobuf/text_format.h>

#include <memory>

#include "fuzztest/fuzztest.h"
#include "gtest/gtest.h"
#include "src/core/ext/transport/chttp2/client/chttp2_connector.h"
#include "src/core/lib/address_utils/parse_address.h"
#include "src/core/lib/event_engine/channel_args_endpoint_config.h"
Expand All @@ -30,9 +33,6 @@
#include "test/core/test_util/fuzz_config_vars.h"
#include "test/core/test_util/test_config.h"

bool squelch = true;
bool leak_check = true;

using ::grpc_event_engine::experimental::ChannelArgsEndpointConfig;
using ::grpc_event_engine::experimental::EventEngine;
using ::grpc_event_engine::experimental::FuzzingEventEngine;
Expand All @@ -54,6 +54,7 @@ class ConnectorFuzzer {
FuzzingEventEngine::Options(), msg.event_engine_actions())),
mock_endpoint_controller_(MockEndpointController::Create(engine_)),
connector_(make_connector()) {
LOG(INFO) << msg.ShortDebugString();
CHECK(engine_);
grpc_event_engine::experimental::SetDefaultEventEngine(engine_);
for (const auto& input : msg.network_input()) {
Expand Down Expand Up @@ -171,9 +172,6 @@ void RunConnectorFuzzer(
absl::FunctionRef<RefCountedPtr<grpc_channel_security_connector>()>
make_security_connector,
absl::FunctionRef<OrphanablePtr<SubchannelConnector>()> make_connector) {
if (squelch && !GetEnv("GRPC_TRACE_FUZZER").has_value()) {
grpc_disable_all_absl_logs();
}
static const int once = []() {
ForceEnableExperiment("event_engine_client", true);
ForceEnableExperiment("event_engine_listener", true);
Expand All @@ -185,6 +183,12 @@ void RunConnectorFuzzer(
ConnectorFuzzer(msg, make_security_connector, make_connector).Run();
}

auto ParseTestProto(const std::string& proto) {
fuzzer_input::Msg msg;
CHECK(google::protobuf::TextFormat::ParseFromString(proto, &msg));
return msg;
}

void Chttp2(fuzzer_input::Msg msg) {
RunConnectorFuzzer(
msg, []() { return RefCountedPtr<grpc_channel_security_connector>(); },
Expand All @@ -205,5 +209,32 @@ void Chttp2Fakesec(fuzzer_input::Msg msg) {
}
FUZZ_TEST(ConnectorFuzzers, Chttp2Fakesec);

TEST(ConnectorFuzzers, Chttp2FakesecTimeout1) {
Chttp2Fakesec(ParseTestProto(R"pb(network_input {
input_segments {
segments { delay_ms: 1 }
segments {
delay_ms: 1
chaotic_good {
known_type: SETTINGS
payload_empty_of_length: 2147483647
}
}
}
connect_delay_ms: -1603816748
connect_timeout_ms: 3
}
event_engine_actions {
run_delay: 1
assign_ports: 1
assign_ports: 2147483647
connections {}
}
config_vars {
verbosity: ""
experiments: 9223372036854775807
})pb"));
}

} // namespace
} // namespace grpc_core
7 changes: 4 additions & 3 deletions test/core/end2end/fuzzers/network_input.cc
Original file line number Diff line number Diff line change
Expand Up @@ -251,9 +251,10 @@ SliceBuffer ChaoticGoodFrame(const fuzzer_input::ChaoticGoodFrame& frame) {
suffix.Append(Slice::FromCopiedString(frame.payload_raw_bytes()));
break;
case fuzzer_input::ChaoticGoodFrame::kPayloadEmptyOfLength:
h.payload_length = frame.payload_empty_of_length();
suffix.Append(Slice::FromCopiedString(
std::string(frame.payload_empty_of_length(), 'a')));
h.payload_length =
std::min<uint32_t>(65536, frame.payload_empty_of_length());
suffix.Append(
Slice::FromCopiedString(std::string(h.payload_length, 'a')));
break;
case fuzzer_input::ChaoticGoodFrame::kPayloadOtherConnectionId:
h.payload_connection_id =
Expand Down
6 changes: 0 additions & 6 deletions test/core/end2end/fuzzers/server_fuzzer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,6 @@
#include "test/core/test_util/fuzz_config_vars.h"
#include "test/core/test_util/test_config.h"

bool squelch = true;
bool leak_check = true;

namespace grpc_core {
namespace testing {

Expand Down Expand Up @@ -97,9 +94,6 @@ void RunServerFuzzer(
const fuzzer_input::Msg& msg,
absl::FunctionRef<void(grpc_server*, int, const ChannelArgs&)>
server_setup) {
if (squelch && !GetEnv("GRPC_TRACE_FUZZER").has_value()) {
grpc_disable_all_absl_logs();
}
static const int once = []() {
ForceEnableExperiment("event_engine_client", true);
ForceEnableExperiment("event_engine_listener", true);
Expand Down

0 comments on commit 07cb67b

Please sign in to comment.