Skip to content

Commit 87a973f

Browse files
authored
Add structurally aware fuzzing support (grpc#27405)
* Add a dependency on libprotobuf-mutator * Changes for structured fuzzing * fuzznificent * add a config that will build fuzzers * bazel run --config=fuzzer_asan //path/to:fuzzer fuzzes! * fixes * Automated change: Fix sanity tests * Automated change: Fix sanity tests * fixes * fix * sanitizer fix * fix directory * regen stuff * compile error * remove fuzzers from cmake build * Automated change: Fix sanity tests * review feedback * remove unnecessary load * review feedback * review feedback Co-authored-by: ctiller <[email protected]>
1 parent e30419f commit 87a973f

13 files changed

+147
-57614
lines changed

CMakeLists.txt

-507
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

bazel/grpc_deps.bzl

+12
Original file line numberDiff line numberDiff line change
@@ -519,3 +519,15 @@ def grpc_test_only_deps():
519519
],
520520
build_file = "@com_github_grpc_grpc//third_party:constantly.BUILD",
521521
)
522+
523+
if "com_google_libprotobuf_mutator" not in native.existing_rules():
524+
http_archive(
525+
name = "com_google_libprotobuf_mutator",
526+
sha256 = "b847c71723d8ce0b747aa661d7f3a07f1d16c595bf9c0202f30febc2f9a24a06",
527+
urls = [
528+
"https://github.com/google/libprotobuf-mutator/archive/ffd86a32874e5c08a143019aad1aaf0907294c9f.tar.gz",
529+
"https://storage.googleapis.com/grpc-bazel-mirror/github.com/google/libprotobuf-mutator/archive/ffd86a32874e5c08a143019aad1aaf0907294c9f.tar.gz",
530+
],
531+
strip_prefix = "libprotobuf-mutator-ffd86a32874e5c08a143019aad1aaf0907294c9f",
532+
build_file = "@com_github_grpc_grpc//third_party:libprotobuf_mutator.BUILD",
533+
)

build_autogenerated.yaml

-185
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

test/core/promise/BUILD

+15
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ licenses(["notice"])
1818

1919
grpc_package(name = "test/core/promise")
2020

21+
load("//test/core/util:grpc_fuzzer.bzl", "grpc_proto_fuzzer")
22+
2123
grpc_cc_test(
2224
name = "poll_test",
2325
srcs = ["poll_test.cc"],
@@ -249,3 +251,16 @@ grpc_cc_test(
249251
"//test/core/util:grpc_suppressions",
250252
],
251253
)
254+
255+
grpc_proto_fuzzer(
256+
name = "promise_fuzzer",
257+
srcs = ["promise_fuzzer.cc"],
258+
corpus = "promise_fuzzer_corpus",
259+
language = "C++",
260+
proto = "promise_fuzzer.proto",
261+
tags = ["no_windows"],
262+
uses_polling = False,
263+
deps = [
264+
"//test/core/util:grpc_test_util",
265+
],
266+
)

test/core/promise/promise_fuzzer.cc

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// Copyright 2021 gRPC authors.
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
#include "src/libfuzzer/libfuzzer_macro.h"
16+
#include "test/core/promise/promise_fuzzer.pb.h"
17+
18+
bool squelch = true;
19+
bool leak_check = true;
20+
21+
DEFINE_PROTO_FUZZER(const promise_fuzzer::Msg&) {}
+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// Copyright 2021 gRPC authors.
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
syntax = "proto3";
16+
17+
package promise_fuzzer;
18+
19+
message Msg {
20+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+

0 commit comments

Comments
 (0)