Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(248)

Side by Side Diff: net/proxy/proxy_service.h

Issue 1996773002: Sanitize https:// URLs before sending them to PAC scripts. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed Matt's feedback Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef NET_PROXY_PROXY_SERVICE_H_ 5 #ifndef NET_PROXY_PROXY_SERVICE_H_
6 #define NET_PROXY_PROXY_SERVICE_H_ 6 #define NET_PROXY_PROXY_SERVICE_H_
7 7
8 #include <stddef.h> 8 #include <stddef.h>
9 9
10 #include <memory> 10 #include <memory>
11 #include <set> 11 #include <set>
12 #include <string> 12 #include <string>
13 #include <vector> 13 #include <vector>
14 14
15 #include "base/gtest_prod_util.h" 15 #include "base/gtest_prod_util.h"
16 #include "base/macros.h" 16 #include "base/macros.h"
17 #include "base/memory/ref_counted.h" 17 #include "base/memory/ref_counted.h"
18 #include "base/synchronization/waitable_event.h" 18 #include "base/synchronization/waitable_event.h"
19 #include "base/threading/non_thread_safe.h" 19 #include "base/threading/non_thread_safe.h"
20 #include "net/base/completion_callback.h" 20 #include "net/base/completion_callback.h"
21 #include "net/base/load_states.h" 21 #include "net/base/load_states.h"
22 #include "net/base/net_export.h" 22 #include "net/base/net_export.h"
23 #include "net/base/network_change_notifier.h" 23 #include "net/base/network_change_notifier.h"
24 #include "net/log/net_log.h" 24 #include "net/log/net_log.h"
25 #include "net/proxy/proxy_config_service.h" 25 #include "net/proxy/proxy_config_service.h"
26 #include "net/proxy/proxy_info.h" 26 #include "net/proxy/proxy_info.h"
27 #include "net/proxy/proxy_server.h" 27 #include "net/proxy/proxy_server.h"
28 #include "url/gurl.h"
28 29
29 class GURL; 30 class GURL;
30 31
31 namespace base { 32 namespace base {
32 class SingleThreadTaskRunner; 33 class SingleThreadTaskRunner;
33 class TimeDelta; 34 class TimeDelta;
34 } // namespace base 35 } // namespace base
35 36
36 namespace net { 37 namespace net {
37 38
38 class DhcpProxyScriptFetcher; 39 class DhcpProxyScriptFetcher;
39 class HostResolver; 40 class HostResolver;
40 class ProxyDelegate; 41 class ProxyDelegate;
41 class ProxyResolver; 42 class ProxyResolver;
42 class ProxyResolverFactory; 43 class ProxyResolverFactory;
43 class ProxyResolverScriptData; 44 class ProxyResolverScriptData;
44 class ProxyScriptDecider; 45 class ProxyScriptDecider;
45 class ProxyScriptFetcher; 46 class ProxyScriptFetcher;
46 47
47 // This class can be used to resolve the proxy server to use when loading a 48 // This class can be used to resolve the proxy server to use when loading a
48 // HTTP(S) URL. It uses the given ProxyResolver to handle the actual proxy 49 // HTTP(S) URL. It uses the given ProxyResolver to handle the actual proxy
49 // resolution. See ProxyResolverV8 for example. 50 // resolution. See ProxyResolverV8 for example.
50 class NET_EXPORT ProxyService : public NetworkChangeNotifier::IPAddressObserver, 51 class NET_EXPORT ProxyService : public NetworkChangeNotifier::IPAddressObserver,
51 public NetworkChangeNotifier::DNSObserver, 52 public NetworkChangeNotifier::DNSObserver,
52 public ProxyConfigService::Observer, 53 public ProxyConfigService::Observer,
53 NON_EXPORTED_BASE(public base::NonThreadSafe) { 54 NON_EXPORTED_BASE(public base::NonThreadSafe) {
54 public: 55 public:
56 // Enumerates the policy to use when sanitizing URLs for proxy resolution
57 // (before passing them off to PAC scripts).
58 enum class SanitizeUrlPolicy {
59 // Do a basic level of sanitization for URLs:
60 // - strip embedded identities (ex: "username:password@")
61 // - strip the fragment (ex: "#blah")
62 //
63 // This is considered "unsafe" because it does not do any additional
64 // stripping for https:// URLs.
65 UNSAFE,
66
67 // SAFE does the same sanitization as UNSAFE, but additionally strips
68 // everything but the (scheme,host,port) from cryptographic URL schemes
69 // (https:// and wss://).
70 //
71 // In other words, it strips the path and query portion of https:// URLs.
72 SAFE,
73 };
74
55 static const size_t kDefaultNumPacThreads = 4; 75 static const size_t kDefaultNumPacThreads = 4;
56 76
57 // This interface defines the set of policies for when to poll the PAC 77 // This interface defines the set of policies for when to poll the PAC
58 // script for changes. 78 // script for changes.
59 // 79 //
60 // The polling policy decides what the next poll delay should be in 80 // The polling policy decides what the next poll delay should be in
61 // milliseconds. It also decides how to wait for this delay -- either 81 // milliseconds. It also decides how to wait for this delay -- either
62 // by starting a timer to do the poll at exactly |next_delay_ms| 82 // by starting a timer to do the poll at exactly |next_delay_ms|
63 // (MODE_USE_TIMER) or by waiting for the first network request issued after 83 // (MODE_USE_TIMER) or by waiting for the first network request issued after
64 // |next_delay_ms| (MODE_START_AFTER_ACTIVITY). 84 // |next_delay_ms| (MODE_START_AFTER_ACTIVITY).
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after
289 const PacPollPolicy* policy); 309 const PacPollPolicy* policy);
290 310
291 // This method should only be used by unit tests. Creates an instance 311 // This method should only be used by unit tests. Creates an instance
292 // of the default internal PacPollPolicy used by ProxyService. 312 // of the default internal PacPollPolicy used by ProxyService.
293 static std::unique_ptr<PacPollPolicy> CreateDefaultPacPollPolicy(); 313 static std::unique_ptr<PacPollPolicy> CreateDefaultPacPollPolicy();
294 314
295 void set_quick_check_enabled(bool value) { 315 void set_quick_check_enabled(bool value) {
296 quick_check_enabled_ = value; 316 quick_check_enabled_ = value;
297 } 317 }
298 318
319 void set_sanitize_url_policy(SanitizeUrlPolicy policy) {
320 sanitize_url_policy_ = policy;
321 }
322
323 // Returns a sanitized copy of |url| which is safe to pass on to a PAC script.
324 // The method for sanitizing is determined by |policy|. See the comments for
325 // that enum for details.
326 NET_EXPORT static GURL SanitizeUrl(const GURL& url, SanitizeUrlPolicy policy);
mmenke 2016/05/20 17:40:23 Should this be NET_EXPORT_PRIVATE? Not really con
eroman 2016/05/20 21:23:53 No longer applicable, as I moved the function to b
327
299 private: 328 private:
300 FRIEND_TEST_ALL_PREFIXES(ProxyServiceTest, UpdateConfigAfterFailedAutodetect); 329 FRIEND_TEST_ALL_PREFIXES(ProxyServiceTest, UpdateConfigAfterFailedAutodetect);
301 FRIEND_TEST_ALL_PREFIXES(ProxyServiceTest, UpdateConfigFromPACToDirect); 330 FRIEND_TEST_ALL_PREFIXES(ProxyServiceTest, UpdateConfigFromPACToDirect);
302 friend class PacRequest; 331 friend class PacRequest;
303 class InitProxyResolver; 332 class InitProxyResolver;
304 class ProxyScriptDeciderPoller; 333 class ProxyScriptDeciderPoller;
305 334
306 typedef std::set<scoped_refptr<PacRequest>> PendingRequests; 335 typedef std::set<scoped_refptr<PacRequest>> PendingRequests;
307 336
308 enum State { 337 enum State {
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
453 // The earliest time at which we should run any proxy auto-config. (Used to 482 // The earliest time at which we should run any proxy auto-config. (Used to
454 // stall re-configuration following an IP address change). 483 // stall re-configuration following an IP address change).
455 base::TimeTicks stall_proxy_autoconfig_until_; 484 base::TimeTicks stall_proxy_autoconfig_until_;
456 485
457 // The amount of time to stall requests following IP address changes. 486 // The amount of time to stall requests following IP address changes.
458 base::TimeDelta stall_proxy_auto_config_delay_; 487 base::TimeDelta stall_proxy_auto_config_delay_;
459 488
460 // Whether child ProxyScriptDeciders should use QuickCheck 489 // Whether child ProxyScriptDeciders should use QuickCheck
461 bool quick_check_enabled_; 490 bool quick_check_enabled_;
462 491
492 // The method to use for sanitizing URLs seen by the proxy resolver.
493 SanitizeUrlPolicy sanitize_url_policy_;
494
463 DISALLOW_COPY_AND_ASSIGN(ProxyService); 495 DISALLOW_COPY_AND_ASSIGN(ProxyService);
464 }; 496 };
465 497
466 } // namespace net 498 } // namespace net
467 499
468 #endif // NET_PROXY_PROXY_SERVICE_H_ 500 #endif // NET_PROXY_PROXY_SERVICE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698