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

Side by Side Diff: components/safe_browsing_db/v4_get_hash_protocol_manager.cc

Issue 2490753002: Ignore ThreatMatch responses for lists that we don't care about. (Closed)
Patch Set: Created 4 years, 1 month 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 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 #include "components/safe_browsing_db/v4_get_hash_protocol_manager.h" 5 #include "components/safe_browsing_db/v4_get_hash_protocol_manager.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/base64url.h" 9 #include "base/base64url.h"
10 #include "base/macros.h" 10 #include "base/macros.h"
(...skipping 509 matching lines...) Expand 10 before | Expand all | Expand 10 after
520 } 520 }
521 if (!match.has_threat_type()) { 521 if (!match.has_threat_type()) {
522 RecordParseGetHashResult(UNEXPECTED_THREAT_TYPE_ERROR); 522 RecordParseGetHashResult(UNEXPECTED_THREAT_TYPE_ERROR);
523 return false; 523 return false;
524 } 524 }
525 if (!match.has_threat()) { 525 if (!match.has_threat()) {
526 RecordParseGetHashResult(NO_THREAT_ERROR); 526 RecordParseGetHashResult(NO_THREAT_ERROR);
527 return false; 527 return false;
528 } 528 }
529 529
530 ListIdentifier list_id(match.platform_type(), match.threat_entry_type(), 530 const PlatformType& platform_type = match.platform_type();
Nathan Parker 2016/11/08 23:50:11 Nit: these temporaries add a lot more chars then t
vakh (use Gerrit instead) 2016/11/10 01:05:55 Done.
531 match.threat_type()); 531 const ThreatEntryType& threat_entry_type = match.threat_entry_type();
532 const ThreatType& threat_type = match.threat_type();
533 if (platform_types_.find(platform_type) == platform_types_.end() ||
534 threat_entry_types_.find(threat_entry_type) ==
535 threat_entry_types_.end() ||
536 threat_types_.find(threat_type) == threat_types_.end()) {
537 // The server may send a ThreatMatch response for lists that we didn't ask
538 // for so ignore those ThreatMatch responses.
539 continue;
540 }
541
542 ListIdentifier list_id(platform_type, threat_entry_type, threat_type);
532 base::Time positive_expiry; 543 base::Time positive_expiry;
533 if (match.has_cache_duration()) { 544 if (match.has_cache_duration()) {
534 // Seconds resolution is good enough so we ignore the nanos field. 545 // Seconds resolution is good enough so we ignore the nanos field.
535 positive_expiry = clock_->Now() + TimeDelta::FromSeconds( 546 positive_expiry = clock_->Now() + TimeDelta::FromSeconds(
536 match.cache_duration().seconds()); 547 match.cache_duration().seconds());
537 } else { 548 } else {
538 positive_expiry = clock_->Now() - base::TimeDelta::FromSeconds(1); 549 positive_expiry = clock_->Now() - base::TimeDelta::FromSeconds(1);
539 } 550 }
540 FullHashInfo full_hash_info(match.threat().hash(), list_id, 551 FullHashInfo full_hash_info(match.threat().hash(), list_id,
541 positive_expiry); 552 positive_expiry);
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after
736 std::ostream& operator<<(std::ostream& os, const FullHashInfo& fhi) { 747 std::ostream& operator<<(std::ostream& os, const FullHashInfo& fhi) {
737 os << "{full_hash: " << fhi.full_hash << "; list_id: " << fhi.list_id 748 os << "{full_hash: " << fhi.full_hash << "; list_id: " << fhi.list_id
738 << "; positive_expiry: " << fhi.positive_expiry 749 << "; positive_expiry: " << fhi.positive_expiry
739 << "; metadata.api_permissions.size(): " 750 << "; metadata.api_permissions.size(): "
740 << fhi.metadata.api_permissions.size() << "}"; 751 << fhi.metadata.api_permissions.size() << "}";
741 return os; 752 return os;
742 } 753 }
743 #endif 754 #endif
744 755
745 } // namespace safe_browsing 756 } // namespace safe_browsing
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698