blob: 571d0cdc71082ccd91734b07d1718d8d452403de [file] [log] [blame]
Eric Orth24feb5b2018-05-25 19:42:461# Copyright 2018 The Chromium Authors. All rights reserved.
2# Use of this source code is governed by a BSD-style license that can be
Yngve N. Pettersend5a75172018-07-09 06:36:563# found in the LICENSE file.
Eric Orth24feb5b2018-05-25 19:42:464
5import("//testing/libfuzzer/fuzzer_test.gni")
6import("//net/features.gni")
7
8enable_built_in_dns = !is_ios && !is_proto_quic
9
10source_set("dns") {
11 # Due to circular dependencies, should only be depended on through //net.
12 visibility = [ "//net" ]
13
14 # Internals only intended for use inside network stack (and tests).
15 friend = [
16 "//chrome/browser:test_support",
17 "//chrome/test/*",
18 "//components/certificate_transparency:unit_tests",
19 "//components/cronet/*",
20 "//net/*",
21 "//services/network/*",
22 ]
23
24 public = []
25 sources = [
26 "dns_util.cc",
27 "dns_util.h",
28 ]
29
30 if (!is_nacl) {
31 sources += [
32 "address_sorter.h",
33 "address_sorter_win.cc",
Eric Orth6432c1a82018-10-02 15:10:2534 "dns_config.cc",
Eric Orthc1eb1292018-10-09 22:07:0735 "dns_config_overrides.cc",
Eric Orth24feb5b2018-05-25 19:42:4636 "dns_config_service.cc",
Eric Orth6432c1a82018-10-02 15:10:2537 "dns_config_service.h",
Eric Orth24feb5b2018-05-25 19:42:4638 "dns_config_service_win.cc",
39 "dns_config_service_win.h",
40 "dns_config_watcher_mac.cc",
41 "dns_config_watcher_mac.h",
42 "dns_hosts.cc",
43 "dns_hosts.h",
44 "dns_query.cc",
45 "dns_query.h",
46 "dns_reloader.cc",
47 "dns_reloader.h",
48 "dns_response.cc",
49 "dns_session.cc",
50 "dns_session.h",
51 "dns_socket_pool.cc",
52 "dns_socket_pool.h",
53 "dns_transaction.cc",
54 "host_cache.cc",
55 "host_resolver.cc",
56 "host_resolver_impl.cc",
Eric Orth9871aafa2018-10-02 19:59:1857 "host_resolver_mdns_task.cc",
58 "host_resolver_mdns_task.h",
Eric Orth24feb5b2018-05-25 19:42:4659 "host_resolver_proc.cc",
60 "host_resolver_proc.h",
Eric Orthdc35748e2018-08-23 22:41:4861 "host_resolver_source.h",
Eric Orth24feb5b2018-05-25 19:42:4662 "mapped_host_resolver.cc",
63 "notify_watcher_mac.cc",
64 "notify_watcher_mac.h",
65 "record_parsed.cc",
66 "record_rdata.cc",
67 "serial_worker.cc",
68 "serial_worker.h",
69 ]
70
71 if (is_posix || is_fuchsia) {
72 sources += [ "dns_config_service_posix.cc" ]
73
74 if (enable_built_in_dns) {
75 sources += [
76 "address_sorter_posix.cc",
77 "address_sorter_posix.h",
78 ]
79 }
80 }
81
82 if (enable_built_in_dns) {
83 sources += [ "dns_client.cc" ]
84 }
85
86 if (enable_mdns) {
87 sources += [
88 "mdns_cache.cc",
89 "mdns_cache.h",
90 "mdns_client.cc",
91 "mdns_client_impl.cc",
92 "mdns_client_impl.h",
93 ]
94 }
95 }
96
97 deps = [
98 "//net:net_deps",
99 ]
100
101 public_deps = [
102 ":dns_client",
Eric Orth168a7e52018-08-27 19:11:32103 ":host_resolver",
Eric Orth24feb5b2018-05-25 19:42:46104 ":host_resolver_impl",
105 ":mdns_client",
Eric Orth24feb5b2018-05-25 19:42:46106 "//net:net_public_deps",
107 ]
108
109 allow_circular_includes_from = [
110 ":dns_client",
Eric Orth168a7e52018-08-27 19:11:32111 ":host_resolver",
Eric Orth24feb5b2018-05-25 19:42:46112 ":host_resolver_impl",
113 ":mdns_client",
Eric Orth24feb5b2018-05-25 19:42:46114 ]
115}
116
Eric Orth168a7e52018-08-27 19:11:32117# The standard API of net/dns.
118#
119# Should typically only be used within the network service. Usage external to
120# the network service should instead use network service Mojo IPCs for host
121# resolution. See ResolveHost() in
122# /services/network/public/mojom/network_context.mojom and
123# /services/network/public/mojom/host_resolver.mojom.
124source_set("host_resolver") {
Eric Orth24feb5b2018-05-25 19:42:46125 # Due to circular dependencies, should only be depended on through //net.
126 # Limit visibility to //net and other source_sets with the same access
127 # restriction.
128 visibility = [
129 ":dns",
Eric Orth24feb5b2018-05-25 19:42:46130 ":host_resolver_impl",
131 ":mdns_client",
132 "//net",
133 ]
134
Eric Orth168a7e52018-08-27 19:11:32135 # Whitelist-only access so we can keep track of all usage external to the
136 # network stack and network service.
137 friend = [
Eric Orth168a7e52018-08-27 19:11:32138 # chrome/browser/io_thread.cc
139 # Used to build in-process HostResolver when network service disabled.
140 #
141 # chrome/browser/net/dns_probe_service.cc
142 # TODO(crbug.com/874660): Remove once migrated to network service IPC.
Eric Orth168a7e52018-08-27 19:11:32143 "//chrome/browser",
144
Eric Orth168a7e52018-08-27 19:11:32145 # chromecast/browser/url_request_context_factory.cc
146 # URLRequestContext creation for chromecast.
147 "//chromecast/browser",
148
Eric Orth168a7e52018-08-27 19:11:32149 # URLRequestContext and HttpNetworkSession::Context creation for iOS.
150 "//ios/components/io_thread",
151 "//ios/web/shell",
152 "//ios/web_view:*",
153
154 # Tests and test support.
155 "//chrome/browser:test_support",
156 "//chrome/test:browser_tests",
Eric Orth1556c382018-11-08 06:05:02157 "//chrome/test:unit_tests",
Eric Orth168a7e52018-08-27 19:11:32158 "//components/grpc_support/test:unit_tests",
159 "//content/shell:content_shell_lib",
160
161 # Stand-alone tools.
162 "//components/sync/tools:*",
163 "//google_apis/gcm:mcs_probe",
164
165 # Network stack/service.
166 "//components/certificate_transparency/*",
167 "//components/cronet/*",
168 "//net/*",
169 "//services/network/*",
Matt Menked60f16ec2018-11-07 20:18:26170
171 # The proxy resolution service uses its own host cache and HostResolver Mojo
172 # wrapper.
173 "//services/proxy_resolver/*",
Eric Orth168a7e52018-08-27 19:11:32174 ]
175
Eric Orth24feb5b2018-05-25 19:42:46176 sources = []
177 public = []
178
179 if (!is_nacl) {
Eric Orth168a7e52018-08-27 19:11:32180 sources += [
Eric Orth6432c1a82018-10-02 15:10:25181 "dns_config.h",
Eric Orthc1eb1292018-10-09 22:07:07182 "dns_config_overrides.h",
Eric Orth24feb5b2018-05-25 19:42:46183 "host_cache.h",
184 "host_resolver.h",
185 "mapped_host_resolver.h",
186 ]
187 }
188
189 deps = [
190 "//net:net_deps",
191 ]
192 public_deps = [
193 "//net:net_public_deps",
194 ]
195}
196
197# Overridable implementation details of HostResolver.
Eric Orth24feb5b2018-05-25 19:42:46198source_set("host_resolver_impl") {
199 # Due to circular dependencies, should only be depended on through //net.
200 # Limit visibility to //net and other source_sets with the same access
201 # restriction.
202 visibility = [
203 ":dns",
Eric Orth24feb5b2018-05-25 19:42:46204 "//net",
205 ]
206
207 # Whitelist-only access so we can keep track of all usage external to the
208 # network stack.
209 friend = [
Eric Orth1556c382018-11-08 06:05:02210 # chromeos/network/network_change_notifier_chromeos.cc
211 # ChromeOS-specific change notifier with some overrides for DnsConfigService
212 # TODO(crbug.com/882610): Remove/cleanup once we figure out servicification.
213 #
214 # chromeos/network/host_resolver_impl_chromeos.h
215 # ChromeOS-specific overriding implementation of HostResolverImpl.
216 # TODO(crbug.com/827533): Remove once converted to use network service.
A Olsen37962d2e2018-10-12 15:05:18217 "//chromeos/network",
Eric Orth1556c382018-11-08 06:05:02218
219 # Network stack/service
Eric Orth24feb5b2018-05-25 19:42:46220 "//components/cronet/*",
221 "//net/*",
Eric Orthe366fe62018-10-24 16:38:31222 "//services/network:tests",
Eric Orth24feb5b2018-05-25 19:42:46223 ]
224
225 sources = []
226 public = []
227
228 if (!is_nacl) {
229 sources += [ "host_resolver_impl.h" ]
230
231 if (is_posix || is_fuchsia) {
232 sources += [ "dns_config_service_posix.h" ]
233 }
234 }
235
236 deps = [
Eric Orth168a7e52018-08-27 19:11:32237 ":host_resolver",
Eric Orth24feb5b2018-05-25 19:42:46238 "//net:net_deps",
239 ]
240 public_deps = [
241 "//net:net_public_deps",
242 ]
243}
244
Eric Orth1556c382018-11-08 06:05:02245# DnsClient interfaces. Primarily intended as part of the implementation of the
Eric Orth24feb5b2018-05-25 19:42:46246# standard HostResolver interface, but can be used as an alternative external
247# interface for advanced usage.
Eric Orth24feb5b2018-05-25 19:42:46248source_set("dns_client") {
249 # Due to circular dependencies, should only be depended on through //net.
250 # Limit visibility to //net and other source_sets with the same access
251 # restriction.
252 visibility = [
253 ":dns",
254 ":mdns_client",
255 "//net",
256 ]
257
258 # Whitelist-only access so we can keep track of all usage external to the
259 # network stack.
260 friend = [
Eric Orth1556c382018-11-08 06:05:02261 # chrome/browser/local_discovery/service_discovery_client_impl.cc
262 # Result parsing utilities for parsing results read through MdnsClient.
263 # TODO(crbug.com/874662): Remove once migrated to network service.
264 #
265 # chrome/browser/net/dns_probe_runner.cc
266 # chrome/browser/net/dns_probe_service.cc
267 # DNS lookups using DnsClient.
268 # TODO(crbug.com/874660): Remove once migrated to network service.
Eric Orth24feb5b2018-05-25 19:42:46269 "//chrome/browser",
Eric Orth1556c382018-11-08 06:05:02270
271 # chrome/browser/chromeos/smb_client/discovery/mdns_host_locator.cc
272 # Result parsing for results read through MdnsClient.
273 # TODO(crbug.com/902531): Remove once migrated to network service.
Eric Orth24feb5b2018-05-25 19:42:46274 "//chrome/browser/chromeos",
Eric Orth1556c382018-11-08 06:05:02275
276 # Tests and test support
277 "//chrome/browser:test_support",
Eric Orth24feb5b2018-05-25 19:42:46278 "//chrome/test/*",
Eric Orth1556c382018-11-08 06:05:02279
280 # Network stack/service
Eric Orth24feb5b2018-05-25 19:42:46281 "//components/certificate_transparency/*",
282 "//net/*",
Eric Orth168a7e52018-08-27 19:11:32283 "//services/network/*",
Eric Orth24feb5b2018-05-25 19:42:46284 ]
285
286 sources = []
287 public = []
288
289 if (!is_nacl) {
290 sources += [
291 "dns_client.h",
292 "dns_response.h",
293 "dns_transaction.h",
294 "record_parsed.h",
295 "record_rdata.h",
296 ]
297 }
298
299 deps = [
Eric Orth24feb5b2018-05-25 19:42:46300 "//net:net_deps",
301 ]
302 public_deps = [
303 "//net:net_public_deps",
Eric Orth8afaf152018-11-07 21:01:26304 "//net/dns/public",
Eric Orth24feb5b2018-05-25 19:42:46305 ]
306}
307
308# MdnsClient interfaces.
Eric Orth24feb5b2018-05-25 19:42:46309source_set("mdns_client") {
310 # Due to circular dependencies, should only be depended on through //net.
311 # Limit visibility to //net and other source_sets with the same access
312 # restriction.
313 visibility = [
314 ":dns",
315 "//net",
316 ]
317
318 # Whitelist-only access so we can keep track of all usage external to the
319 # network stack.
320 friend = [
Eric Orth1556c382018-11-08 06:05:02321 # chrome/browser/local_discovery/service_discovery_client_mdns.h
322 # chrome/browser/local_discovery/service_discovery_client_impl.h
323 # Makes MDNS queries using MDnsClient.
324 # TODO(crbug.com/874662): Remove once migrated to network service.
Eric Orth24feb5b2018-05-25 19:42:46325 "//chrome/browser",
Eric Orth1556c382018-11-08 06:05:02326
327 # chrome/tools/service_discovery_sniffer/service_discovery_sniffer.cc
328 # Creates MDnsClient instance and passes to ServiceDiscoveryClientImpl.
329 # TODO(crbug.com/874662): Remove once discovery client migrated.
Eric Orth24feb5b2018-05-25 19:42:46330 "//chrome/tools/service_discovery_sniffer",
Eric Orth1556c382018-11-08 06:05:02331
332 # chrome/browser/chromeos/smb_client/discovery/mdns_host_locator.h
333 # chrome/browser/chromeos/smb_client/discovery/mdns_host_locator.cc
334 # Makes MDNS queries using MDnsClient.
335 # TODO(crbug.com/902531): Remove once migrated to network service.
336 "//chrome/browser/chromeos",
337
338 # Tests and test support
339 "//chrome/browser:test_support",
340
341 # Network stack/service
Eric Orth24feb5b2018-05-25 19:42:46342 "//net/*",
Qingsi Wangc2213d5d2018-11-02 01:28:12343 "//services/network/*",
Eric Orth24feb5b2018-05-25 19:42:46344 ]
345
346 public = []
347 sources = []
348
349 if (!is_nacl && enable_mdns) {
350 sources += [ "mdns_client.h" ]
351 }
352
353 deps = [
354 ":dns_client",
Eric Orth168a7e52018-08-27 19:11:32355 ":host_resolver",
Eric Orth24feb5b2018-05-25 19:42:46356 "//net:net_deps",
357 ]
358 public_deps = [
359 "//net:net_public_deps",
360 ]
361}
362
Eric Orth24feb5b2018-05-25 19:42:46363source_set("tests") {
364 testonly = true
365 sources = [
366 "dns_config_service_unittest.cc",
367 "dns_config_service_win_unittest.cc",
368 "dns_hosts_unittest.cc",
369 "dns_query_unittest.cc",
370 "dns_response_unittest.cc",
371 "dns_session_unittest.cc",
372 "dns_socket_pool_unittest.cc",
373 "dns_transaction_unittest.cc",
374 "dns_util_unittest.cc",
375 "host_cache_unittest.cc",
376 "host_resolver_impl_unittest.cc",
377 "mapped_host_resolver_unittest.cc",
378 "record_parsed_unittest.cc",
379 "record_rdata_unittest.cc",
380 "serial_worker_unittest.cc",
381 ]
382
383 if (is_posix || is_fuchsia) {
384 sources += [ "dns_config_service_posix_unittest.cc" ]
385 }
386
387 if (enable_built_in_dns) {
388 sources += [ "address_sorter_unittest.cc" ]
389 if (is_posix || is_fuchsia) {
390 sources += [ "address_sorter_posix_unittest.cc" ]
391 }
392 }
393
Eric Orth24feb5b2018-05-25 19:42:46394 if (enable_mdns) {
395 sources += [
396 "mdns_cache_unittest.cc",
397 "mdns_client_unittest.cc",
398 ]
399 }
400
401 deps = [
402 "//base",
403 "//net",
404 "//net:test_support",
405 "//testing/gmock",
406 "//testing/gtest",
407 ]
Eric Orth24feb5b2018-05-25 19:42:46408}
409
410source_set("test_support") {
411 testonly = true
412 sources = [
413 "dns_test_util.cc",
414 "mock_host_resolver.cc",
415 ]
416 public = [
417 "dns_test_util.h",
418 "mock_host_resolver.h",
419 ]
420
421 if (enable_mdns) {
Eric Orth9871aafa2018-10-02 19:59:18422 sources += [
423 "mock_mdns_client.cc",
424 "mock_mdns_socket_factory.cc",
425 ]
426 public += [
427 "mock_mdns_client.h",
428 "mock_mdns_socket_factory.h",
429 ]
Eric Orth24feb5b2018-05-25 19:42:46430 }
431
432 deps = [
433 "//base",
434 "//net",
435 "//testing/gmock",
436 "//testing/gtest",
437 ]
438}
439
440source_set("fuzzer_test_support") {
441 testonly = true
442 sources = [
443 "fuzzed_host_resolver.cc",
444 "fuzzed_host_resolver.h",
445 ]
446 deps = [
447 "//base",
448 "//base/test:test_support",
449 "//net",
450 ]
451}
452
453fuzzer_test("net_dns_hosts_parse_fuzzer") {
454 sources = [
455 "dns_hosts_parse_fuzzer.cc",
456 ]
457 deps = [
458 "//base",
459 "//net",
460 "//net:net_fuzzer_test_support",
461 ]
462 dict = "//net/data/fuzzer_dictionaries/net_dns_hosts_parse_fuzzer.dict"
463}
464
465fuzzer_test("net_dns_record_fuzzer") {
466 sources = [
467 "dns_record_fuzzer.cc",
468 ]
469 deps = [
470 "//base",
471 "//net",
472 "//net:net_fuzzer_test_support",
473 ]
474 dict = "//net/data/fuzzer_dictionaries/net_dns_record_fuzzer.dict"
475}
476
Qingsi Wangecd69252018-09-27 21:35:55477fuzzer_test("net_dns_query_parse_fuzzer") {
478 sources = [
479 "dns_query_parse_fuzzer.cc",
480 ]
481 deps = [
482 "//base",
483 "//net",
484 "//net:net_fuzzer_test_support",
485 ]
486 dict = "//net/data/fuzzer_dictionaries/net_dns_record_fuzzer.dict"
487}
488
Qingsi Wang65841072018-10-09 01:14:45489fuzzer_test("net_dns_response_fuzzer") {
490 sources = [
491 "dns_response_fuzzer.cc",
492 ]
493 deps = [
494 "//base",
495 "//net",
496 "//net:net_fuzzer_test_support",
497 ]
498 dict = "//net/data/fuzzer_dictionaries/net_dns_record_fuzzer.dict"
499}
500
Eric Orth24feb5b2018-05-25 19:42:46501fuzzer_test("net_host_resolver_impl_fuzzer") {
502 sources = [
503 "host_resolver_impl_fuzzer.cc",
504 ]
505 deps = [
506 "//base",
507 "//net",
508 "//net:net_fuzzer_test_support",
509 "//net:test_support",
510 ]
511 dict = "//net/data/fuzzer_dictionaries/net_host_resolver_impl_fuzzer.dict"
512}