BUILD.gn 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275
  1. # Copyright 2017 The Chromium Authors. All rights reserved.
  2. # Use of this source code is governed by a BSD-style license that can be
  3. # found in the LICENSE file.
  4. import("//testing/libfuzzer/fuzzer_test.gni")
  5. import("//third_party/libprotobuf-mutator/fuzzable_proto_library.gni")
  6. import("//third_party/openscreen/src/build/config/data_headers_template.gni")
  7. import("//third_party/protobuf/proto_library.gni")
  8. static_library("cast_channel") {
  9. sources = [
  10. "cast_auth_util.cc",
  11. "cast_auth_util.h",
  12. "cast_channel_enum.cc",
  13. "cast_channel_enum.h",
  14. "cast_framer.cc",
  15. "cast_framer.h",
  16. "cast_message_handler.cc",
  17. "cast_message_handler.h",
  18. "cast_message_util.cc",
  19. "cast_message_util.h",
  20. "cast_socket.cc",
  21. "cast_socket.h",
  22. "cast_socket_service.cc",
  23. "cast_socket_service.h",
  24. "cast_transport.cc",
  25. "cast_transport.h",
  26. "enum_table.cc",
  27. "enum_table.h",
  28. "keep_alive_delegate.cc",
  29. "keep_alive_delegate.h",
  30. "keep_alive_handler.cc",
  31. "keep_alive_handler.h",
  32. "libcast_socket_service.cc",
  33. "libcast_socket_service.h",
  34. "logger.cc",
  35. "logger.h",
  36. "mojo_data_pump.cc",
  37. "mojo_data_pump.h",
  38. ]
  39. deps = [
  40. "//base",
  41. "//build:chromeos_buildflags",
  42. "//components/cast_certificate",
  43. "//components/cast_certificate:openscreen_certificate_verifier",
  44. "//components/keyed_service/content",
  45. "//components/keyed_service/core",
  46. "//components/openscreen_platform:openscreen_platform_network_service",
  47. "//components/prefs",
  48. "//components/version_info",
  49. "//content/public/browser",
  50. "//crypto",
  51. "//net",
  52. "//services/data_decoder/public/cpp",
  53. "//third_party/openscreen/src/cast/common:channel",
  54. "//third_party/openscreen/src/cast/common/channel/proto:channel_proto",
  55. "//third_party/openscreen/src/cast/sender:channel",
  56. "//third_party/openscreen/src/platform",
  57. ]
  58. public_deps = [
  59. "//services/data_decoder/public/cpp",
  60. "//services/network/public/mojom",
  61. ]
  62. }
  63. static_library("test_support") {
  64. testonly = true
  65. sources = [
  66. "cast_test_util.cc",
  67. "cast_test_util.h",
  68. ]
  69. deps = [
  70. ":cast_channel",
  71. "//base",
  72. "//net",
  73. "//net:test_support",
  74. "//services/service_manager/public/cpp",
  75. "//testing/gmock",
  76. "//testing/gtest",
  77. "//third_party/openscreen/src/cast/common/channel/proto:channel_proto",
  78. ]
  79. }
  80. source_set("unit_tests") {
  81. testonly = true
  82. sources = [
  83. "cast_auth_util_unittest.cc",
  84. "cast_framer_unittest.cc",
  85. "cast_message_handler_unittest.cc",
  86. "cast_message_util_unittest.cc",
  87. "cast_socket_service_unittest.cc",
  88. "cast_socket_unittest.cc",
  89. "cast_transport_unittest.cc",
  90. "enum_table_unittest.cc",
  91. "keep_alive_delegate_unittest.cc",
  92. "libcast_socket_service_unittest.cc",
  93. "logger_unittest.cc",
  94. ]
  95. deps = [
  96. ":cast_channel",
  97. ":test_support",
  98. "//base/test:test_support",
  99. "//components/cast_certificate",
  100. "//components/cast_certificate:cast_certificate_reader",
  101. "//components/cast_certificate:test_support",
  102. "//components/openscreen_platform:openscreen_platform",
  103. "//components/prefs",
  104. "//components/prefs:test_support",
  105. "//content/test:test_support",
  106. "//net:test_support",
  107. "//services/data_decoder/public/cpp",
  108. "//services/data_decoder/public/cpp:test_support",
  109. "//testing/gmock",
  110. "//testing/gtest",
  111. "//third_party/openscreen/src/cast/common:test_helpers",
  112. "//third_party/openscreen/src/cast/common/certificate/proto:certificate_unittest_proto",
  113. "//third_party/openscreen/src/cast/common/channel/proto:channel_proto",
  114. ]
  115. }
  116. # TODO(issuetracker.google.com/185815206): Fuzzers should also work with
  117. # openscreen code.
  118. if (use_fuzzing_engine) {
  119. source_set("cast_auth_util_fuzzer_shared") {
  120. sources = [
  121. "cast_auth_util_fuzzer_shared.cc",
  122. "cast_auth_util_fuzzer_shared.h",
  123. ]
  124. public_deps = [ ":cast_channel_fuzzer_inputs" ]
  125. deps = [
  126. "//third_party/openscreen/src/cast/common/channel/proto:channel_proto",
  127. ]
  128. }
  129. data_headers("cast_auth_util_fuzzer_certs") {
  130. namespace = "cast"
  131. sources =
  132. [ "../test/data/cast_certificate/certificates/chromecast_gen1.pem" ]
  133. }
  134. fuzzable_proto_library("cast_channel_fuzzer_inputs") {
  135. sources = [ "proto/fuzzer_inputs.proto" ]
  136. import_dirs = [
  137. "//third_party/openscreen/src/cast/common/certificate/proto",
  138. "//third_party/openscreen/src/cast/common/channel/proto",
  139. ]
  140. link_deps = [
  141. "//third_party/openscreen/src/cast/common/certificate/proto:certificate_proto",
  142. "//third_party/openscreen/src/cast/common/channel/proto:channel_proto",
  143. ]
  144. proto_out_dir = "components/cast_channel/fuzz_proto"
  145. }
  146. protoc_convert("cast_auth_util_fuzzer_convert_corpus") {
  147. sources = [
  148. "test/data/error.textproto",
  149. "test/data/good.textproto",
  150. ]
  151. inputs = [ "proto/fuzzer_inputs.proto" ]
  152. output_pattern = "$target_gen_dir/cast_auth_util_fuzzer_corpus/{{source_name_part}}.binarypb"
  153. args = [
  154. "--encode=cast_channel.fuzz.CastAuthUtilInputs",
  155. "-I",
  156. rebase_path("//third_party/openscreen/src/cast/common/channel/proto"),
  157. "-I",
  158. rebase_path("//third_party/openscreen/src/cast/common/certificate/proto"),
  159. "-I",
  160. rebase_path("proto"),
  161. "fuzzer_inputs.proto",
  162. ]
  163. }
  164. }
  165. fuzzer_test("cast_auth_util_fuzzer") {
  166. sources = [ "cast_auth_util_fuzzer.cc" ]
  167. deps = [
  168. ":cast_auth_util_fuzzer_certs",
  169. ":cast_auth_util_fuzzer_shared",
  170. ":cast_channel",
  171. ":cast_channel_fuzzer_inputs",
  172. "//components/cast_certificate",
  173. "//components/cast_certificate:cast_certificate_reader",
  174. "//components/cast_certificate:test_support",
  175. "//net:test_support",
  176. "//net/data/ssl/certificates:generate_fuzzer_cert_includes",
  177. "//third_party/libprotobuf-mutator",
  178. "//third_party/openscreen/src/cast/common/certificate/proto:certificate_proto",
  179. ]
  180. seed_corpus = "$target_gen_dir/cast_auth_util_fuzzer_corpus"
  181. seed_corpus_deps = [ ":cast_auth_util_fuzzer_convert_corpus" ]
  182. }
  183. # TODO(crbug.com/1291729): Rename target to cast_framer_ingest_fuzzer. The name
  184. # is left unchanged for now to avoid the need to get reviews for
  185. # various files that include it.
  186. fuzzer_test("cast_message_fuzzer") {
  187. sources = [ "cast_framer_ingest_fuzzer.cc" ]
  188. deps = [
  189. ":test_support",
  190. "//base",
  191. "//components/cast_channel",
  192. "//net",
  193. "//third_party/openscreen/src/cast/common/channel/proto:channel_proto",
  194. ]
  195. seed_corpus = "fuzz_corpus"
  196. # See MessageFramer::MessageHeader::max_message_size()
  197. libfuzzer_options = [ "max_len=65535" ]
  198. }
  199. fuzzer_test("cast_framer_serialize_fuzzer") {
  200. sources = [ "cast_framer_serialize_fuzzer.cc" ]
  201. deps = [
  202. ":cast_channel",
  203. ":cast_channel_fuzzer_inputs",
  204. "//third_party/libprotobuf-mutator",
  205. "//third_party/openscreen/src/cast/common/channel/proto:channel_proto",
  206. ]
  207. }
  208. fuzzer_test("cast_message_util_fuzzer") {
  209. sources = [ "cast_message_util_fuzzer.cc" ]
  210. dict = "fuzz.dict"
  211. deps = [
  212. ":cast_channel",
  213. ":cast_channel_fuzzer_inputs",
  214. "//third_party/libprotobuf-mutator",
  215. "//third_party/openscreen/src/cast/common/channel/proto:channel_proto",
  216. ]
  217. }
  218. fuzzer_test("openscreen_cast_auth_util_fuzzer") {
  219. sources = [ "openscreen_cast_auth_util_fuzzer.cc" ]
  220. deps = [
  221. ":cast_auth_util_fuzzer_certs",
  222. ":cast_auth_util_fuzzer_shared",
  223. ":cast_channel_fuzzer_inputs",
  224. "//base",
  225. "//components/cast_certificate:cast_certificate_reader",
  226. "//components/openscreen_platform",
  227. "//net/data/ssl/certificates:generate_fuzzer_cert_includes",
  228. "//third_party/boringssl",
  229. "//third_party/libprotobuf-mutator",
  230. "//third_party/openscreen/src/cast/common:certificate_boringssl",
  231. "//third_party/openscreen/src/cast/common/certificate/proto:certificate_proto",
  232. "//third_party/openscreen/src/cast/sender:channel",
  233. ]
  234. seed_corpus = "$target_gen_dir/cast_auth_util_fuzzer_corpus"
  235. seed_corpus_deps = [ ":cast_auth_util_fuzzer_convert_corpus" ]
  236. }
  237. fuzzer_test("openscreen_message_framer_deserialize_fuzzer") {
  238. sources = [ "openscreen_message_framer_deserialize_fuzzer.cc" ]
  239. deps = [
  240. "//components/openscreen_platform",
  241. "//third_party/openscreen/src/cast/common:channel",
  242. ]
  243. seed_corpus = "fuzz_corpus"
  244. # NOTE: Max message size is 65536 + 4, so this allows some overhang.
  245. libfuzzer_options = [ "max_len=65600" ]
  246. }
  247. fuzzer_test("openscreen_message_framer_serialize_fuzzer") {
  248. sources = [ "openscreen_message_framer_serialize_fuzzer.cc" ]
  249. deps = [
  250. ":cast_channel_fuzzer_inputs",
  251. "//components/openscreen_platform",
  252. "//third_party/libprotobuf-mutator",
  253. "//third_party/openscreen/src/cast/common:channel",
  254. ]
  255. }