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
Craig Tiller 3 years ago committed by GitHub
parent e30419fcac
commit 87a973f01d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 507
      CMakeLists.txt
  2. 12
      bazel/grpc_deps.bzl
  3. 185
      build_autogenerated.yaml
  4. 15
      test/core/promise/BUILD
  5. 21
      test/core/promise/promise_fuzzer.cc
  6. 20
      test/core/promise/promise_fuzzer.proto
  7. 1
      test/core/promise/promise_fuzzer_corpus/b858cb282617fb0956d960215c8e84d1ccf909c6
  8. 44
      test/core/util/grpc_fuzzer.bzl
  9. 30
      third_party/libprotobuf_mutator.BUILD
  10. 112
      tools/buildgen/extract_metadata_from_bazel_xml.py
  11. 50
      tools/buildgen/plugins/make_fuzzer_tests.py
  12. 56760
      tools/run_tests/generated/tests.json
  13. 4
      tools/run_tests/sanity/check_bazel_workspace.py

507
CMakeLists.txt generated

@ -1025,19 +1025,6 @@ if(gRPC_BUILD_TESTS)
endif()
add_dependencies(buildtests_cxx xds_interop_client)
add_dependencies(buildtests_cxx xds_interop_server)
add_dependencies(buildtests_cxx alts_credentials_fuzzer_one_entry)
add_dependencies(buildtests_cxx client_fuzzer_one_entry)
add_dependencies(buildtests_cxx hpack_parser_fuzzer_test_one_entry)
add_dependencies(buildtests_cxx http_request_fuzzer_test_one_entry)
add_dependencies(buildtests_cxx http_response_fuzzer_test_one_entry)
add_dependencies(buildtests_cxx json_fuzzer_test_one_entry)
add_dependencies(buildtests_cxx nanopb_fuzzer_response_test_one_entry)
add_dependencies(buildtests_cxx nanopb_fuzzer_serverlist_test_one_entry)
add_dependencies(buildtests_cxx percent_decode_fuzzer_one_entry)
add_dependencies(buildtests_cxx percent_encode_fuzzer_one_entry)
add_dependencies(buildtests_cxx server_fuzzer_one_entry)
add_dependencies(buildtests_cxx ssl_server_fuzzer_one_entry)
add_dependencies(buildtests_cxx uri_fuzzer_test_one_entry)
add_custom_target(buildtests
DEPENDS buildtests_c buildtests_cxx)
@ -17076,500 +17063,6 @@ target_link_libraries(xds_interop_server
endif()
if(gRPC_BUILD_TESTS)
add_executable(alts_credentials_fuzzer_one_entry
test/core/security/alts_credentials_fuzzer.cc
test/core/util/one_corpus_entry_fuzzer.cc
third_party/googletest/googletest/src/gtest-all.cc
third_party/googletest/googlemock/src/gmock-all.cc
)
target_include_directories(alts_credentials_fuzzer_one_entry
PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_CURRENT_SOURCE_DIR}/include
${_gRPC_ADDRESS_SORTING_INCLUDE_DIR}
${_gRPC_RE2_INCLUDE_DIR}
${_gRPC_SSL_INCLUDE_DIR}
${_gRPC_UPB_GENERATED_DIR}
${_gRPC_UPB_GRPC_GENERATED_DIR}
${_gRPC_UPB_INCLUDE_DIR}
${_gRPC_XXHASH_INCLUDE_DIR}
${_gRPC_ZLIB_INCLUDE_DIR}
third_party/googletest/googletest/include
third_party/googletest/googletest
third_party/googletest/googlemock/include
third_party/googletest/googlemock
${_gRPC_PROTO_GENS_DIR}
)
target_link_libraries(alts_credentials_fuzzer_one_entry
${_gRPC_PROTOBUF_LIBRARIES}
${_gRPC_ALLTARGETS_LIBRARIES}
absl::flags
grpc_test_util
grpc++_test_config
)
endif()
if(gRPC_BUILD_TESTS)
add_executable(client_fuzzer_one_entry
test/core/end2end/fuzzers/client_fuzzer.cc
test/core/util/one_corpus_entry_fuzzer.cc
third_party/googletest/googletest/src/gtest-all.cc
third_party/googletest/googlemock/src/gmock-all.cc
)
target_include_directories(client_fuzzer_one_entry
PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_CURRENT_SOURCE_DIR}/include
${_gRPC_ADDRESS_SORTING_INCLUDE_DIR}
${_gRPC_RE2_INCLUDE_DIR}
${_gRPC_SSL_INCLUDE_DIR}
${_gRPC_UPB_GENERATED_DIR}
${_gRPC_UPB_GRPC_GENERATED_DIR}
${_gRPC_UPB_INCLUDE_DIR}
${_gRPC_XXHASH_INCLUDE_DIR}
${_gRPC_ZLIB_INCLUDE_DIR}
third_party/googletest/googletest/include
third_party/googletest/googletest
third_party/googletest/googlemock/include
third_party/googletest/googlemock
${_gRPC_PROTO_GENS_DIR}
)
target_link_libraries(client_fuzzer_one_entry
${_gRPC_PROTOBUF_LIBRARIES}
${_gRPC_ALLTARGETS_LIBRARIES}
absl::flags
grpc_test_util
grpc++_test_config
)
endif()
if(gRPC_BUILD_TESTS)
add_executable(hpack_parser_fuzzer_test_one_entry
test/core/transport/chttp2/hpack_parser_fuzzer_test.cc
test/core/util/one_corpus_entry_fuzzer.cc
third_party/googletest/googletest/src/gtest-all.cc
third_party/googletest/googlemock/src/gmock-all.cc
)
target_include_directories(hpack_parser_fuzzer_test_one_entry
PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_CURRENT_SOURCE_DIR}/include
${_gRPC_ADDRESS_SORTING_INCLUDE_DIR}
${_gRPC_RE2_INCLUDE_DIR}
${_gRPC_SSL_INCLUDE_DIR}
${_gRPC_UPB_GENERATED_DIR}
${_gRPC_UPB_GRPC_GENERATED_DIR}
${_gRPC_UPB_INCLUDE_DIR}
${_gRPC_XXHASH_INCLUDE_DIR}
${_gRPC_ZLIB_INCLUDE_DIR}
third_party/googletest/googletest/include
third_party/googletest/googletest
third_party/googletest/googlemock/include
third_party/googletest/googlemock
${_gRPC_PROTO_GENS_DIR}
)
target_link_libraries(hpack_parser_fuzzer_test_one_entry
${_gRPC_PROTOBUF_LIBRARIES}
${_gRPC_ALLTARGETS_LIBRARIES}
absl::flags
grpc_test_util
grpc++_test_config
)
endif()
if(gRPC_BUILD_TESTS)
add_executable(http_request_fuzzer_test_one_entry
test/core/http/request_fuzzer.cc
test/core/util/one_corpus_entry_fuzzer.cc
third_party/googletest/googletest/src/gtest-all.cc
third_party/googletest/googlemock/src/gmock-all.cc
)
target_include_directories(http_request_fuzzer_test_one_entry
PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_CURRENT_SOURCE_DIR}/include
${_gRPC_ADDRESS_SORTING_INCLUDE_DIR}
${_gRPC_RE2_INCLUDE_DIR}
${_gRPC_SSL_INCLUDE_DIR}
${_gRPC_UPB_GENERATED_DIR}
${_gRPC_UPB_GRPC_GENERATED_DIR}
${_gRPC_UPB_INCLUDE_DIR}
${_gRPC_XXHASH_INCLUDE_DIR}
${_gRPC_ZLIB_INCLUDE_DIR}
third_party/googletest/googletest/include
third_party/googletest/googletest
third_party/googletest/googlemock/include
third_party/googletest/googlemock
${_gRPC_PROTO_GENS_DIR}
)
target_link_libraries(http_request_fuzzer_test_one_entry
${_gRPC_PROTOBUF_LIBRARIES}
${_gRPC_ALLTARGETS_LIBRARIES}
absl::flags
grpc_test_util
grpc++_test_config
)
endif()
if(gRPC_BUILD_TESTS)
add_executable(http_response_fuzzer_test_one_entry
test/core/http/response_fuzzer.cc
test/core/util/one_corpus_entry_fuzzer.cc
third_party/googletest/googletest/src/gtest-all.cc
third_party/googletest/googlemock/src/gmock-all.cc
)
target_include_directories(http_response_fuzzer_test_one_entry
PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_CURRENT_SOURCE_DIR}/include
${_gRPC_ADDRESS_SORTING_INCLUDE_DIR}
${_gRPC_RE2_INCLUDE_DIR}
${_gRPC_SSL_INCLUDE_DIR}
${_gRPC_UPB_GENERATED_DIR}
${_gRPC_UPB_GRPC_GENERATED_DIR}
${_gRPC_UPB_INCLUDE_DIR}
${_gRPC_XXHASH_INCLUDE_DIR}
${_gRPC_ZLIB_INCLUDE_DIR}
third_party/googletest/googletest/include
third_party/googletest/googletest
third_party/googletest/googlemock/include
third_party/googletest/googlemock
${_gRPC_PROTO_GENS_DIR}
)
target_link_libraries(http_response_fuzzer_test_one_entry
${_gRPC_PROTOBUF_LIBRARIES}
${_gRPC_ALLTARGETS_LIBRARIES}
absl::flags
grpc_test_util
grpc++_test_config
)
endif()
if(gRPC_BUILD_TESTS)
add_executable(json_fuzzer_test_one_entry
test/core/json/fuzzer.cc
test/core/util/one_corpus_entry_fuzzer.cc
third_party/googletest/googletest/src/gtest-all.cc
third_party/googletest/googlemock/src/gmock-all.cc
)
target_include_directories(json_fuzzer_test_one_entry
PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_CURRENT_SOURCE_DIR}/include
${_gRPC_ADDRESS_SORTING_INCLUDE_DIR}
${_gRPC_RE2_INCLUDE_DIR}
${_gRPC_SSL_INCLUDE_DIR}
${_gRPC_UPB_GENERATED_DIR}
${_gRPC_UPB_GRPC_GENERATED_DIR}
${_gRPC_UPB_INCLUDE_DIR}
${_gRPC_XXHASH_INCLUDE_DIR}
${_gRPC_ZLIB_INCLUDE_DIR}
third_party/googletest/googletest/include
third_party/googletest/googletest
third_party/googletest/googlemock/include
third_party/googletest/googlemock
${_gRPC_PROTO_GENS_DIR}
)
target_link_libraries(json_fuzzer_test_one_entry
${_gRPC_PROTOBUF_LIBRARIES}
${_gRPC_ALLTARGETS_LIBRARIES}
absl::flags
grpc_test_util
grpc++_test_config
)
endif()
if(gRPC_BUILD_TESTS)
add_executable(nanopb_fuzzer_response_test_one_entry
test/core/nanopb/fuzzer_response.cc
test/core/util/one_corpus_entry_fuzzer.cc
third_party/googletest/googletest/src/gtest-all.cc
third_party/googletest/googlemock/src/gmock-all.cc
)
target_include_directories(nanopb_fuzzer_response_test_one_entry
PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_CURRENT_SOURCE_DIR}/include
${_gRPC_ADDRESS_SORTING_INCLUDE_DIR}
${_gRPC_RE2_INCLUDE_DIR}
${_gRPC_SSL_INCLUDE_DIR}
${_gRPC_UPB_GENERATED_DIR}
${_gRPC_UPB_GRPC_GENERATED_DIR}
${_gRPC_UPB_INCLUDE_DIR}
${_gRPC_XXHASH_INCLUDE_DIR}
${_gRPC_ZLIB_INCLUDE_DIR}
third_party/googletest/googletest/include
third_party/googletest/googletest
third_party/googletest/googlemock/include
third_party/googletest/googlemock
${_gRPC_PROTO_GENS_DIR}
)
target_link_libraries(nanopb_fuzzer_response_test_one_entry
${_gRPC_PROTOBUF_LIBRARIES}
${_gRPC_ALLTARGETS_LIBRARIES}
absl::flags
grpc_test_util
grpc++_test_config
)
endif()
if(gRPC_BUILD_TESTS)
add_executable(nanopb_fuzzer_serverlist_test_one_entry
test/core/nanopb/fuzzer_serverlist.cc
test/core/util/one_corpus_entry_fuzzer.cc
third_party/googletest/googletest/src/gtest-all.cc
third_party/googletest/googlemock/src/gmock-all.cc
)
target_include_directories(nanopb_fuzzer_serverlist_test_one_entry
PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_CURRENT_SOURCE_DIR}/include
${_gRPC_ADDRESS_SORTING_INCLUDE_DIR}
${_gRPC_RE2_INCLUDE_DIR}
${_gRPC_SSL_INCLUDE_DIR}
${_gRPC_UPB_GENERATED_DIR}
${_gRPC_UPB_GRPC_GENERATED_DIR}
${_gRPC_UPB_INCLUDE_DIR}
${_gRPC_XXHASH_INCLUDE_DIR}
${_gRPC_ZLIB_INCLUDE_DIR}
third_party/googletest/googletest/include
third_party/googletest/googletest
third_party/googletest/googlemock/include
third_party/googletest/googlemock
${_gRPC_PROTO_GENS_DIR}
)
target_link_libraries(nanopb_fuzzer_serverlist_test_one_entry
${_gRPC_PROTOBUF_LIBRARIES}
${_gRPC_ALLTARGETS_LIBRARIES}
absl::flags
grpc_test_util
grpc++_test_config
)
endif()
if(gRPC_BUILD_TESTS)
add_executable(percent_decode_fuzzer_one_entry
test/core/slice/percent_decode_fuzzer.cc
test/core/util/one_corpus_entry_fuzzer.cc
third_party/googletest/googletest/src/gtest-all.cc
third_party/googletest/googlemock/src/gmock-all.cc
)
target_include_directories(percent_decode_fuzzer_one_entry
PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_CURRENT_SOURCE_DIR}/include
${_gRPC_ADDRESS_SORTING_INCLUDE_DIR}
${_gRPC_RE2_INCLUDE_DIR}
${_gRPC_SSL_INCLUDE_DIR}
${_gRPC_UPB_GENERATED_DIR}
${_gRPC_UPB_GRPC_GENERATED_DIR}
${_gRPC_UPB_INCLUDE_DIR}
${_gRPC_XXHASH_INCLUDE_DIR}
${_gRPC_ZLIB_INCLUDE_DIR}
third_party/googletest/googletest/include
third_party/googletest/googletest
third_party/googletest/googlemock/include
third_party/googletest/googlemock
${_gRPC_PROTO_GENS_DIR}
)
target_link_libraries(percent_decode_fuzzer_one_entry
${_gRPC_PROTOBUF_LIBRARIES}
${_gRPC_ALLTARGETS_LIBRARIES}
absl::flags
grpc_test_util
grpc++_test_config
)
endif()
if(gRPC_BUILD_TESTS)
add_executable(percent_encode_fuzzer_one_entry
test/core/slice/percent_encode_fuzzer.cc
test/core/util/one_corpus_entry_fuzzer.cc
third_party/googletest/googletest/src/gtest-all.cc
third_party/googletest/googlemock/src/gmock-all.cc
)
target_include_directories(percent_encode_fuzzer_one_entry
PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_CURRENT_SOURCE_DIR}/include
${_gRPC_ADDRESS_SORTING_INCLUDE_DIR}
${_gRPC_RE2_INCLUDE_DIR}
${_gRPC_SSL_INCLUDE_DIR}
${_gRPC_UPB_GENERATED_DIR}
${_gRPC_UPB_GRPC_GENERATED_DIR}
${_gRPC_UPB_INCLUDE_DIR}
${_gRPC_XXHASH_INCLUDE_DIR}
${_gRPC_ZLIB_INCLUDE_DIR}
third_party/googletest/googletest/include
third_party/googletest/googletest
third_party/googletest/googlemock/include
third_party/googletest/googlemock
${_gRPC_PROTO_GENS_DIR}
)
target_link_libraries(percent_encode_fuzzer_one_entry
${_gRPC_PROTOBUF_LIBRARIES}
${_gRPC_ALLTARGETS_LIBRARIES}
absl::flags
grpc_test_util
grpc++_test_config
)
endif()
if(gRPC_BUILD_TESTS)
add_executable(server_fuzzer_one_entry
test/core/end2end/fuzzers/server_fuzzer.cc
test/core/util/one_corpus_entry_fuzzer.cc
third_party/googletest/googletest/src/gtest-all.cc
third_party/googletest/googlemock/src/gmock-all.cc
)
target_include_directories(server_fuzzer_one_entry
PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_CURRENT_SOURCE_DIR}/include
${_gRPC_ADDRESS_SORTING_INCLUDE_DIR}
${_gRPC_RE2_INCLUDE_DIR}
${_gRPC_SSL_INCLUDE_DIR}
${_gRPC_UPB_GENERATED_DIR}
${_gRPC_UPB_GRPC_GENERATED_DIR}
${_gRPC_UPB_INCLUDE_DIR}
${_gRPC_XXHASH_INCLUDE_DIR}
${_gRPC_ZLIB_INCLUDE_DIR}
third_party/googletest/googletest/include
third_party/googletest/googletest
third_party/googletest/googlemock/include
third_party/googletest/googlemock
${_gRPC_PROTO_GENS_DIR}
)
target_link_libraries(server_fuzzer_one_entry
${_gRPC_PROTOBUF_LIBRARIES}
${_gRPC_ALLTARGETS_LIBRARIES}
absl::flags
grpc_test_util
grpc++_test_config
)
endif()
if(gRPC_BUILD_TESTS)
add_executable(ssl_server_fuzzer_one_entry
test/core/security/ssl_server_fuzzer.cc
test/core/util/one_corpus_entry_fuzzer.cc
third_party/googletest/googletest/src/gtest-all.cc
third_party/googletest/googlemock/src/gmock-all.cc
)
target_include_directories(ssl_server_fuzzer_one_entry
PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_CURRENT_SOURCE_DIR}/include
${_gRPC_ADDRESS_SORTING_INCLUDE_DIR}
${_gRPC_RE2_INCLUDE_DIR}
${_gRPC_SSL_INCLUDE_DIR}
${_gRPC_UPB_GENERATED_DIR}
${_gRPC_UPB_GRPC_GENERATED_DIR}
${_gRPC_UPB_INCLUDE_DIR}
${_gRPC_XXHASH_INCLUDE_DIR}
${_gRPC_ZLIB_INCLUDE_DIR}
third_party/googletest/googletest/include
third_party/googletest/googletest
third_party/googletest/googlemock/include
third_party/googletest/googlemock
${_gRPC_PROTO_GENS_DIR}
)
target_link_libraries(ssl_server_fuzzer_one_entry
${_gRPC_PROTOBUF_LIBRARIES}
${_gRPC_ALLTARGETS_LIBRARIES}
absl::flags
grpc_test_util
grpc++_test_config
)
endif()
if(gRPC_BUILD_TESTS)
add_executable(uri_fuzzer_test_one_entry
test/core/uri/uri_fuzzer_test.cc
test/core/util/one_corpus_entry_fuzzer.cc
third_party/googletest/googletest/src/gtest-all.cc
third_party/googletest/googlemock/src/gmock-all.cc
)
target_include_directories(uri_fuzzer_test_one_entry
PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_CURRENT_SOURCE_DIR}/include
${_gRPC_ADDRESS_SORTING_INCLUDE_DIR}
${_gRPC_RE2_INCLUDE_DIR}
${_gRPC_SSL_INCLUDE_DIR}
${_gRPC_UPB_GENERATED_DIR}
${_gRPC_UPB_GRPC_GENERATED_DIR}
${_gRPC_UPB_INCLUDE_DIR}
${_gRPC_XXHASH_INCLUDE_DIR}
${_gRPC_ZLIB_INCLUDE_DIR}
third_party/googletest/googletest/include
third_party/googletest/googletest
third_party/googletest/googlemock/include
third_party/googletest/googlemock
${_gRPC_PROTO_GENS_DIR}
)
target_link_libraries(uri_fuzzer_test_one_entry
${_gRPC_PROTOBUF_LIBRARIES}
${_gRPC_ALLTARGETS_LIBRARIES}
absl::flags
grpc_test_util
grpc++_test_config
)
endif()

@ -519,3 +519,15 @@ def grpc_test_only_deps():
],
build_file = "@com_github_grpc_grpc//third_party:constantly.BUILD",
)
if "com_google_libprotobuf_mutator" not in native.existing_rules():
http_archive(
name = "com_google_libprotobuf_mutator",
sha256 = "b847c71723d8ce0b747aa661d7f3a07f1d16c595bf9c0202f30febc2f9a24a06",
urls = [
"https://github.com/google/libprotobuf-mutator/archive/ffd86a32874e5c08a143019aad1aaf0907294c9f.tar.gz",
"https://storage.googleapis.com/grpc-bazel-mirror/github.com/google/libprotobuf-mutator/archive/ffd86a32874e5c08a143019aad1aaf0907294c9f.tar.gz",
],
strip_prefix = "libprotobuf-mutator-ffd86a32874e5c08a143019aad1aaf0907294c9f",
build_file = "@com_github_grpc_grpc//third_party:libprotobuf_mutator.BUILD",
)

@ -4411,20 +4411,6 @@ targets:
platforms:
- linux
- posix
- name: alts_credentials_fuzzer
build: fuzzer
language: c++
headers: []
src:
- test/core/security/alts_credentials_fuzzer.cc
- test/core/util/fuzzer_corpus_test.cc
deps:
- absl/flags:flag
- grpc_test_util
- grpc++_test_config
corpus_dirs:
- test/core/security/corpus/alts_credentials_corpus
maxlen: 2048
- name: alts_util_test
gtest: true
build: test
@ -5193,21 +5179,6 @@ targets:
deps:
- grpc++_test
- grpc++_test_util
- name: client_fuzzer
build: fuzzer
language: c++
headers: []
src:
- test/core/end2end/fuzzers/client_fuzzer.cc
- test/core/util/fuzzer_corpus_test.cc
deps:
- absl/flags:flag
- grpc_test_util
- grpc++_test_config
corpus_dirs:
- test/core/end2end/fuzzers/client_fuzzer_corpus
dict: test/core/end2end/fuzzers/hpack.dictionary
maxlen: 2048
- name: client_interceptors_end2end_test
gtest: true
build: test
@ -6140,21 +6111,6 @@ targets:
- test/core/transport/chttp2/hpack_encoder_index_test.cc
deps:
- absl/types:optional
- name: hpack_parser_fuzzer_test
build: fuzzer
language: c++
headers: []
src:
- test/core/transport/chttp2/hpack_parser_fuzzer_test.cc
- test/core/util/fuzzer_corpus_test.cc
deps:
- absl/flags:flag
- grpc_test_util
- grpc++_test_config
corpus_dirs:
- test/core/transport/chttp2/hpack_parser_corpus
dict: test/core/end2end/fuzzers/hpack.dictionary
maxlen: 512
- name: http2_client
build: test
run: false
@ -6168,34 +6124,6 @@ targets:
deps:
- grpc++_test_config
- grpc++_test_util
- name: http_request_fuzzer_test
build: fuzzer
language: c++
headers: []
src:
- test/core/http/request_fuzzer.cc
- test/core/util/fuzzer_corpus_test.cc
deps:
- absl/flags:flag
- grpc_test_util
- grpc++_test_config
corpus_dirs:
- test/core/http/request_corpus
maxlen: 2048
- name: http_response_fuzzer_test
build: fuzzer
language: c++
headers: []
src:
- test/core/http/response_fuzzer.cc
- test/core/util/fuzzer_corpus_test.cc
deps:
- absl/flags:flag
- grpc_test_util
- grpc++_test_config
corpus_dirs:
- test/core/http/response_corpus
maxlen: 2048
- name: hybrid_end2end_test
gtest: true
build: test
@ -6323,20 +6251,6 @@ targets:
deps:
- absl/types:variant
uses_polling: false
- name: json_fuzzer_test
build: fuzzer
language: c++
headers: []
src:
- test/core/json/fuzzer.cc
- test/core/util/fuzzer_corpus_test.cc
deps:
- absl/flags:flag
- grpc_test_util
- grpc++_test_config
corpus_dirs:
- test/core/json/corpus
maxlen: 512
- name: json_test
gtest: true
build: test
@ -6630,34 +6544,6 @@ targets:
deps:
- grpc++_test
- grpc++_test_util
- name: nanopb_fuzzer_response_test
build: fuzzer
language: c++
headers: []
src:
- test/core/nanopb/fuzzer_response.cc
- test/core/util/fuzzer_corpus_test.cc
deps:
- absl/flags:flag
- grpc_test_util
- grpc++_test_config
corpus_dirs:
- test/core/nanopb/corpus_response
maxlen: 128
- name: nanopb_fuzzer_serverlist_test
build: fuzzer
language: c++
headers: []
src:
- test/core/nanopb/fuzzer_serverlist.cc
- test/core/util/fuzzer_corpus_test.cc
deps:
- absl/flags:flag
- grpc_test_util
- grpc++_test_config
corpus_dirs:
- test/core/nanopb/corpus_serverlist
maxlen: 128
- name: nonblocking_test
gtest: true
build: test
@ -6846,34 +6732,6 @@ targets:
- test/core/gprpp/overload_test.cc
deps: []
uses_polling: false
- name: percent_decode_fuzzer
build: fuzzer
language: c++
headers: []
src:
- test/core/slice/percent_decode_fuzzer.cc
- test/core/util/fuzzer_corpus_test.cc
deps:
- absl/flags:flag
- grpc_test_util
- grpc++_test_config
corpus_dirs:
- test/core/slice/percent_decode_corpus
maxlen: 32
- name: percent_encode_fuzzer
build: fuzzer
language: c++
headers: []
src:
- test/core/slice/percent_encode_fuzzer.cc
- test/core/util/fuzzer_corpus_test.cc
deps:
- absl/flags:flag
- grpc_test_util
- grpc++_test_config
corpus_dirs:
- test/core/slice/percent_encode_corpus
maxlen: 32
- name: pid_controller_test
gtest: true
build: test
@ -7427,21 +7285,6 @@ targets:
- test/cpp/end2end/server_early_return_test.cc
deps:
- grpc++_test_util
- name: server_fuzzer
build: fuzzer
language: c++
headers: []
src:
- test/core/end2end/fuzzers/server_fuzzer.cc
- test/core/util/fuzzer_corpus_test.cc
deps:
- absl/flags:flag
- grpc_test_util
- grpc++_test_config
corpus_dirs:
- test/core/end2end/fuzzers/server_fuzzer_corpus
dict: test/core/end2end/fuzzers/hpack.dictionary
maxlen: 2048
- name: server_interceptors_end2end_test
gtest: true
build: test
@ -7557,20 +7400,6 @@ targets:
- test/core/address_utils/sockaddr_utils_test.cc
deps:
- grpc_test_util
- name: ssl_server_fuzzer
build: fuzzer
language: c++
headers: []
src:
- test/core/security/ssl_server_fuzzer.cc
- test/core/util/fuzzer_corpus_test.cc
deps:
- absl/flags:flag
- grpc_test_util
- grpc++_test_config
corpus_dirs:
- test/core/security/corpus/ssl_server_corpus
maxlen: 2048
- name: stack_tracer_test
gtest: true
build: test
@ -7901,20 +7730,6 @@ targets:
- test/core/end2end/cq_verifier.cc
deps:
- grpc_test_util
- name: uri_fuzzer_test
build: fuzzer
language: c++
headers: []
src:
- test/core/uri/uri_fuzzer_test.cc
- test/core/util/fuzzer_corpus_test.cc
deps:
- absl/flags:flag
- grpc_test_util
- grpc++_test_config
corpus_dirs:
- test/core/uri/uri_corpus
maxlen: 128
- name: uri_parser_test
gtest: true
build: test

@ -18,6 +18,8 @@ licenses(["notice"])
grpc_package(name = "test/core/promise")
load("//test/core/util:grpc_fuzzer.bzl", "grpc_proto_fuzzer")
grpc_cc_test(
name = "poll_test",
srcs = ["poll_test.cc"],
@ -249,3 +251,16 @@ grpc_cc_test(
"//test/core/util:grpc_suppressions",
],
)
grpc_proto_fuzzer(
name = "promise_fuzzer",
srcs = ["promise_fuzzer.cc"],
corpus = "promise_fuzzer_corpus",
language = "C++",
proto = "promise_fuzzer.proto",
tags = ["no_windows"],
uses_polling = False,
deps = [
"//test/core/util:grpc_test_util",
],
)

@ -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 {
}

@ -13,8 +13,11 @@
# limitations under the License.
load("//bazel:grpc_build_system.bzl", "grpc_cc_test")
load("@rules_proto//proto:defs.bzl", "proto_library")
load("@rules_cc//cc:defs.bzl", "cc_proto_library")
def grpc_fuzzer(name, corpus, srcs = [], deps = [], data = [], size = "large", **kwargs):
CORPUS_DIR = native.package_name() + "/" + corpus
grpc_cc_test(
name = name,
srcs = srcs,
@ -28,8 +31,45 @@ def grpc_fuzzer(name, corpus, srcs = [], deps = [], data = [], size = "large", *
],
size = size,
args = select({
"//:grpc_build_fuzzers": [native.package_name() + "/" + corpus],
"//conditions:default": ["--directory=" + native.package_name() + "/" + corpus],
"//:grpc_build_fuzzers": [CORPUS_DIR],
"//conditions:default": ["--directory=" + CORPUS_DIR],
}),
**kwargs
)
def grpc_proto_fuzzer(name, corpus, proto, srcs = [], deps = [], data = [], size = "large", **kwargs):
PROTO_LIBRARY = "_%s_proto" % name
CC_PROTO_LIBRARY = "_%s_cc_proto" % name
CORPUS_DIR = native.package_name() + "/" + corpus
proto_library(
name = PROTO_LIBRARY,
srcs = [proto],
)
cc_proto_library(
name = CC_PROTO_LIBRARY,
deps = [PROTO_LIBRARY],
)
grpc_cc_test(
name = name,
srcs = srcs,
deps = deps + [
"@com_google_libprotobuf_mutator//:libprotobuf_mutator",
CC_PROTO_LIBRARY,
] + select({
"//:grpc_build_fuzzers": [],
"//conditions:default": ["//test/core/util:fuzzer_corpus_test"],
}),
data = data + native.glob([corpus + "/**"]),
external_deps = [
"gtest",
],
size = size,
args = select({
"//:grpc_build_fuzzers": [CORPUS_DIR],
"//conditions:default": ["--directory=" + CORPUS_DIR],
}),
**kwargs
)

@ -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 = ["."]
)

@ -536,6 +536,9 @@ def _exclude_unwanted_cc_tests(tests: List[str]) -> List[str]:
if not test.startswith('test/cpp/util:channelz_sampler_test')
]
# we don't need to generate fuzzers outside of bazel
tests = [test for test in tests if not test.endswith('_fuzzer')]
return tests
@ -857,115 +860,6 @@ _BUILD_EXTRA_METADATA = {
# TODO(jtattermusch): add remaining tools such as grpc_print_google_default_creds_token (they are not used by bazel build)
# Fuzzers
'test/core/security:alts_credentials_fuzzer': {
'language': 'c++',
'build': 'fuzzer',
'corpus_dirs': ['test/core/security/corpus/alts_credentials_corpus'],
'maxlen': 2048,
'_TYPE': 'target',
'_RENAME': 'alts_credentials_fuzzer'
},
'test/core/end2end/fuzzers:client_fuzzer': {
'language': 'c++',
'build': 'fuzzer',
'corpus_dirs': ['test/core/end2end/fuzzers/client_fuzzer_corpus'],
'maxlen': 2048,
'dict': 'test/core/end2end/fuzzers/hpack.dictionary',
'_TYPE': 'target',
'_RENAME': 'client_fuzzer'
},
'test/core/transport/chttp2:hpack_parser_fuzzer': {
'language': 'c++',
'build': 'fuzzer',
'corpus_dirs': ['test/core/transport/chttp2/hpack_parser_corpus'],
'maxlen': 512,
'dict': 'test/core/end2end/fuzzers/hpack.dictionary',
'_TYPE': 'target',
'_RENAME': 'hpack_parser_fuzzer_test'
},
'test/core/http:request_fuzzer': {
'language': 'c++',
'build': 'fuzzer',
'corpus_dirs': ['test/core/http/request_corpus'],
'maxlen': 2048,
'_TYPE': 'target',
'_RENAME': 'http_request_fuzzer_test'
},
'test/core/http:response_fuzzer': {
'language': 'c++',
'build': 'fuzzer',
'corpus_dirs': ['test/core/http/response_corpus'],
'maxlen': 2048,
'_TYPE': 'target',
'_RENAME': 'http_response_fuzzer_test'
},
'test/core/json:json_fuzzer': {
'language': 'c++',
'build': 'fuzzer',
'corpus_dirs': ['test/core/json/corpus'],
'maxlen': 512,
'_TYPE': 'target',
'_RENAME': 'json_fuzzer_test'
},
'test/core/nanopb:fuzzer_response': {
'language': 'c++',
'build': 'fuzzer',
'corpus_dirs': ['test/core/nanopb/corpus_response'],
'maxlen': 128,
'_TYPE': 'target',
'_RENAME': 'nanopb_fuzzer_response_test'
},
'test/core/nanopb:fuzzer_serverlist': {
'language': 'c++',
'build': 'fuzzer',
'corpus_dirs': ['test/core/nanopb/corpus_serverlist'],
'maxlen': 128,
'_TYPE': 'target',
'_RENAME': 'nanopb_fuzzer_serverlist_test'
},
'test/core/slice:percent_decode_fuzzer': {
'language': 'c++',
'build': 'fuzzer',
'corpus_dirs': ['test/core/slice/percent_decode_corpus'],
'maxlen': 32,
'_TYPE': 'target',
'_RENAME': 'percent_decode_fuzzer'
},
'test/core/slice:percent_encode_fuzzer': {
'language': 'c++',
'build': 'fuzzer',
'corpus_dirs': ['test/core/slice/percent_encode_corpus'],
'maxlen': 32,
'_TYPE': 'target',
'_RENAME': 'percent_encode_fuzzer'
},
'test/core/end2end/fuzzers:server_fuzzer': {
'language': 'c++',
'build': 'fuzzer',
'corpus_dirs': ['test/core/end2end/fuzzers/server_fuzzer_corpus'],
'maxlen': 2048,
'dict': 'test/core/end2end/fuzzers/hpack.dictionary',
'_TYPE': 'target',
'_RENAME': 'server_fuzzer'
},
'test/core/security:ssl_server_fuzzer': {
'language': 'c++',
'build': 'fuzzer',
'corpus_dirs': ['test/core/security/corpus/ssl_server_corpus'],
'maxlen': 2048,
'_TYPE': 'target',
'_RENAME': 'ssl_server_fuzzer'
},
'test/core/uri:uri_fuzzer_test': {
'language': 'c++',
'build': 'fuzzer',
'corpus_dirs': ['test/core/uri/uri_corpus'],
'maxlen': 128,
'_TYPE': 'target',
'_RENAME': 'uri_fuzzer_test'
},
# TODO(jtattermusch): these fuzzers had no build.yaml equivalent
# test/core/compression:message_compress_fuzzer
# test/core/compression:message_decompress_fuzzer

@ -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

@ -50,7 +50,8 @@ _GRPC_DEP_NAMES = [
_TWISTED_CONSTANTLY_DEP_NAME, 'io_bazel_rules_go',
'build_bazel_rules_apple', 'build_bazel_apple_support', 'libuv',
'com_googlesource_code_re2', 'bazel_gazelle', 'opencensus_proto',
'com_envoyproxy_protoc_gen_validate', 'com_google_googleapis'
'com_envoyproxy_protoc_gen_validate', 'com_google_googleapis',
'com_google_libprotobuf_mutator'
]
_GRPC_BAZEL_ONLY_DEPS = [
@ -74,6 +75,7 @@ _GRPC_BAZEL_ONLY_DEPS = [
'opencensus_proto',
'com_envoyproxy_protoc_gen_validate',
'com_google_googleapis',
'com_google_libprotobuf_mutator'
]

Loading…
Cancel
Save