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

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: 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>
(...skipping 26 matching lines...) Expand all
37 37
38 class DhcpProxyScriptFetcher; 38 class DhcpProxyScriptFetcher;
39 class HostResolver; 39 class HostResolver;
40 class ProxyDelegate; 40 class ProxyDelegate;
41 class ProxyResolver; 41 class ProxyResolver;
42 class ProxyResolverFactory; 42 class ProxyResolverFactory;
43 class ProxyResolverScriptData; 43 class ProxyResolverScriptData;
44 class ProxyScriptDecider; 44 class ProxyScriptDecider;
45 class ProxyScriptFetcher; 45 class ProxyScriptFetcher;
46 46
47 // Enumerates the policy to use when sanitizing URLs for proxy resolution
48 // (before passing them off to PAC scripts).
49 enum class SanitizeUrlForPacScriptPolicy {
50 // Do a basic level of sanitization for URLs:
51 // - strip embedded identities (ex: "username:password@")
52 // - strip the fragment (ex: "#blah")
53 //
54 // This is considered "unsafe" because it does not do any additional
55 // stripping for https:// URLs.
56 UNSAFE,
57
58 // SAFE does the same sanitization as UNSAFE, but additionally strips
59 // everything but the (scheme,host,port) from cryptographic URL schemes
60 // (https:// and wss://).
61 //
62 // In other words, it strips the path and query portion of https:// URLs.
63 SAFE,
64 };
65
66 // Returns a sanitized copy of |url| which is safe to pass on to a PAC script.
67 // The method for sanitizing is determined by |policy|. See the comments for
68 // that enum for details.
69 NET_EXPORT GURL SanitizeUrlForPacScript(const GURL& url,
mmenke 2016/05/19 22:33:23 Do you need to include gurl.h when returning a GUR
eroman 2016/05/19 23:26:05 Done.
70 SanitizeUrlForPacScriptPolicy policy);
mmenke 2016/05/19 22:33:24 Not a big fan of bonus enums and methods hanging o
eroman 2016/05/19 23:26:05 Done.
71
47 // This class can be used to resolve the proxy server to use when loading a 72 // 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 73 // HTTP(S) URL. It uses the given ProxyResolver to handle the actual proxy
49 // resolution. See ProxyResolverV8 for example. 74 // resolution. See ProxyResolverV8 for example.
50 class NET_EXPORT ProxyService : public NetworkChangeNotifier::IPAddressObserver, 75 class NET_EXPORT ProxyService : public NetworkChangeNotifier::IPAddressObserver,
51 public NetworkChangeNotifier::DNSObserver, 76 public NetworkChangeNotifier::DNSObserver,
52 public ProxyConfigService::Observer, 77 public ProxyConfigService::Observer,
53 NON_EXPORTED_BASE(public base::NonThreadSafe) { 78 NON_EXPORTED_BASE(public base::NonThreadSafe) {
54 public: 79 public:
55 static const size_t kDefaultNumPacThreads = 4; 80 static const size_t kDefaultNumPacThreads = 4;
56 81
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after
289 const PacPollPolicy* policy); 314 const PacPollPolicy* policy);
290 315
291 // This method should only be used by unit tests. Creates an instance 316 // This method should only be used by unit tests. Creates an instance
292 // of the default internal PacPollPolicy used by ProxyService. 317 // of the default internal PacPollPolicy used by ProxyService.
293 static std::unique_ptr<PacPollPolicy> CreateDefaultPacPollPolicy(); 318 static std::unique_ptr<PacPollPolicy> CreateDefaultPacPollPolicy();
294 319
295 void set_quick_check_enabled(bool value) { 320 void set_quick_check_enabled(bool value) {
296 quick_check_enabled_ = value; 321 quick_check_enabled_ = value;
297 } 322 }
298 323
324 void set_sanitize_url_for_pac_script_policy(
325 SanitizeUrlForPacScriptPolicy policy) {
326 sanitize_url_for_pac_script_policy_ = policy;
327 }
328
299 private: 329 private:
300 FRIEND_TEST_ALL_PREFIXES(ProxyServiceTest, UpdateConfigAfterFailedAutodetect); 330 FRIEND_TEST_ALL_PREFIXES(ProxyServiceTest, UpdateConfigAfterFailedAutodetect);
301 FRIEND_TEST_ALL_PREFIXES(ProxyServiceTest, UpdateConfigFromPACToDirect); 331 FRIEND_TEST_ALL_PREFIXES(ProxyServiceTest, UpdateConfigFromPACToDirect);
302 friend class PacRequest; 332 friend class PacRequest;
303 class InitProxyResolver; 333 class InitProxyResolver;
304 class ProxyScriptDeciderPoller; 334 class ProxyScriptDeciderPoller;
305 335
306 typedef std::set<scoped_refptr<PacRequest>> PendingRequests; 336 typedef std::set<scoped_refptr<PacRequest>> PendingRequests;
307 337
308 enum State { 338 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 483 // The earliest time at which we should run any proxy auto-config. (Used to
454 // stall re-configuration following an IP address change). 484 // stall re-configuration following an IP address change).
455 base::TimeTicks stall_proxy_autoconfig_until_; 485 base::TimeTicks stall_proxy_autoconfig_until_;
456 486
457 // The amount of time to stall requests following IP address changes. 487 // The amount of time to stall requests following IP address changes.
458 base::TimeDelta stall_proxy_auto_config_delay_; 488 base::TimeDelta stall_proxy_auto_config_delay_;
459 489
460 // Whether child ProxyScriptDeciders should use QuickCheck 490 // Whether child ProxyScriptDeciders should use QuickCheck
461 bool quick_check_enabled_; 491 bool quick_check_enabled_;
462 492
493 SanitizeUrlForPacScriptPolicy sanitize_url_for_pac_script_policy_ =
494 SanitizeUrlForPacScriptPolicy::SAFE;
mmenke 2016/05/19 22:33:23 nit: Seems weird to me to mix inline simple initi
495
463 DISALLOW_COPY_AND_ASSIGN(ProxyService); 496 DISALLOW_COPY_AND_ASSIGN(ProxyService);
464 }; 497 };
465 498
466 } // namespace net 499 } // namespace net
467 500
468 #endif // NET_PROXY_PROXY_SERVICE_H_ 501 #endif // NET_PROXY_PROXY_SERVICE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698