safe_browsing-disable-reporting-of-safebrowsing-over.patch 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. From 8f348bf2c249701de2f6049ac57fe346bd6b665f Mon Sep 17 00:00:00 2001
  2. From: Joachim Bauch <jojo@struktur.de>
  3. Date: Tue, 7 Jul 2015 18:28:46 +0200
  4. Subject: [PATCH 48/66] safe_browsing: disable reporting of safebrowsing
  5. override
  6. Disables reporting of the safebrowsing override, i.e. the report sent
  7. if a user decides to visit a page that was flagged as "insecure".
  8. This prevents trk:148 (phishing) and trk:149 (malware).
  9. ---
  10. .../browser/safe_browsing/client_side_detection_service.cc | 12 ++++++++++++
  11. 1 file changed, 12 insertions(+)
  12. --- a/chrome/browser/safe_browsing/client_side_detection_service.cc
  13. +++ b/chrome/browser/safe_browsing/client_side_detection_service.cc
  14. @@ -221,99 +221,8 @@ void ClientSideDetectionService::StartCl
  15. DCHECK_CURRENTLY_ON(BrowserThread::UI);
  16. std::unique_ptr<ClientPhishingRequest> request(verdict);
  17. - if (!enabled_) {
  18. - if (!callback.is_null())
  19. - callback.Run(GURL(request->url()), false);
  20. - return;
  21. - }
  22. -
  23. - // Fill in metadata about which model we used.
  24. - if (is_extended_reporting || is_enhanced_reporting) {
  25. - request->set_model_filename(model_loader_extended_->name());
  26. - if (is_enhanced_reporting) {
  27. - request->mutable_population()->set_user_population(
  28. - ChromeUserPopulation::ENHANCED_PROTECTION);
  29. - } else {
  30. - request->mutable_population()->set_user_population(
  31. - ChromeUserPopulation::EXTENDED_REPORTING);
  32. - }
  33. - } else {
  34. - request->set_model_filename(model_loader_standard_->name());
  35. - request->mutable_population()->set_user_population(
  36. - ChromeUserPopulation::SAFE_BROWSING);
  37. - }
  38. - DVLOG(2) << "Starting report for hit on model " << request->model_filename();
  39. -
  40. - request->mutable_population()->set_profile_management_status(
  41. - GetProfileManagementStatus(
  42. - g_browser_process->browser_policy_connector()));
  43. -
  44. - std::string request_data;
  45. - if (!request->SerializeToString(&request_data)) {
  46. - UMA_HISTOGRAM_COUNTS_1M("SBClientPhishing.RequestNotSerialized", 1);
  47. - DVLOG(1) << "Unable to serialize the CSD request. Proto file changed?";
  48. - if (!callback.is_null())
  49. - callback.Run(GURL(request->url()), false);
  50. - return;
  51. - }
  52. -
  53. - net::NetworkTrafficAnnotationTag traffic_annotation =
  54. - net::DefineNetworkTrafficAnnotation(
  55. - "safe_browsing_client_side_phishing_detector", R"(
  56. - semantics {
  57. - sender: "Safe Browsing Client-Side Phishing Detector"
  58. - description:
  59. - "If the client-side phishing detector determines that the "
  60. - "current page contents are similar to phishing pages, it will "
  61. - "send a request to Safe Browsing to ask for a final verdict. If "
  62. - "Safe Browsing agrees the page is dangerous, Chrome will show a "
  63. - "full-page interstitial warning."
  64. - trigger:
  65. - "Whenever the clinet-side detector machine learning model "
  66. - "computes a phishy-ness score above a threshold, after page-load."
  67. - data:
  68. - "Top-level page URL without CGI parameters, boolean and double "
  69. - "features extracted from DOM, such as the number of resources "
  70. - "loaded in the page, if certain likely phishing and social "
  71. - "engineering terms found on the page, etc."
  72. - destination: GOOGLE_OWNED_SERVICE
  73. - }
  74. - policy {
  75. - cookies_allowed: YES
  76. - cookies_store: "Safe browsing cookie store"
  77. - setting:
  78. - "Users can enable or disable this feature by toggling 'Protect "
  79. - "you and your device from dangerous sites' in Chrome settings "
  80. - "under Privacy. This feature is enabled by default."
  81. - chrome_policy {
  82. - SafeBrowsingEnabled {
  83. - policy_options {mode: MANDATORY}
  84. - SafeBrowsingEnabled: false
  85. - }
  86. - }
  87. - })");
  88. - auto resource_request = std::make_unique<network::ResourceRequest>();
  89. - resource_request->url = GetClientReportUrl(kClientReportPhishingUrl);
  90. - resource_request->method = "POST";
  91. - resource_request->load_flags = net::LOAD_DISABLE_CACHE;
  92. - auto loader = network::SimpleURLLoader::Create(std::move(resource_request),
  93. - traffic_annotation);
  94. - loader->AttachStringForUpload(request_data, "application/octet-stream");
  95. - loader->DownloadToStringOfUnboundedSizeUntilCrashAndDie(
  96. - url_loader_factory_.get(),
  97. - base::BindOnce(&ClientSideDetectionService::OnURLLoaderComplete,
  98. - base::Unretained(this), loader.get()));
  99. -
  100. - // Remember which callback and URL correspond to the current fetcher object.
  101. - std::unique_ptr<ClientPhishingReportInfo> info(new ClientPhishingReportInfo);
  102. - auto* loader_ptr = loader.get();
  103. - info->loader = std::move(loader);
  104. - info->callback = callback;
  105. - info->phishing_url = GURL(request->url());
  106. - client_phishing_reports_[loader_ptr] = std::move(info);
  107. -
  108. - // Record that we made a request
  109. - phishing_report_times_.push(base::Time::Now());
  110. + if (!callback.is_null())
  111. + callback.Run(GURL(request->url()), false);
  112. }
  113. void ClientSideDetectionService::HandlePhishingVerdict(