Skip to content

Commit f8d2fad

Browse files
Add FuzzTest set up and OSS-Fuzz integration
Adds a fuzzer using the FuzzTest framework. https://github.com/google/fuzztest The fuzzer is a migration of 8294639 to the fuzztest set up. This is also an effort to follow up on a recent OSS-Fuzz integration https://github.com/google/oss-fuzz/tree/master/projects/quiche Signed-off-by: David Korczynski <[email protected]>
1 parent 661e3c8 commit f8d2fad

File tree

3 files changed

+42
-0
lines changed

3 files changed

+42
-0
lines changed

WORKSPACE.bazel

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,13 @@ http_archive(
7474
urls = ["https://github.com/google/re2/archive/03da4fc0857c285e3a26782f6bc8931c4c950df4.zip"],
7575
)
7676

77+
http_archive(
78+
name = "com_google_fuzztest",
79+
sha256 = "c75f224b34c3c62ee901381fb743f6326f7b91caae0ceb8fe62f3fd36f187627",
80+
strip_prefix = "fuzztest-58b4e7065924f1a284952b84ea827ce35a87e4dc",
81+
urls = ["https://github.com/google/fuzztest/archive/58b4e7065924f1a284952b84ea827ce35a87e4dc.zip"],
82+
)
83+
7784
# -------- Load and call dependencies of underlying libraries --------
7885

7986
load("@bazel_skylib//:workspace.bzl", "bazel_skylib_workspace")

quiche/BUILD.bazel

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -322,6 +322,31 @@ cc_library(
322322
],
323323
)
324324

325+
cc_test(
326+
name = "http_frame_fuzzer",
327+
srcs = ["http2/decoder/http2_frame_decoder_test.cc"],
328+
deps = [
329+
":binary_http",
330+
":quiche_core",
331+
":quiche_platform_default_testonly",
332+
":quiche_protobufs_testonly_cc_proto",
333+
":quiche_tool_support",
334+
":quiche_test_support",
335+
"@boringssl//:crypto",
336+
"@boringssl//:ssl",
337+
"@com_google_absl//absl/base:core_headers",
338+
"@com_google_absl//absl/container:flat_hash_map",
339+
"@com_google_absl//absl/container:flat_hash_set",
340+
"@com_google_absl//absl/memory",
341+
"@com_google_absl//absl/strings",
342+
"@com_google_absl//absl/strings:str_format",
343+
"@com_google_absl//absl/types:optional",
344+
"@com_google_fuzztest//fuzztest",
345+
"@com_google_fuzztest//fuzztest:fuzztest_gtest_main",
346+
"@com_google_googleurl//url",
347+
],
348+
)
349+
325350
test_suite_from_source_list(
326351
name = "quiche_tests",
327352
srcs = quiche_tests_srcs,

quiche/http2/decoder/http2_frame_decoder_test.cc

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
#include "quiche/http2/test_tools/verify_macros.h"
1919
#include "quiche/common/platform/api/quiche_logging.h"
2020

21+
#include "fuzztest/fuzztest.h"
22+
2123
using ::testing::AssertionSuccess;
2224

2325
namespace http2 {
@@ -914,6 +916,14 @@ TEST_F(Http2FrameDecoderTest, WindowUpdateTooLong) {
914916
EXPECT_TRUE(DecodePayloadExpectingFrameSizeError(kFrameData, header));
915917
}
916918

919+
void FuzzFrameDecoder(const std::string &s) {
920+
http2::Http2FrameDecoderNoOpListener listener;
921+
http2::Http2FrameDecoder decoder(&listener);
922+
http2::DecodeBuffer db(reinterpret_cast<const char *>(s.c_str()), s.size());
923+
decoder.DecodeFrame(&db);
924+
}
925+
FUZZ_TEST(Http2FrameDecoderFuzzTest, FuzzFrameDecoder);
926+
917927
} // namespace
918928
} // namespace test
919929
} // namespace http2

0 commit comments

Comments
 (0)