Add ALTS fuzzer

pull/15221/head
Yihua Zhang 7 years ago
parent d8f35e95dc
commit cc93663910
  1. 32
      CMakeLists.txt
  2. 72
      Makefile
  3. 15
      build.yaml
  4. 2
      gRPC-Core.podspec
  5. 2
      grpc.gyp
  6. 139
      test/core/end2end/fuzzers/api_fuzzer.cc
  7. 12
      test/core/security/BUILD
  8. 120
      test/core/security/alts_credentials_fuzzer.cc
  9. BIN
      test/core/security/corpus/alts_credentials_corpus/0149b46b88d583e05be0fb1423d10f2a14d36c48
  10. BIN
      test/core/security/corpus/alts_credentials_corpus/047fc351e73f760d329d5a8845944720be9ce773
  11. BIN
      test/core/security/corpus/alts_credentials_corpus/04ef96c66d8222d1a2c07e6b2a6548e6a527042b
  12. BIN
      test/core/security/corpus/alts_credentials_corpus/05a7e16c1d7f92111f43e9c777421879920e79a4
  13. BIN
      test/core/security/corpus/alts_credentials_corpus/063eb46f202fdfe7935c30ca38d7eb81c82db419
  14. BIN
      test/core/security/corpus/alts_credentials_corpus/064773597c295fa871c184fc12d17b6de8aab31b
  15. BIN
      test/core/security/corpus/alts_credentials_corpus/087449740758b114d16790067707934479946bd6
  16. BIN
      test/core/security/corpus/alts_credentials_corpus/0a5d068feb57a2782c6eba57b637abe8668ac82f
  17. BIN
      test/core/security/corpus/alts_credentials_corpus/0b81e6d89bf7df80e87e5ee7c49f7cc1431f77e8
  18. BIN
      test/core/security/corpus/alts_credentials_corpus/11409339cec708a5e353893101bfe76364337d5c
  19. 1
      test/core/security/corpus/alts_credentials_corpus/147696a264cd6f197adb7c68aff834c30b1b77f8
  20. BIN
      test/core/security/corpus/alts_credentials_corpus/160e5cac38c5c9e919ed6e4fbafee76907d63044
  21. 1
      test/core/security/corpus/alts_credentials_corpus/173d02167db431040b0540d98f6fc5e8b456587d
  22. BIN
      test/core/security/corpus/alts_credentials_corpus/18a3fe239806b3c7d1af24bcd2bd23aeeb072d5c
  23. 1
      test/core/security/corpus/alts_credentials_corpus/195abd83b2e9d32b1b5b854fe33da44b6db40880
  24. BIN
      test/core/security/corpus/alts_credentials_corpus/19af2509c7d84334b9ec64de4767a07d5294fd72
  25. BIN
      test/core/security/corpus/alts_credentials_corpus/1b9864b948fcf08b062fd4401ef55b214c259535
  26. BIN
      test/core/security/corpus/alts_credentials_corpus/1edddfa67de854d7faaba41418fda845e9c6a89d
  27. BIN
      test/core/security/corpus/alts_credentials_corpus/20031bb00e6608e1b570aa96e6afb9de06d42167
  28. BIN
      test/core/security/corpus/alts_credentials_corpus/22b4c7ce7db99b0df63c9eae9265de484b695922
  29. 1
      test/core/security/corpus/alts_credentials_corpus/27416437ad287bd3cc1c5efdecebc39f20df73c1
  30. BIN
      test/core/security/corpus/alts_credentials_corpus/27e8cd785c2b9346f68dba75761b52fbabaf2b72
  31. BIN
      test/core/security/corpus/alts_credentials_corpus/28236f860d3d8e5ea11176746cb4c1c5c4f1f6c0
  32. BIN
      test/core/security/corpus/alts_credentials_corpus/29e15b492c5a409938092a30c003c5c34df7e283
  33. BIN
      test/core/security/corpus/alts_credentials_corpus/2a47864d77749aa042b772895dbdf46f608ccc6d
  34. 2
      test/core/security/corpus/alts_credentials_corpus/2cca5cb1b135c35f6e5e1ec4c37deb9e12d37dc0
  35. BIN
      test/core/security/corpus/alts_credentials_corpus/2df27b6c42dbaee382a29a87338d64ee87354acb
  36. 2
      test/core/security/corpus/alts_credentials_corpus/2e9ddd1339d8e599cef658a08965985c4f45e428
  37. 2
      test/core/security/corpus/alts_credentials_corpus/31a2d12a84a7a56ace831a9668d6ab4847390679
  38. BIN
      test/core/security/corpus/alts_credentials_corpus/33cb9ec0ce3538ed6079b5fcb127649a5d05955b
  39. 1
      test/core/security/corpus/alts_credentials_corpus/348d9ae6eebb2e1644addf7f07231d108cf6f3b8
  40. BIN
      test/core/security/corpus/alts_credentials_corpus/359f76f3c802292e92b0640de2bfe051e780a3b6
  41. BIN
      test/core/security/corpus/alts_credentials_corpus/35a479988e965a6e3e75138b64b0bd1f45073e2f
  42. BIN
      test/core/security/corpus/alts_credentials_corpus/362b00d713686ff70cb0199f3d7d0058e5a1a27a
  43. BIN
      test/core/security/corpus/alts_credentials_corpus/3849c1625071791ceae709b9c6c705b28d099d67
  44. BIN
      test/core/security/corpus/alts_credentials_corpus/39ef03c66ee2d4bcfb6c8da50486dcd40f02fb12
  45. 1
      test/core/security/corpus/alts_credentials_corpus/3a3ca061863499ebc171a4f910fa1b49523baad4
  46. BIN
      test/core/security/corpus/alts_credentials_corpus/3a890f3fd01b048ac9db65a9a9b4f4443268b91a
  47. 1
      test/core/security/corpus/alts_credentials_corpus/3b9554038a425bd1fae057ba41f9366bb467e946
  48. BIN
      test/core/security/corpus/alts_credentials_corpus/3ce0ae4aa226f205a3a4e66bbb253419d9d754bf
  49. BIN
      test/core/security/corpus/alts_credentials_corpus/3dccc5523986c37e27684659bba8a1037e7a92e8
  50. BIN
      test/core/security/corpus/alts_credentials_corpus/3e0908c15b1cede4541d25f388b1345e8641e221
  51. BIN
      test/core/security/corpus/alts_credentials_corpus/3fcb181ff6a8c8e2ba38ed34cf78f7482eb55cb7
  52. BIN
      test/core/security/corpus/alts_credentials_corpus/41c9b5f720eb8f8fa04c840375a881781a849b43
  53. 2
      test/core/security/corpus/alts_credentials_corpus/4257a018f08f13a3a9adc848ef808e1be50bc4cf
  54. BIN
      test/core/security/corpus/alts_credentials_corpus/42dfc5c4d13261b7259e65cd692df9c9d607194e
  55. BIN
      test/core/security/corpus/alts_credentials_corpus/43144664aedb585d45d42aa5249ddbfe81afe470
  56. BIN
      test/core/security/corpus/alts_credentials_corpus/43e5ad495a47593b17dbcbd3e70c2e25a417bb6e
  57. BIN
      test/core/security/corpus/alts_credentials_corpus/446614e45b7bef49118b17e031c48faf167ebe3e
  58. BIN
      test/core/security/corpus/alts_credentials_corpus/46492477fa84ca88e85df914801af0b09b0939f6
  59. BIN
      test/core/security/corpus/alts_credentials_corpus/47157f83b166b57e0052c98a65c6db864fa6cb9b
  60. BIN
      test/core/security/corpus/alts_credentials_corpus/473fc9b6d768a925527d3ad805ca363d490dc741
  61. BIN
      test/core/security/corpus/alts_credentials_corpus/483c0b4015100eee00f6b23d1100d8c4953dd3b1
  62. BIN
      test/core/security/corpus/alts_credentials_corpus/48be2dc4cdc5462407b319caa855d976cda88153
  63. 1
      test/core/security/corpus/alts_credentials_corpus/4e84eb54a0e438052b0c2e83653135042d9eb59a
  64. 1
      test/core/security/corpus/alts_credentials_corpus/50839d5c8bf33f0970986dcc4b73b024f11a95b7
  65. BIN
      test/core/security/corpus/alts_credentials_corpus/523d964986d8ad966ae07e540a608681098813f9
  66. BIN
      test/core/security/corpus/alts_credentials_corpus/5410b8190c95dacd36d6e6ec75b7538a630e08de
  67. BIN
      test/core/security/corpus/alts_credentials_corpus/549b2891ac79f504a7c9ea00f6d7527c34ce04e6
  68. 1
      test/core/security/corpus/alts_credentials_corpus/55321649e7b7f1b5664ae20724e683c930643fc4
  69. 1
      test/core/security/corpus/alts_credentials_corpus/55cc52f25865baee3e6e52c3110a9723caa2b3cb
  70. BIN
      test/core/security/corpus/alts_credentials_corpus/56c22410e3295ad03aa31552ab888f581756cc17
  71. BIN
      test/core/security/corpus/alts_credentials_corpus/5724a705b62a7548ba2df1abe4ef0c970c4e1bd2
  72. BIN
      test/core/security/corpus/alts_credentials_corpus/576a148c107d56861d1611641a6f7c7921061c5c
  73. BIN
      test/core/security/corpus/alts_credentials_corpus/5a6b8263e8939f851cf5b1e347a33d97253b7b3d
  74. BIN
      test/core/security/corpus/alts_credentials_corpus/5ba93c9db0cff93f52b521d7420e43f6eda2784f
  75. BIN
      test/core/security/corpus/alts_credentials_corpus/5bd02a339fd7705449388580c75bfcc597aba954
  76. 1
      test/core/security/corpus/alts_credentials_corpus/5bd6fb6fc4163bf3a9db6ddaf509dce8df8a5000
  77. 1
      test/core/security/corpus/alts_credentials_corpus/5d06fc38005503af3d084721c60e574fb9d2f370
  78. BIN
      test/core/security/corpus/alts_credentials_corpus/5ddc10489ff3269bdaa3051b70fb7af455ee1104
  79. BIN
      test/core/security/corpus/alts_credentials_corpus/5ea9d515f0d10b04f1356b9463139bfe121a6e4a
  80. 1
      test/core/security/corpus/alts_credentials_corpus/61c449793347cf2e1ed0c38d54d23c63dfaabeb8
  81. BIN
      test/core/security/corpus/alts_credentials_corpus/6287389c373e9788dcc04f9747b4be1fd1ef3028
  82. BIN
      test/core/security/corpus/alts_credentials_corpus/64d4de4d5aafab7ec388a7fe83066c1a4d1d9d68
  83. BIN
      test/core/security/corpus/alts_credentials_corpus/651c37806d2ac579dcfc97643c3c1ea74dbb8774
  84. 1
      test/core/security/corpus/alts_credentials_corpus/6551d02d20573cfa2944ec1f12b0c01f264a1326
  85. BIN
      test/core/security/corpus/alts_credentials_corpus/65f029414ee10e45ff4b9f305f7b472364cea538
  86. BIN
      test/core/security/corpus/alts_credentials_corpus/68b75a17fe2db060df3e61a597650ba99079abbf
  87. BIN
      test/core/security/corpus/alts_credentials_corpus/69e80594dbc5c4c648e39883a650b1760f20ab63
  88. BIN
      test/core/security/corpus/alts_credentials_corpus/6cb47d0e640b4c41e32f13c0d64ee46eae1b80b5
  89. BIN
      test/core/security/corpus/alts_credentials_corpus/6da5fe063432cb9094c7c083efdbbe5ba4246d18
  90. BIN
      test/core/security/corpus/alts_credentials_corpus/6dd140da774d85f272fb587dc1b2a85d881a7c21
  91. BIN
      test/core/security/corpus/alts_credentials_corpus/6ddab273597d73be49e2307d68e00fa18bba4765
  92. BIN
      test/core/security/corpus/alts_credentials_corpus/6eaf85d84fbf47ea0619d0dba8d366f4e3ff0be6
  93. BIN
      test/core/security/corpus/alts_credentials_corpus/6f751cc09af8113f6ecd491b1830bd8454c4738d
  94. BIN
      test/core/security/corpus/alts_credentials_corpus/70d9eb29a70d483d07e2faca6b00098af78d1fff
  95. BIN
      test/core/security/corpus/alts_credentials_corpus/7192effa1058382b379fb7b87f1acad5ac554d05
  96. BIN
      test/core/security/corpus/alts_credentials_corpus/730e85d6a62e70cb6721009b903782ade4ff73a2
  97. 2
      test/core/security/corpus/alts_credentials_corpus/74002471a854059cb29de7cad8f9fb7adc3c5ec2
  98. BIN
      test/core/security/corpus/alts_credentials_corpus/747f2330cd1fc4a06d54b376a9a6528d0364f0ac
  99. 1
      test/core/security/corpus/alts_credentials_corpus/749d5d7a9e0b1545b297117e834462af32b3e230
  100. 1
      test/core/security/corpus/alts_credentials_corpus/77de0b1de120ac702ca45868b1008a48626daf12
  101. Some files were not shown because too many files have changed in this diff Show More

@ -454,6 +454,7 @@ if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX)
add_dependencies(buildtests_c h2_uds_nosec_test)
endif()
add_dependencies(buildtests_c inproc_nosec_test)
add_dependencies(buildtests_c alts_credentials_fuzzer_one_entry)
add_dependencies(buildtests_c api_fuzzer_one_entry)
add_dependencies(buildtests_c client_fuzzer_one_entry)
add_dependencies(buildtests_c hpack_parser_fuzzer_test_one_entry)
@ -1672,6 +1673,7 @@ add_library(grpc_test_util
test/core/end2end/fixtures/proxy.cc
test/core/iomgr/endpoint_tests.cc
test/core/util/debugger_macros.cc
test/core/util/fuzzer_util.cc
test/core/util/grpc_profiler.cc
test/core/util/histogram.cc
test/core/util/memory_counters.cc
@ -1975,6 +1977,7 @@ add_library(grpc_test_util_unsecure
test/core/end2end/fixtures/proxy.cc
test/core/iomgr/endpoint_tests.cc
test/core/util/debugger_macros.cc
test/core/util/fuzzer_util.cc
test/core/util/grpc_profiler.cc
test/core/util/histogram.cc
test/core/util/memory_counters.cc
@ -15712,6 +15715,35 @@ endif()
endif (gRPC_BUILD_TESTS)
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
)
target_include_directories(alts_credentials_fuzzer_one_entry
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
PRIVATE ${_gRPC_SSL_INCLUDE_DIR}
PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR}
PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR}
PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR}
PRIVATE ${_gRPC_CARES_INCLUDE_DIR}
PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR}
PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR}
)
target_link_libraries(alts_credentials_fuzzer_one_entry
${_gRPC_ALLTARGETS_LIBRARIES}
grpc_test_util
grpc
gpr_test_util
gpr
)
endif (gRPC_BUILD_TESTS)
if (gRPC_BUILD_TESTS)
add_executable(api_fuzzer_one_entry
test/core/end2end/fuzzers/api_fuzzer.cc
test/core/util/one_corpus_entry_fuzzer.cc

@ -960,6 +960,7 @@ stop:
algorithm_test: $(BINDIR)/$(CONFIG)/algorithm_test
alloc_test: $(BINDIR)/$(CONFIG)/alloc_test
alpn_test: $(BINDIR)/$(CONFIG)/alpn_test
alts_credentials_fuzzer: $(BINDIR)/$(CONFIG)/alts_credentials_fuzzer
api_fuzzer: $(BINDIR)/$(CONFIG)/api_fuzzer
arena_test: $(BINDIR)/$(CONFIG)/arena_test
avl_test: $(BINDIR)/$(CONFIG)/avl_test
@ -1325,6 +1326,7 @@ resolver_component_tests_runner_invoker_unsecure: $(BINDIR)/$(CONFIG)/resolver_c
resolver_component_tests_runner_invoker: $(BINDIR)/$(CONFIG)/resolver_component_tests_runner_invoker
address_sorting_test_unsecure: $(BINDIR)/$(CONFIG)/address_sorting_test_unsecure
address_sorting_test: $(BINDIR)/$(CONFIG)/address_sorting_test
alts_credentials_fuzzer_one_entry: $(BINDIR)/$(CONFIG)/alts_credentials_fuzzer_one_entry
api_fuzzer_one_entry: $(BINDIR)/$(CONFIG)/api_fuzzer_one_entry
client_fuzzer_one_entry: $(BINDIR)/$(CONFIG)/client_fuzzer_one_entry
hpack_parser_fuzzer_test_one_entry: $(BINDIR)/$(CONFIG)/hpack_parser_fuzzer_test_one_entry
@ -1571,6 +1573,7 @@ buildtests_c: privatelibs_c \
$(BINDIR)/$(CONFIG)/h2_sockpair_1byte_nosec_test \
$(BINDIR)/$(CONFIG)/h2_uds_nosec_test \
$(BINDIR)/$(CONFIG)/inproc_nosec_test \
$(BINDIR)/$(CONFIG)/alts_credentials_fuzzer_one_entry \
$(BINDIR)/$(CONFIG)/api_fuzzer_one_entry \
$(BINDIR)/$(CONFIG)/client_fuzzer_one_entry \
$(BINDIR)/$(CONFIG)/hpack_parser_fuzzer_test_one_entry \
@ -4057,6 +4060,7 @@ LIBGRPC_TEST_UTIL_SRC = \
test/core/end2end/fixtures/proxy.cc \
test/core/iomgr/endpoint_tests.cc \
test/core/util/debugger_macros.cc \
test/core/util/fuzzer_util.cc \
test/core/util/grpc_profiler.cc \
test/core/util/histogram.cc \
test/core/util/memory_counters.cc \
@ -4352,6 +4356,7 @@ LIBGRPC_TEST_UTIL_UNSECURE_SRC = \
test/core/end2end/fixtures/proxy.cc \
test/core/iomgr/endpoint_tests.cc \
test/core/util/debugger_macros.cc \
test/core/util/fuzzer_util.cc \
test/core/util/grpc_profiler.cc \
test/core/util/histogram.cc \
test/core/util/memory_counters.cc \
@ -10226,6 +10231,38 @@ endif
endif
ALTS_CREDENTIALS_FUZZER_SRC = \
test/core/security/alts_credentials_fuzzer.cc \
ALTS_CREDENTIALS_FUZZER_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(ALTS_CREDENTIALS_FUZZER_SRC))))
ifeq ($(NO_SECURE),true)
# You can't build secure targets if you don't have OpenSSL.
$(BINDIR)/$(CONFIG)/alts_credentials_fuzzer: openssl_dep_error
else
$(BINDIR)/$(CONFIG)/alts_credentials_fuzzer: $(ALTS_CREDENTIALS_FUZZER_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a
$(E) "[LD] Linking $@"
$(Q) mkdir -p `dirname $@`
$(Q) $(LDXX) $(LDFLAGS) $(ALTS_CREDENTIALS_FUZZER_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -lFuzzer -o $(BINDIR)/$(CONFIG)/alts_credentials_fuzzer
endif
$(OBJDIR)/$(CONFIG)/test/core/security/alts_credentials_fuzzer.o: $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a
deps_alts_credentials_fuzzer: $(ALTS_CREDENTIALS_FUZZER_OBJS:.o=.dep)
ifneq ($(NO_SECURE),true)
ifneq ($(NO_DEPS),true)
-include $(ALTS_CREDENTIALS_FUZZER_OBJS:.o=.dep)
endif
endif
API_FUZZER_SRC = \
test/core/end2end/fuzzers/api_fuzzer.cc \
@ -23445,6 +23482,41 @@ endif
endif
ALTS_CREDENTIALS_FUZZER_ONE_ENTRY_SRC = \
test/core/security/alts_credentials_fuzzer.cc \
test/core/util/one_corpus_entry_fuzzer.cc \
ALTS_CREDENTIALS_FUZZER_ONE_ENTRY_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(ALTS_CREDENTIALS_FUZZER_ONE_ENTRY_SRC))))
ifeq ($(NO_SECURE),true)
# You can't build secure targets if you don't have OpenSSL.
$(BINDIR)/$(CONFIG)/alts_credentials_fuzzer_one_entry: openssl_dep_error
else
$(BINDIR)/$(CONFIG)/alts_credentials_fuzzer_one_entry: $(ALTS_CREDENTIALS_FUZZER_ONE_ENTRY_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a
$(E) "[LD] Linking $@"
$(Q) mkdir -p `dirname $@`
$(Q) $(LD) $(LDFLAGS) $(ALTS_CREDENTIALS_FUZZER_ONE_ENTRY_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/alts_credentials_fuzzer_one_entry
endif
$(OBJDIR)/$(CONFIG)/test/core/security/alts_credentials_fuzzer.o: $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a
$(OBJDIR)/$(CONFIG)/test/core/util/one_corpus_entry_fuzzer.o: $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a
deps_alts_credentials_fuzzer_one_entry: $(ALTS_CREDENTIALS_FUZZER_ONE_ENTRY_OBJS:.o=.dep)
ifneq ($(NO_SECURE),true)
ifneq ($(NO_DEPS),true)
-include $(ALTS_CREDENTIALS_FUZZER_ONE_ENTRY_OBJS:.o=.dep)
endif
endif
API_FUZZER_ONE_ENTRY_SRC = \
test/core/end2end/fuzzers/api_fuzzer.cc \
test/core/util/one_corpus_entry_fuzzer.cc \

@ -827,6 +827,7 @@ filegroups:
- test/core/end2end/fixtures/proxy.h
- test/core/iomgr/endpoint_tests.h
- test/core/util/debugger_macros.h
- test/core/util/fuzzer_util.h
- test/core/util/grpc_profiler.h
- test/core/util/histogram.h
- test/core/util/memory_counters.h
@ -846,6 +847,7 @@ filegroups:
- test/core/end2end/fixtures/proxy.cc
- test/core/iomgr/endpoint_tests.cc
- test/core/util/debugger_macros.cc
- test/core/util/fuzzer_util.cc
- test/core/util/grpc_profiler.cc
- test/core/util/histogram.cc
- test/core/util/memory_counters.cc
@ -1991,6 +1993,19 @@ targets:
- grpc
- gpr_test_util
- gpr
- name: alts_credentials_fuzzer
build: fuzzer
language: c
src:
- test/core/security/alts_credentials_fuzzer.cc
deps:
- grpc_test_util
- grpc
- gpr_test_util
- gpr
corpus_dirs:
- test/core/security/corpus/alts_credentials_corpus
maxlen: 2048
- name: api_fuzzer
build: fuzzer
language: c

@ -1126,6 +1126,7 @@ Pod::Spec.new do |s|
'test/core/end2end/fixtures/proxy.cc',
'test/core/iomgr/endpoint_tests.cc',
'test/core/util/debugger_macros.cc',
'test/core/util/fuzzer_util.cc',
'test/core/util/grpc_profiler.cc',
'test/core/util/histogram.cc',
'test/core/util/memory_counters.cc',
@ -1148,6 +1149,7 @@ Pod::Spec.new do |s|
'test/core/end2end/fixtures/proxy.h',
'test/core/iomgr/endpoint_tests.h',
'test/core/util/debugger_macros.h',
'test/core/util/fuzzer_util.h',
'test/core/util/grpc_profiler.h',
'test/core/util/histogram.h',
'test/core/util/memory_counters.h',

@ -577,6 +577,7 @@
'test/core/end2end/fixtures/proxy.cc',
'test/core/iomgr/endpoint_tests.cc',
'test/core/util/debugger_macros.cc',
'test/core/util/fuzzer_util.cc',
'test/core/util/grpc_profiler.cc',
'test/core/util/histogram.cc',
'test/core/util/memory_counters.cc',
@ -807,6 +808,7 @@
'test/core/end2end/fixtures/proxy.cc',
'test/core/iomgr/endpoint_tests.cc',
'test/core/util/debugger_macros.cc',
'test/core/util/fuzzer_util.cc',
'test/core/util/grpc_profiler.cc',
'test/core/util/histogram.cc',
'test/core/util/memory_counters.cc',

@ -38,8 +38,14 @@
#include "src/core/lib/surface/server.h"
#include "src/core/lib/transport/metadata.h"
#include "test/core/end2end/data/ssl_test_data.h"
#include "test/core/util/fuzzer_util.h"
#include "test/core/util/passthru_endpoint.h"
using grpc_core::testing::grpc_fuzzer_get_next_byte;
using grpc_core::testing::grpc_fuzzer_get_next_string;
using grpc_core::testing::grpc_fuzzer_get_next_uint32;
using grpc_core::testing::input_stream;
////////////////////////////////////////////////////////////////////////////////
// logging
@ -65,58 +71,20 @@ static gpr_timespec now_impl(gpr_clock_type clock_type) {
return ts;
}
////////////////////////////////////////////////////////////////////////////////
// input_stream: allows easy access to input bytes, and allows reading a little
// past the end (avoiding needing to check everywhere)
typedef struct {
const uint8_t* cur;
const uint8_t* end;
} input_stream;
static uint8_t next_byte(input_stream* inp) {
if (inp->cur == inp->end) {
return 0;
}
return *inp->cur++;
}
static void end(input_stream* inp) { inp->cur = inp->end; }
static char* read_string(input_stream* inp, bool* special) {
char* str = nullptr;
size_t cap = 0;
size_t sz = 0;
char c;
do {
if (cap == sz) {
cap = GPR_MAX(3 * cap / 2, cap + 8);
str = static_cast<char*>(gpr_realloc(str, cap));
}
c = static_cast<char>(next_byte(inp));
str[sz++] = c;
} while (c != 0 && c != 1);
if (special != nullptr) {
*special = (c == 1);
}
if (c == 1) {
str[sz - 1] = 0;
}
return str;
}
static void read_buffer(input_stream* inp, char** buffer, size_t* length,
bool* special) {
*length = next_byte(inp);
*length = grpc_fuzzer_get_next_byte(inp);
if (*length == 255) {
if (special != nullptr) *special = true;
*length = next_byte(inp);
*length = grpc_fuzzer_get_next_byte(inp);
} else {
if (special != nullptr) *special = false;
}
*buffer = static_cast<char*>(gpr_malloc(*length));
for (size_t i = 0; i < *length; i++) {
(*buffer)[i] = static_cast<char>(next_byte(inp));
(*buffer)[i] = static_cast<char>(grpc_fuzzer_get_next_byte(inp));
}
}
@ -128,7 +96,7 @@ static grpc_slice maybe_intern(grpc_slice s, bool intern) {
static grpc_slice read_string_like_slice(input_stream* inp) {
bool special;
char* s = read_string(inp, &special);
char* s = grpc_fuzzer_get_next_string(inp, &special);
grpc_slice r = maybe_intern(grpc_slice_from_copied_string(s), special);
gpr_free(s);
return r;
@ -146,39 +114,15 @@ static grpc_slice read_buffer_like_slice(input_stream* inp) {
}
static uint32_t read_uint22(input_stream* inp) {
uint8_t b = next_byte(inp);
uint8_t b = grpc_fuzzer_get_next_byte(inp);
uint32_t x = b & 0x7f;
if (b & 0x80) {
x <<= 7;
b = next_byte(inp);
b = grpc_fuzzer_get_next_byte(inp);
x |= b & 0x7f;
if (b & 0x80) {
x <<= 8;
x |= next_byte(inp);
}
}
return x;
}
static uint32_t read_uint32(input_stream* inp) {
uint8_t b = next_byte(inp);
uint32_t x = b & 0x7f;
if (b & 0x80) {
x <<= 7;
b = next_byte(inp);
x |= b & 0x7f;
if (b & 0x80) {
x <<= 7;
b = next_byte(inp);
x |= b & 0x7f;
if (b & 0x80) {
x <<= 7;
b = next_byte(inp);
x |= b & 0x7f;
if (b & 0x80) {
x = (x << 4) | (next_byte(inp) & 0x0f);
}
}
x |= grpc_fuzzer_get_next_byte(inp);
}
}
return x;
@ -193,22 +137,22 @@ static grpc_byte_buffer* read_message(input_stream* inp) {
}
static int read_int(input_stream* inp) {
return static_cast<int>(read_uint32(inp));
return static_cast<int>(grpc_fuzzer_get_next_uint32(inp));
}
static grpc_channel_args* read_args(input_stream* inp) {
size_t n = next_byte(inp);
size_t n = grpc_fuzzer_get_next_byte(inp);
grpc_arg* args = static_cast<grpc_arg*>(gpr_malloc(sizeof(*args) * n));
for (size_t i = 0; i < n; i++) {
switch (next_byte(inp)) {
switch (grpc_fuzzer_get_next_byte(inp)) {
case 1:
args[i].type = GRPC_ARG_STRING;
args[i].key = read_string(inp, nullptr);
args[i].value.string = read_string(inp, nullptr);
args[i].key = grpc_fuzzer_get_next_string(inp, nullptr);
args[i].value.string = grpc_fuzzer_get_next_string(inp, nullptr);
break;
case 2:
args[i].type = GRPC_ARG_INTEGER;
args[i].key = read_string(inp, nullptr);
args[i].key = grpc_fuzzer_get_next_string(inp, nullptr);
args[i].value.integer = read_int(inp);
break;
case 3:
@ -249,10 +193,11 @@ static void cred_artifact_ctx_finish(cred_artifact_ctx* ctx) {
static const char* read_cred_artifact(cred_artifact_ctx* ctx, input_stream* inp,
const char** builtins,
size_t num_builtins) {
uint8_t b = next_byte(inp);
uint8_t b = grpc_fuzzer_get_next_byte(inp);
if (b == 0) return nullptr;
if (b == 1)
return ctx->release[ctx->num_release++] = read_string(inp, nullptr);
return ctx->release[ctx->num_release++] =
grpc_fuzzer_get_next_string(inp, nullptr);
if (b >= num_builtins + 1) {
end(inp);
return nullptr;
@ -288,7 +233,7 @@ static grpc_call_credentials* read_call_creds(input_stream* inp, int depth) {
end(inp);
return nullptr;
}
switch (next_byte(inp)) {
switch (grpc_fuzzer_get_next_byte(inp)) {
default:
end(inp);
return nullptr;
@ -339,7 +284,7 @@ static grpc_call_credentials* read_call_creds(input_stream* inp, int depth) {
}
static grpc_channel_credentials* read_channel_creds(input_stream* inp) {
switch (next_byte(inp)) {
switch (grpc_fuzzer_get_next_byte(inp)) {
case 0:
return read_ssl_channel_creds(inp);
break;
@ -673,7 +618,7 @@ static grpc_slice* add_slice_to_unref(call_state* call, grpc_slice s) {
static void read_metadata(input_stream* inp, size_t* count,
grpc_metadata** metadata, call_state* cs) {
*count = next_byte(inp);
*count = grpc_fuzzer_get_next_byte(inp);
if (*count) {
*metadata =
static_cast<grpc_metadata*>(gpr_malloc(*count * sizeof(**metadata)));
@ -681,7 +626,7 @@ static void read_metadata(input_stream* inp, size_t* count,
for (size_t i = 0; i < *count; i++) {
(*metadata)[i].key = read_string_like_slice(inp);
(*metadata)[i].value = read_buffer_like_slice(inp);
(*metadata)[i].flags = read_uint32(inp);
(*metadata)[i].flags = grpc_fuzzer_get_next_uint32(inp);
add_slice_to_unref(cs, (*metadata)[i].key);
add_slice_to_unref(cs, (*metadata)[i].value);
}
@ -811,7 +756,7 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
grpc_timer_manager_tick();
switch (next_byte(&inp)) {
switch (grpc_fuzzer_get_next_byte(&inp)) {
// terminate on bad bytes
default:
end(&inp);
@ -838,13 +783,14 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
// increment global time
case 1: {
g_now = gpr_time_add(
g_now, gpr_time_from_micros(read_uint32(&inp), GPR_TIMESPAN));
g_now, gpr_time_from_micros(grpc_fuzzer_get_next_uint32(&inp),
GPR_TIMESPAN));
break;
}
// create an insecure channel
case 2: {
if (g_channel == nullptr) {
char* target = read_string(&inp, nullptr);
char* target = grpc_fuzzer_get_next_string(&inp, nullptr);
char* target_uri;
gpr_asprintf(&target_uri, "dns:%s", target);
grpc_channel_args* args = read_args(&inp);
@ -927,7 +873,7 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
// check connectivity
case 8: {
if (g_channel != nullptr) {
uint8_t try_to_connect = next_byte(&inp);
uint8_t try_to_connect = grpc_fuzzer_get_next_byte(&inp);
if (try_to_connect == 0 || try_to_connect == 1) {
grpc_channel_check_connectivity_state(g_channel, try_to_connect);
} else {
@ -946,7 +892,8 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
if (st != GRPC_CHANNEL_SHUTDOWN) {
gpr_timespec deadline = gpr_time_add(
gpr_now(GPR_CLOCK_REALTIME),
gpr_time_from_micros(read_uint32(&inp), GPR_TIMESPAN));
gpr_time_from_micros(grpc_fuzzer_get_next_uint32(&inp),
GPR_TIMESPAN));
grpc_channel_watch_connectivity_state(
g_channel, st, deadline, cq,
create_validator(validate_connectivity_watch,
@ -971,7 +918,7 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
}
parent_call = g_active_call->call;
}
uint32_t propagation_mask = read_uint32(&inp);
uint32_t propagation_mask = grpc_fuzzer_get_next_uint32(&inp);
grpc_slice method = read_string_like_slice(&inp);
if (GRPC_SLICE_LENGTH(method) == 0) {
ok = false;
@ -979,7 +926,8 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
grpc_slice host = read_string_like_slice(&inp);
gpr_timespec deadline =
gpr_time_add(gpr_now(GPR_CLOCK_REALTIME),
gpr_time_from_micros(read_uint32(&inp), GPR_TIMESPAN));
gpr_time_from_micros(grpc_fuzzer_get_next_uint32(&inp),
GPR_TIMESPAN));
if (ok) {
call_state* cs = new_call(g_active_call, CLIENT);
@ -1005,7 +953,7 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
end(&inp);
break;
}
size_t num_ops = next_byte(&inp);
size_t num_ops = grpc_fuzzer_get_next_byte(&inp);
if (num_ops > 6) {
end(&inp);
break;
@ -1019,7 +967,7 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
uint8_t has_ops = 0;
for (i = 0; i < num_ops; i++) {
op = &ops[i];
switch (next_byte(&inp)) {
switch (grpc_fuzzer_get_next_byte(&inp)) {
default:
/* invalid value */
op->op = (grpc_op_type)-1;
@ -1060,7 +1008,8 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
&op->data.send_status_from_server.trailing_metadata,
g_active_call);
op->data.send_status_from_server.status =
static_cast<grpc_status_code>(next_byte(&inp));
static_cast<grpc_status_code>(
grpc_fuzzer_get_next_byte(&inp));
op->data.send_status_from_server.status_details =
add_slice_to_unref(g_active_call,
read_buffer_like_slice(&inp));
@ -1097,7 +1046,7 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
break;
}
op->reserved = nullptr;
op->flags = read_uint32(&inp);
op->flags = grpc_fuzzer_get_next_uint32(&inp);
}
if (ok) {
validator* v = make_finished_batch_validator(g_active_call, has_ops);
@ -1160,14 +1109,14 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
}
// enable a tracer
case 17: {
char* tracer = read_string(&inp, nullptr);
char* tracer = grpc_fuzzer_get_next_string(&inp, nullptr);
grpc_tracer_set_enabled(tracer, 1);
gpr_free(tracer);
break;
}
// disable a tracer
case 18: {
char* tracer = read_string(&inp, nullptr);
char* tracer = grpc_fuzzer_get_next_string(&inp, nullptr);
grpc_tracer_set_enabled(tracer, 0);
gpr_free(tracer);
break;
@ -1209,7 +1158,7 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
// create a secure channel
case 22: {
if (g_channel == nullptr) {
char* target = read_string(&inp, nullptr);
char* target = grpc_fuzzer_get_next_string(&inp, nullptr);
char* target_uri;
gpr_asprintf(&target_uri, "dns:%s", target);
grpc_channel_args* args = read_args(&inp);

@ -20,6 +20,18 @@ grpc_package(name = "test/core/security")
load("//test/core/util:grpc_fuzzer.bzl", "grpc_fuzzer")
grpc_fuzzer(
name = "alts_credentials_fuzzer",
srcs = ["alts_credentials_fuzzer.cc"],
language = "C++",
corpus = "corpus/alts_credentials_corpus",
deps = [
"//:gpr",
"//:grpc",
"//test/core/util:grpc_test_util",
],
)
grpc_fuzzer(
name = "ssl_server_fuzzer",
srcs = ["ssl_server_fuzzer.cc"],

@ -0,0 +1,120 @@
/*
*
* Copyright 2018 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 <string.h>
#include <grpc/grpc.h>
#include <grpc/grpc_security.h>
#include <grpc/support/alloc.h>
#include <grpc/support/log.h>
#include <grpc/support/string_util.h>
#include "test/core/util/fuzzer_util.h"
#include "test/core/util/memory_counters.h"
#include "src/core/lib/gpr/env.h"
#include "src/core/lib/security/credentials/alts/alts_credentials.h"
#include "src/core/lib/security/credentials/alts/check_gcp_environment.h"
#include "src/core/lib/security/credentials/alts/grpc_alts_credentials_options.h"
using grpc_core::testing::grpc_fuzzer_get_next_byte;
using grpc_core::testing::grpc_fuzzer_get_next_string;
using grpc_core::testing::input_stream;
// Logging
bool squelch = true;
bool leak_check = true;
static void dont_log(gpr_log_func_args* args) {}
// Add a random number of target service accounts to client options.
static void read_target_service_accounts(
input_stream* inp, grpc_alts_credentials_options* options) {
size_t n = grpc_fuzzer_get_next_byte(inp);
for (size_t i = 0; i < n; i++) {
char* service_account = grpc_fuzzer_get_next_string(inp, nullptr);
if (service_account != nullptr) {
grpc_alts_credentials_client_options_add_target_service_account(
options, service_account);
gpr_free(service_account);
}
}
// Added to improve code coverage.
grpc_alts_credentials_client_options_add_target_service_account(options,
nullptr);
grpc_alts_credentials_client_options_add_target_service_account(
nullptr, "this is service account");
}
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
char* grpc_trace_fuzzer = gpr_getenv("GRPC_TRACE_FUZZER");
if (squelch && grpc_trace_fuzzer == nullptr) {
gpr_set_log_function(dont_log);
}
gpr_free(grpc_trace_fuzzer);
struct grpc_memory_counters counters;
if (leak_check) {
grpc_memory_counters_init();
}
input_stream inp = {data, data + size};
grpc_init();
bool is_on_gcp = grpc_alts_is_running_on_gcp();
while (inp.cur != inp.end) {
bool enable_untrusted_alts = grpc_fuzzer_get_next_byte(&inp) & 0x01;
char* handshaker_service_url =
grpc_fuzzer_get_next_byte(&inp) & 0x01
? grpc_fuzzer_get_next_string(&inp, nullptr)
: nullptr;
if (grpc_fuzzer_get_next_byte(&inp) & 0x01) {
// Test ALTS channel credentials.
grpc_alts_credentials_options* options =
grpc_alts_credentials_client_options_create();
read_target_service_accounts(&inp, options);
grpc_channel_credentials* cred = grpc_alts_credentials_create_customized(
options, handshaker_service_url, enable_untrusted_alts);
if (!enable_untrusted_alts && !is_on_gcp) {
GPR_ASSERT(cred == nullptr);
} else {
GPR_ASSERT(cred != nullptr);
}
grpc_channel_credentials_release(cred);
grpc_alts_credentials_options_destroy(options);
} else {
// Test ALTS server credentials.
grpc_alts_credentials_options* options =
grpc_alts_credentials_server_options_create();
grpc_server_credentials* cred =
grpc_alts_server_credentials_create_customized(
options, handshaker_service_url, enable_untrusted_alts);
if (!enable_untrusted_alts && !is_on_gcp) {
GPR_ASSERT(cred == nullptr);
} else {
GPR_ASSERT(cred != nullptr);
}
grpc_server_credentials_release(cred);
grpc_alts_credentials_options_destroy(options);
}
gpr_free(handshaker_service_url);
}
grpc_shutdown();
if (leak_check) {
counters = grpc_memory_counters_snapshot();
grpc_memory_counters_destroy();
GPR_ASSERT(counters.total_size_relative == 0);
}
return 0;
}

@ -0,0 +1 @@
ap˙ě~!őěA~;ě

@ -0,0 +1 @@
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ワワワ

@ -0,0 +1,2 @@
ňÓ99999999999999999999999999999999999ŹŹŹŹŹŹŹŹŹ˙˙˙˙˙˙˙˙˙˙˙˙˙/////˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙
˙˙˙˙˙˙˙˙˙˙˛˛˛˛˛˛˛˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙NSt6locale5

@ -0,0 +1 @@
<EFBFBD><EFBFBD>t_<EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>&<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>

@ -0,0 +1 @@
)applea.˙˙˙˙„ÜÜ.˙ß˙˙˙˙˙Ü˙˙˙Ü˙˙„ÜÜ.

@ -0,0 +1 @@
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>

@ -0,0 +1 @@
ač˙˙+

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save