1# Copyright 2018 The Chromium Authors 2# Use of this source code is governed by a BSD-style license that can be 3# found in the LICENSE file. 4 5import("//net/features.gni") 6import("//testing/libfuzzer/fuzzer_test.gni") 7import("//third_party/protobuf/proto_library.gni") 8 9enable_built_in_dns = use_blink 10 11source_set("dns") { 12 # Due to circular dependencies, should only be depended on through //net. 13 visibility = [ 14 "//net", 15 "//net/http:transport_security_state_generated_files", 16 ] 17 18 # Internals only intended for use inside network stack (and tests). 19 friend = [ 20 "//chrome/browser:test_support", 21 "//chrome/test/*", 22 "//components/certificate_transparency:unit_tests", 23 "//components/cronet/*", 24 25 # Needed for brokering system DNS resolution out of the network service. 26 "//content/browser/system_dns_resolution", 27 "//content/test/*", 28 "//net/*", 29 "//services/network/*", 30 ] 31 32 public = [] 33 sources = [ 34 "address_info.cc", 35 "address_info.h", 36 "address_sorter.h", 37 "context_host_resolver.cc", 38 "context_host_resolver.h", 39 "dns_alias_utility.cc", 40 "dns_alias_utility.h", 41 "dns_config.cc", 42 "dns_config_service.cc", 43 "dns_config_service.h", 44 "dns_hosts.cc", 45 "dns_hosts.h", 46 "dns_names_util.cc", 47 "dns_names_util.h", 48 "dns_query.cc", 49 "dns_query.h", 50 "dns_reloader.cc", 51 "dns_reloader.h", 52 "dns_response.cc", 53 "dns_response_result_extractor.cc", 54 "dns_response_result_extractor.h", 55 "dns_server_iterator.cc", 56 "dns_server_iterator.h", 57 "dns_session.cc", 58 "dns_session.h", 59 "dns_transaction.cc", 60 "dns_udp_tracker.cc", 61 "dns_udp_tracker.h", 62 "dns_util.cc", 63 "dns_util.h", 64 "host_cache.cc", 65 "host_resolver.cc", 66 "host_resolver_cache.cc", 67 "host_resolver_cache.h", 68 "host_resolver_internal_result.cc", 69 "host_resolver_internal_result.h", 70 "host_resolver_manager.cc", 71 "host_resolver_mdns_listener_impl.cc", 72 "host_resolver_mdns_listener_impl.h", 73 "host_resolver_mdns_task.cc", 74 "host_resolver_mdns_task.h", 75 "host_resolver_nat64_task.cc", 76 "host_resolver_nat64_task.h", 77 "host_resolver_proc.cc", 78 "host_resolver_proc.h", 79 "host_resolver_system_task.cc", 80 "host_resolver_system_task.h", 81 "https_record_rdata.cc", 82 "httpssvc_metrics.cc", 83 "httpssvc_metrics.h", 84 "loopback_only.cc", 85 "loopback_only.h", 86 "mapped_host_resolver.cc", 87 "nsswitch_reader.cc", 88 "nsswitch_reader.h", 89 "opt_record_rdata.cc", 90 "record_parsed.cc", 91 "record_rdata.cc", 92 "resolve_context.cc", 93 "resolve_context.h", 94 "serial_worker.cc", 95 "serial_worker.h", 96 "system_dns_config_change_notifier.cc", 97 "system_dns_config_change_notifier.h", 98 "test_dns_config_service.cc", 99 "test_dns_config_service.h", 100 ] 101 102 if (is_win) { 103 sources += [ 104 "address_sorter_win.cc", 105 "dns_config_service_win.cc", 106 "dns_config_service_win.h", 107 ] 108 } 109 110 if (is_mac) { 111 sources += [ 112 "dns_config_watcher_mac.cc", 113 "dns_config_watcher_mac.h", 114 "notify_watcher_mac.cc", 115 "notify_watcher_mac.h", 116 ] 117 } 118 119 if (is_fuchsia) { 120 sources += [ 121 "dns_config_service_fuchsia.cc", 122 "dns_config_service_fuchsia.h", 123 ] 124 } 125 126 if (is_android) { 127 sources += [ 128 "dns_config_service_android.cc", 129 "dns_config_service_android.h", 130 ] 131 } else if (is_linux) { 132 sources += [ 133 "dns_config_service_linux.cc", 134 "dns_config_service_linux.h", 135 ] 136 } else if (is_posix) { 137 sources += [ 138 "dns_config_service_posix.cc", 139 "dns_config_service_posix.h", 140 ] 141 } 142 143 if (enable_built_in_dns) { 144 sources += [ "dns_client.cc" ] 145 146 if (is_posix || is_fuchsia) { 147 sources += [ 148 "address_sorter_posix.cc", 149 "address_sorter_posix.h", 150 ] 151 } 152 } 153 154 if (enable_mdns) { 155 sources += [ 156 "mdns_cache.cc", 157 "mdns_cache.h", 158 "mdns_client.cc", 159 "mdns_client_impl.cc", 160 "mdns_client_impl.h", 161 ] 162 } 163 164 deps = [ "//net:net_deps" ] 165 166 public_deps = [ 167 ":dns_client", 168 ":host_resolver", 169 ":host_resolver_manager", 170 ":mdns_client", 171 "//net:net_public_deps", 172 ] 173 174 allow_circular_includes_from = [ 175 ":dns_client", 176 ":host_resolver", 177 ":host_resolver_manager", 178 ":mdns_client", 179 ] 180} 181 182# The standard API of net/dns. 183# 184# Should typically only be used within the network service. Usage external to 185# the network service should instead use network service Mojo IPCs for host 186# resolution. See ResolveHost() in 187# /services/network/public/mojom/network_context.mojom and 188# /services/network/public/mojom/host_resolver.mojom. 189source_set("host_resolver") { 190 # Due to circular dependencies, should only be depended on through //net. 191 # Limit visibility to //net and other source_sets with the same access 192 # restriction. 193 visibility = [ 194 ":dns", 195 ":dns_client", 196 ":host_resolver_manager", 197 ":mdns_client", 198 "//net", 199 ] 200 201 # Restricted access so we can keep track of all usage external to the 202 # network stack and network service. 203 friend = [ 204 # chromecast/browser/url_request_context_factory.cc 205 # URLRequestContext creation for chromecast. 206 "//chromecast/browser", 207 208 # URLRequestContext and HttpNetworkSession::Context creation for iOS. 209 "//ios/components/io_thread", 210 "//ios/web/shell", 211 "//ios/web_view:*", 212 213 # Tests and test support. 214 "//chrome/browser:test_support", 215 "//chrome/test/*", 216 "//components/grpc_support/test:unit_tests", 217 "//content/shell:content_shell_lib", 218 "//content/test:*", 219 220 # Stand-alone tools. 221 "//google_apis/gcm:mcs_probe", 222 223 # Network stack/service. 224 "//components/certificate_transparency/*", 225 "//components/cronet/*", 226 "//net/*", 227 "//services/network/*", 228 ] 229 230 sources = [ 231 "dns_config.h", 232 "host_cache.h", 233 "host_resolver.h", 234 "mapped_host_resolver.h", 235 ] 236 public = [] 237 238 deps = [ 239 "//net:net_deps", 240 "//net/dns/public", 241 ] 242 public_deps = [ "//net:net_public_deps" ] 243 244 allow_circular_includes_from = [ "//net/dns/public" ] 245} 246 247# Shared mostly-global handler of HostResolver requests. 248# 249# Typically should only be directly interacted with by NetworkService (or other 250# mostly-global creators of request contexts), standalone tools, and tests. Host 251# resolution should generally instead go through HostResolvers received from 252# URLRequestContext or network service Mojo IPCs. 253source_set("host_resolver_manager") { 254 # Due to circular dependencies, should only be depended on through //net. 255 # Limit visibility to //net and other source_sets with the same access 256 # restriction. 257 visibility = [ 258 ":dns", 259 ":host_resolver", 260 "//net", 261 ] 262 263 # Restricted access so we can keep track of all usage external to the 264 # network stack and network service. 265 friend = [ 266 # chromecast/browser/url_request_context_factory.cc 267 # URLRequestContext creation for chromecast. 268 "//chromecast/browser", 269 270 # Tests and test support. 271 "//components/cronet:cronet_common_unittests", 272 273 # Network stack/service. 274 "//net/*", 275 "//services/network/*", 276 ] 277 278 sources = [ "host_resolver_manager.h" ] 279 public = [] 280 281 deps = [ 282 ":host_resolver", 283 "//net:net_deps", 284 "//net/dns/public", 285 ] 286 public_deps = [ "//net:net_public_deps" ] 287} 288 289# DnsClient interfaces. Primarily intended as part of the implementation of the 290# standard HostResolver interface, but can be used as an alternative external 291# interface for advanced usage. 292source_set("dns_client") { 293 # Due to circular dependencies, should only be depended on through //net. 294 # Limit visibility to //net and other source_sets with the same access 295 # restriction. 296 visibility = [ 297 ":dns", 298 ":mdns_client", 299 "//net", 300 ] 301 302 # Restricted access so we can keep track of all usage external to the 303 # network stack. 304 friend = [ 305 # chrome/browser/local_discovery/service_discovery_client_impl.cc 306 # Result parsing utilities for parsing results read through MdnsClient. 307 # TODO(crbug.com/874662): Remove once migrated to network service. 308 "//chrome/browser", 309 310 # chrome/browser/ash/smb_client/discovery/mdns_host_locator.cc 311 # Result parsing for results read through MdnsClient. 312 # TODO(crbug.com/902531): Remove once migrated to network service. 313 "//chrome/browser/ash", 314 315 # Tests and test support 316 "//chrome/browser:test_support", 317 "//chrome/test/*", 318 319 # Network stack/service 320 "//components/certificate_transparency/*", 321 "//net/*", 322 "//services/network/*", 323 ] 324 325 sources = [ 326 "dns_client.h", 327 "dns_response.h", 328 "dns_transaction.h", 329 "https_record_rdata.h", 330 "opt_record_rdata.h", 331 "record_parsed.h", 332 "record_rdata.h", 333 ] 334 public = [] 335 336 deps = [ 337 ":host_resolver", 338 "//net:net_deps", 339 ] 340 public_deps = [ 341 "//net:net_public_deps", 342 "//net/dns/public", 343 ] 344} 345 346# MdnsClient interfaces. 347source_set("mdns_client") { 348 # Due to circular dependencies, should only be depended on through //net. 349 # Limit visibility to //net and other source_sets with the same access 350 # restriction. 351 visibility = [ 352 ":dns", 353 "//net", 354 ] 355 356 # Restricted access so we can keep track of all usage external to the 357 # network stack. 358 friend = [ 359 # chrome/browser/local_discovery/service_discovery_client_mdns.h 360 # chrome/browser/local_discovery/service_discovery_client_impl.h 361 # Makes MDNS queries using MDnsClient. 362 # TODO(crbug.com/874662): Remove once migrated to network service. 363 "//chrome/browser", 364 365 # chrome/tools/service_discovery_sniffer/service_discovery_sniffer.cc 366 # Creates MDnsClient instance and passes to ServiceDiscoveryClientImpl. 367 # TODO(crbug.com/874662): Remove once discovery client migrated. 368 "//chrome/tools/service_discovery_sniffer", 369 370 # chrome/browser/ash/smb_client/discovery/mdns_host_locator.h 371 # chrome/browser/ash/smb_client/discovery/mdns_host_locator.cc 372 # Makes MDNS queries using MDnsClient. 373 # TODO(crbug.com/902531): Remove once migrated to network service. 374 "//chrome/browser/ash", 375 376 # Tests and test support 377 "//chrome/browser:test_support", 378 379 # Network stack/service 380 "//net/*", 381 "//services/network/*", 382 ] 383 384 public = [] 385 sources = [] 386 387 if (enable_mdns) { 388 sources += [ "mdns_client.h" ] 389 } 390 391 deps = [ 392 ":dns_client", 393 ":host_resolver", 394 "//net:net_deps", 395 ] 396 public_deps = [ "//net:net_public_deps" ] 397} 398 399source_set("tests") { 400 testonly = true 401 sources = [ 402 "address_info_unittest.cc", 403 "context_host_resolver_unittest.cc", 404 "dns_alias_utility_unittest.cc", 405 "dns_config_service_unittest.cc", 406 "dns_hosts_unittest.cc", 407 "dns_names_util_unittest.cc", 408 "dns_query_unittest.cc", 409 "dns_response_result_extractor_unittest.cc", 410 "dns_response_unittest.cc", 411 "dns_transaction_unittest.cc", 412 "dns_udp_tracker_unittest.cc", 413 "dns_util_unittest.cc", 414 "host_cache_unittest.cc", 415 "host_resolver_cache_unittest.cc", 416 "host_resolver_internal_result_unittest.cc", 417 "host_resolver_manager_unittest.cc", 418 "https_record_rdata_unittest.cc", 419 "httpssvc_metrics_unittest.cc", 420 "loopback_only_unittest.cc", 421 "mapped_host_resolver_unittest.cc", 422 "nsswitch_reader_unittest.cc", 423 "opt_record_rdata_unittest.cc", 424 "record_parsed_unittest.cc", 425 "record_rdata_unittest.cc", 426 "resolve_context_unittest.cc", 427 "serial_worker_unittest.cc", 428 "system_dns_config_change_notifier_unittest.cc", 429 ] 430 431 if (is_win) { 432 sources += [ "dns_config_service_win_unittest.cc" ] 433 } 434 435 if (is_android) { 436 sources += [ "dns_config_service_android_unittest.cc" ] 437 } else if (is_linux) { 438 sources += [ "dns_config_service_linux_unittest.cc" ] 439 } else if (is_posix) { 440 sources += [ "dns_config_service_posix_unittest.cc" ] 441 } 442 443 if (enable_built_in_dns) { 444 sources += [ 445 "address_sorter_unittest.cc", 446 "dns_client_unittest.cc", 447 ] 448 if (is_posix || is_fuchsia) { 449 sources += [ "address_sorter_posix_unittest.cc" ] 450 } 451 } 452 453 if (enable_mdns) { 454 sources += [ 455 "mdns_cache_unittest.cc", 456 "mdns_client_unittest.cc", 457 ] 458 } 459 460 deps = [ 461 "//base", 462 "//net", 463 "//net:test_support", 464 "//testing/gmock", 465 "//testing/gtest", 466 ] 467} 468 469source_set("test_support") { 470 visibility = [ "//net:test_support" ] 471 testonly = true 472 sources = [ 473 "dns_test_util.cc", 474 "host_resolver_internal_result_test_util.cc", 475 "host_resolver_results_test_util.cc", 476 "mock_host_resolver.cc", 477 ] 478 public = [ 479 "dns_test_util.h", 480 "host_resolver_internal_result_test_util.h", 481 "host_resolver_results_test_util.h", 482 "mock_host_resolver.h", 483 ] 484 485 if (enable_mdns) { 486 sources += [ 487 "mock_mdns_client.cc", 488 "mock_mdns_socket_factory.cc", 489 ] 490 public += [ 491 "mock_mdns_client.h", 492 "mock_mdns_socket_factory.h", 493 ] 494 } 495 496 deps = [ 497 "//base", 498 "//net", 499 "//testing/gmock", 500 "//testing/gtest", 501 ] 502} 503 504if (use_fuzzing_engine) { 505 # fuzzer_test targets are no-op when |use_fuzzing_engine| is false. Fuzzer 506 # support targets should be disabled too. 507 source_set("fuzzer_test_support") { 508 testonly = true 509 sources = [ 510 "fuzzed_host_resolver_util.cc", 511 "fuzzed_host_resolver_util.h", 512 ] 513 deps = [ 514 "//base", 515 "//base/test:test_support", 516 "//net", 517 ] 518 } 519} 520 521proto_library("host_cache_fuzzer_proto") { 522 proto_in_dir = "//" 523 sources = [ "host_cache_fuzzer.proto" ] 524 deps = [ "//testing/libfuzzer/proto:json_proto" ] 525} 526 527fuzzer_test("net_dns_host_cache_fuzzer") { 528 sources = [ "host_cache_fuzzer.cc" ] 529 deps = [ 530 ":host_cache_fuzzer_proto", 531 "//base", 532 "//net", 533 "//net:net_fuzzer_test_support", 534 "//testing/libfuzzer/proto:json_proto", 535 "//testing/libfuzzer/proto:json_proto_converter", 536 "//third_party/libprotobuf-mutator", 537 ] 538 dict = "//testing/libfuzzer/fuzzers/dicts/json.dict" 539} 540 541fuzzer_test("net_dns_hosts_parse_fuzzer") { 542 sources = [ "dns_hosts_parse_fuzzer.cc" ] 543 deps = [ 544 "//base", 545 "//net", 546 "//net:net_fuzzer_test_support", 547 ] 548 dict = "//net/data/fuzzer_dictionaries/net_dns_hosts_parse_fuzzer.dict" 549} 550 551fuzzer_test("net_dns_host_resolver_cache_fuzzer") { 552 sources = [ "host_resolver_cache_fuzzer.cc" ] 553 deps = [ 554 "//base", 555 "//net", 556 "//net:net_fuzzer_test_support", 557 "//testing/libfuzzer/proto:json_proto", 558 "//testing/libfuzzer/proto:json_proto_converter", 559 "//third_party/libprotobuf-mutator", 560 ] 561} 562 563fuzzer_test("net_dns_https_record_rdata_fuzzer") { 564 sources = [ "https_record_rdata_fuzzer.cc" ] 565 deps = [ 566 "//base", 567 "//net", 568 "//net:net_fuzzer_test_support", 569 ] 570 dict = "//net/data/fuzzer_dictionaries/net_dns_record_fuzzer.dict" 571} 572 573fuzzer_test("net_dns_nsswitch_reader_fuzzer") { 574 sources = [ "nsswitch_reader_fuzzer.cc" ] 575 deps = [ 576 "//base", 577 "//net", 578 "//net:net_fuzzer_test_support", 579 ] 580 dict = "//net/data/fuzzer_dictionaries/net_dns_nsswitch_reader_fuzzer.dict" 581} 582 583fuzzer_test("net_dns_record_fuzzer") { 584 sources = [ "dns_record_fuzzer.cc" ] 585 deps = [ 586 "//base", 587 "//net", 588 "//net:net_fuzzer_test_support", 589 ] 590 dict = "//net/data/fuzzer_dictionaries/net_dns_record_fuzzer.dict" 591} 592 593fuzzer_test("net_dns_query_parse_fuzzer") { 594 sources = [ "dns_query_parse_fuzzer.cc" ] 595 deps = [ 596 "//base", 597 "//net", 598 "//net:net_fuzzer_test_support", 599 ] 600 dict = "//net/data/fuzzer_dictionaries/net_dns_record_fuzzer.dict" 601} 602 603fuzzer_test("net_dns_response_fuzzer") { 604 sources = [ "dns_response_fuzzer.cc" ] 605 deps = [ 606 "//base", 607 "//net", 608 "//net:net_fuzzer_test_support", 609 ] 610 dict = "//net/data/fuzzer_dictionaries/net_dns_record_fuzzer.dict" 611} 612 613fuzzer_test("net_host_resolver_manager_fuzzer") { 614 sources = [ "host_resolver_manager_fuzzer.cc" ] 615 deps = [ 616 "//base", 617 "//net", 618 "//net:net_fuzzer_test_support", 619 "//net:test_support", 620 ] 621 dict = "//net/data/fuzzer_dictionaries/net_host_resolver_manager_fuzzer.dict" 622 libfuzzer_options = [ "max_len=4096" ] 623} 624 625if (is_win) { 626 fuzzer_test("net_dns_parse_domain_ascii_win_fuzzer") { 627 sources = [ "dns_parse_domain_ascii_win_fuzzer.cc" ] 628 deps = [ 629 "//base", 630 "//net", 631 "//net:net_fuzzer_test_support", 632 ] 633 dict = "//net/data/fuzzer_dictionaries/net_dns_hosts_parse_fuzzer.dict" 634 seed_corpus = "//net/data/fuzzer_data/dns_parse_domain_ascii_win_fuzzer" 635 } 636} 637