Add structurally aware fuzzing support (#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 <ctiller@users.noreply.github.com>pull/27450/head
parent
e30419fcac
commit
87a973f01d
13 changed files with 147 additions and 57614 deletions
@ -0,0 +1,21 @@ |
|||||||
|
// Copyright 2021 gRPC authors.
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
|
||||||
|
#include "src/libfuzzer/libfuzzer_macro.h" |
||||||
|
#include "test/core/promise/promise_fuzzer.pb.h" |
||||||
|
|
||||||
|
bool squelch = true; |
||||||
|
bool leak_check = true; |
||||||
|
|
||||||
|
DEFINE_PROTO_FUZZER(const promise_fuzzer::Msg&) {} |
@ -0,0 +1,20 @@ |
|||||||
|
// Copyright 2021 gRPC authors. |
||||||
|
// |
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License"); |
||||||
|
// you may not use this file except in compliance with the License. |
||||||
|
// You may obtain a copy of the License at |
||||||
|
// |
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0 |
||||||
|
// |
||||||
|
// Unless required by applicable law or agreed to in writing, software |
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS, |
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||||
|
// See the License for the specific language governing permissions and |
||||||
|
// limitations under the License. |
||||||
|
|
||||||
|
syntax = "proto3"; |
||||||
|
|
||||||
|
package promise_fuzzer; |
||||||
|
|
||||||
|
message Msg { |
||||||
|
} |
@ -0,0 +1 @@ |
|||||||
|
|
@ -0,0 +1,30 @@ |
|||||||
|
# Copyright 2021 gRPC authors. |
||||||
|
# |
||||||
|
# Licensed under the Apache License, Version 2.0 (the "License"); |
||||||
|
# you may not use this file except in compliance with the License. |
||||||
|
# You may obtain a copy of the License at |
||||||
|
# |
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0 |
||||||
|
# |
||||||
|
# Unless required by applicable law or agreed to in writing, software |
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS, |
||||||
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||||
|
# See the License for the specific language governing permissions and |
||||||
|
# limitations under the License. |
||||||
|
|
||||||
|
licenses(["notice"]) |
||||||
|
|
||||||
|
cc_library( |
||||||
|
name = "libprotobuf_mutator", |
||||||
|
srcs = glob( |
||||||
|
["src/*.cc", "src/libfuzzer/*.cc"], |
||||||
|
exclude = ["src/*_test.cc", "src/libfuzzer/*_test.cc"] |
||||||
|
), |
||||||
|
hdrs = glob(["src/*.h", "port/*.h", "src/libfuzzer/*.h"]), |
||||||
|
deps = [ |
||||||
|
"@com_google_protobuf//:protobuf", |
||||||
|
"@com_google_googletest//:gtest", |
||||||
|
], |
||||||
|
visibility = ["//visibility:public"], |
||||||
|
includes = ["."] |
||||||
|
) |
@ -1,50 +0,0 @@ |
|||||||
# Copyright 2016 gRPC authors. |
|
||||||
# |
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License"); |
|
||||||
# you may not use this file except in compliance with the License. |
|
||||||
# You may obtain a copy of the License at |
|
||||||
# |
|
||||||
# http://www.apache.org/licenses/LICENSE-2.0 |
|
||||||
# |
|
||||||
# Unless required by applicable law or agreed to in writing, software |
|
||||||
# distributed under the License is distributed on an "AS IS" BASIS, |
|
||||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
||||||
# See the License for the specific language governing permissions and |
|
||||||
# limitations under the License. |
|
||||||
"""Create tests for each fuzzer""" |
|
||||||
|
|
||||||
import copy |
|
||||||
import glob |
|
||||||
|
|
||||||
|
|
||||||
def mako_plugin(dictionary): |
|
||||||
targets = dictionary['targets'] |
|
||||||
tests = dictionary['tests'] |
|
||||||
for tgt in targets: |
|
||||||
if tgt['build'] == 'fuzzer': |
|
||||||
new_target = copy.deepcopy(tgt) |
|
||||||
new_target['build'] = 'test' |
|
||||||
new_target['name'] += '_one_entry' |
|
||||||
new_target['run'] = False |
|
||||||
new_target['src'].append( |
|
||||||
'test/core/util/one_corpus_entry_fuzzer.cc') |
|
||||||
|
|
||||||
# avoid having two main() methods |
|
||||||
to_remove = 'test/core/util/fuzzer_corpus_test.cc' |
|
||||||
if to_remove in new_target['src']: |
|
||||||
new_target['src'].remove(to_remove) |
|
||||||
|
|
||||||
targets.append(new_target) |
|
||||||
for corpus in new_target['corpus_dirs']: |
|
||||||
for fn in sorted(glob.glob('%s/*' % corpus)): |
|
||||||
tests.append({ |
|
||||||
'name': new_target['name'], |
|
||||||
'args': [fn], |
|
||||||
'exclude_configs': ['tsan'], |
|
||||||
'uses_polling': False, |
|
||||||
'platforms': ['mac', 'linux'], |
|
||||||
'ci_platforms': ['linux'], |
|
||||||
'flaky': False, |
|
||||||
'language': 'c++', |
|
||||||
'cpu_cost': 0.1, |
|
||||||
}) |
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in new issue