| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 // This file should not be build on Android but is currently getting built. | 5 // This file should not be build on Android but is currently getting built. |
| 6 // TODO(vakh): Fix that: http://crbug.com/621647 | 6 // TODO(vakh): Fix that: http://crbug.com/621647 |
| 7 | 7 |
| 8 #include "components/safe_browsing_db/v4_local_database_manager.h" | 8 #include "components/safe_browsing_db/v4_local_database_manager.h" |
| 9 | 9 |
| 10 #include <vector> | 10 #include <vector> |
| 11 | 11 |
| 12 #include "base/bind_helpers.h" | 12 #include "base/bind_helpers.h" |
| 13 #include "base/callback.h" | 13 #include "base/callback.h" |
| 14 #include "base/memory/ptr_util.h" | 14 #include "base/memory/ptr_util.h" |
| 15 #include "base/memory/ref_counted.h" | 15 #include "base/memory/ref_counted.h" |
| 16 #include "base/metrics/histogram_macros.h" | 16 #include "base/metrics/histogram_macros.h" |
| 17 #include "components/safe_browsing_db/v4_feature_list.h" | 17 #include "components/safe_browsing_db/v4_feature_list.h" |
| 18 #include "components/safe_browsing_db/v4_protocol_manager_util.h" | 18 #include "components/safe_browsing_db/v4_protocol_manager_util.h" |
| 19 #include "content/public/browser/browser_thread.h" | 19 #include "content/public/browser/browser_thread.h" |
| 20 #include "crypto/sha2.h" |
| 20 | 21 |
| 21 using content::BrowserThread; | 22 using content::BrowserThread; |
| 22 using base::TimeTicks; | 23 using base::TimeTicks; |
| 23 | 24 |
| 24 namespace safe_browsing { | 25 namespace safe_browsing { |
| 25 | 26 |
| 26 namespace { | 27 namespace { |
| 27 | 28 |
| 28 const ThreatSeverity kLeastSeverity = | 29 const ThreatSeverity kLeastSeverity = |
| 29 std::numeric_limits<ThreatSeverity>::max(); | 30 std::numeric_limits<ThreatSeverity>::max(); |
| (...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 297 if (!V4ProtocolManagerUtil::IPAddressToEncodedIPV6Hash(ip_address, | 298 if (!V4ProtocolManagerUtil::IPAddressToEncodedIPV6Hash(ip_address, |
| 298 &hashed_encoded_ip)) { | 299 &hashed_encoded_ip)) { |
| 299 return false; | 300 return false; |
| 300 } | 301 } |
| 301 | 302 |
| 302 return HandleHashSynchronously(hashed_encoded_ip, | 303 return HandleHashSynchronously(hashed_encoded_ip, |
| 303 StoresToCheck({GetIpMalwareId()})); | 304 StoresToCheck({GetIpMalwareId()})); |
| 304 } | 305 } |
| 305 | 306 |
| 306 bool V4LocalDatabaseManager::MatchModuleWhitelistString( | 307 bool V4LocalDatabaseManager::MatchModuleWhitelistString( |
| 307 const std::string& str) { | 308 const std::string& module_filename) { |
| 308 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 309 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 309 | |
| 310 if (!enabled_ || !v4_database_) { | 310 if (!enabled_ || !v4_database_) { |
| 311 // To make sure we are conservative we return true. | 311 // Fail open: Whitelist everything |
| 312 return true; | 312 return true; |
| 313 } | 313 } |
| 314 | 314 |
| 315 FullHash hash = crypto::SHA256HashString(module_filename); |
| 315 return HandleHashSynchronously( | 316 return HandleHashSynchronously( |
| 316 str, StoresToCheck({GetChromeFilenameClientIncidentId()})); | 317 hash, StoresToCheck({GetChromeFilenameClientIncidentId()})); |
| 317 } | 318 } |
| 318 | 319 |
| 319 ThreatSource V4LocalDatabaseManager::GetThreatSource() const { | 320 ThreatSource V4LocalDatabaseManager::GetThreatSource() const { |
| 320 return ThreatSource::LOCAL_PVER4; | 321 return ThreatSource::LOCAL_PVER4; |
| 321 } | 322 } |
| 322 | 323 |
| 323 bool V4LocalDatabaseManager::IsCsdWhitelistKillSwitchOn() { | 324 bool V4LocalDatabaseManager::IsCsdWhitelistKillSwitchOn() { |
| 324 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 325 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 325 return false; | 326 return false; |
| 326 } | 327 } |
| (...skipping 350 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 677 } | 678 } |
| 678 | 679 |
| 679 void V4LocalDatabaseManager::UpdateRequestCompleted( | 680 void V4LocalDatabaseManager::UpdateRequestCompleted( |
| 680 std::unique_ptr<ParsedServerResponse> parsed_server_response) { | 681 std::unique_ptr<ParsedServerResponse> parsed_server_response) { |
| 681 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 682 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 682 v4_database_->ApplyUpdate(std::move(parsed_server_response), | 683 v4_database_->ApplyUpdate(std::move(parsed_server_response), |
| 683 db_updated_callback_); | 684 db_updated_callback_); |
| 684 } | 685 } |
| 685 | 686 |
| 686 } // namespace safe_browsing | 687 } // namespace safe_browsing |
| OLD | NEW |