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

Side by Side Diff: net/http/transport_security_state.cc

Issue 2648713002: Add response code to the success callback of ReportSender (Closed)
Patch Set: Created 3 years, 11 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 #include "net/http/transport_security_state.h" 5 #include "net/http/transport_security_state.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <memory> 8 #include <memory>
9 #include <utility> 9 #include <utility>
10 #include <vector> 10 #include <vector>
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
61 DCHECK_EQ(HASH_VALUE_SHA256, rhs.tag); 61 DCHECK_EQ(HASH_VALUE_SHA256, rhs.tag);
62 return memcmp(lhs.data, rhs.data(), rhs.size()) < 0; 62 return memcmp(lhs.data, rhs.data(), rhs.size()) < 0;
63 } 63 }
64 64
65 bool operator()(const HashValue& lhs, const SHA256HashValue& rhs) const { 65 bool operator()(const HashValue& lhs, const SHA256HashValue& rhs) const {
66 DCHECK_EQ(HASH_VALUE_SHA256, lhs.tag); 66 DCHECK_EQ(HASH_VALUE_SHA256, lhs.tag);
67 return memcmp(lhs.data(), rhs.data, lhs.size()) < 0; 67 return memcmp(lhs.data(), rhs.data, lhs.size()) < 0;
68 } 68 }
69 }; 69 };
70 70
71 void RecordUMAForHPKPReportFailure(const GURL& report_uri, int net_error) { 71 void RecordUMAForHPKPReportFailure(const GURL& report_uri,
72 int net_error,
73 int response_code) {
72 UMA_HISTOGRAM_SPARSE_SLOWLY("Net.PublicKeyPinReportSendingFailure2", 74 UMA_HISTOGRAM_SPARSE_SLOWLY("Net.PublicKeyPinReportSendingFailure2",
73 -net_error); 75 -net_error);
74 } 76 }
75 77
76 std::string TimeToISO8601(const base::Time& t) { 78 std::string TimeToISO8601(const base::Time& t) {
77 base::Time::Exploded exploded; 79 base::Time::Exploded exploded;
78 t.UTCExplode(&exploded); 80 t.UTCExplode(&exploded);
79 return base::StringPrintf( 81 return base::StringPrintf(
80 "%04d-%02d-%02dT%02d:%02d:%02d.%03dZ", exploded.year, exploded.month, 82 "%04d-%02d-%02dT%02d:%02d:%02d.%03dZ", exploded.year, exploded.month,
81 exploded.day_of_month, exploded.hour, exploded.minute, exploded.second, 83 exploded.day_of_month, exploded.hour, exploded.minute, exploded.second,
(...skipping 736 matching lines...) Expand 10 before | Expand all | Expand 10 after
818 return; 820 return;
819 } 821 }
820 822
821 std::string serialized_report; 823 std::string serialized_report;
822 if (!SerializeExpectStapleReport(host_port_pair, ssl_info, ocsp_response, 824 if (!SerializeExpectStapleReport(host_port_pair, ssl_info, ocsp_response,
823 &serialized_report)) { 825 &serialized_report)) {
824 return; 826 return;
825 } 827 }
826 report_sender_->Send(expect_staple_state.report_uri, 828 report_sender_->Send(expect_staple_state.report_uri,
827 "application/json; charset=utf-8", serialized_report, 829 "application/json; charset=utf-8", serialized_report,
828 base::Closure(), 830 base::Callback<void(int)>(),
829 base::Bind(RecordUMAForHPKPReportFailure)); 831 base::Bind(RecordUMAForHPKPReportFailure));
830 } 832 }
831 833
832 bool TransportSecurityState::HasPublicKeyPins(const std::string& host) { 834 bool TransportSecurityState::HasPublicKeyPins(const std::string& host) {
833 PKPState dynamic_state; 835 PKPState dynamic_state;
834 if (GetDynamicPKPState(host, &dynamic_state)) 836 if (GetDynamicPKPState(host, &dynamic_state))
835 return dynamic_state.HasPublicKeyPins(); 837 return dynamic_state.HasPublicKeyPins();
836 838
837 STSState unused; 839 STSState unused;
838 PKPState static_pkp_state; 840 PKPState static_pkp_state;
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after
1076 // also prevents accidental loops (a.com triggers a report to b.com 1078 // also prevents accidental loops (a.com triggers a report to b.com
1077 // which triggers a report to a.com). See section 2.1.4 of RFC 7469. 1079 // which triggers a report to a.com). See section 2.1.4 of RFC 7469.
1078 if (sent_reports_cache_.Get(report_cache_key, base::TimeTicks::Now())) 1080 if (sent_reports_cache_.Get(report_cache_key, base::TimeTicks::Now()))
1079 return PKPStatus::VIOLATED; 1081 return PKPStatus::VIOLATED;
1080 sent_reports_cache_.Put( 1082 sent_reports_cache_.Put(
1081 report_cache_key, true, base::TimeTicks::Now(), 1083 report_cache_key, true, base::TimeTicks::Now(),
1082 base::TimeTicks::Now() + 1084 base::TimeTicks::Now() +
1083 base::TimeDelta::FromMinutes(kTimeToRememberHPKPReportsMins)); 1085 base::TimeDelta::FromMinutes(kTimeToRememberHPKPReportsMins));
1084 1086
1085 report_sender_->Send(pkp_state.report_uri, "application/json; charset=utf-8", 1087 report_sender_->Send(pkp_state.report_uri, "application/json; charset=utf-8",
1086 serialized_report, base::Closure(), 1088 serialized_report, base::Callback<void(int)>(),
1087 base::Bind(RecordUMAForHPKPReportFailure)); 1089 base::Bind(RecordUMAForHPKPReportFailure));
1088 return PKPStatus::VIOLATED; 1090 return PKPStatus::VIOLATED;
1089 } 1091 }
1090 1092
1091 bool TransportSecurityState::GetStaticExpectCTState( 1093 bool TransportSecurityState::GetStaticExpectCTState(
1092 const std::string& host, 1094 const std::string& host,
1093 ExpectCTState* expect_ct_state) const { 1095 ExpectCTState* expect_ct_state) const {
1094 DCHECK(CalledOnValidThread()); 1096 DCHECK(CalledOnValidThread());
1095 1097
1096 if (!IsBuildTimely()) 1098 if (!IsBuildTimely())
(...skipping 557 matching lines...) Expand 10 before | Expand all | Expand 10 after
1654 TransportSecurityState::PKPStateIterator::PKPStateIterator( 1656 TransportSecurityState::PKPStateIterator::PKPStateIterator(
1655 const TransportSecurityState& state) 1657 const TransportSecurityState& state)
1656 : iterator_(state.enabled_pkp_hosts_.begin()), 1658 : iterator_(state.enabled_pkp_hosts_.begin()),
1657 end_(state.enabled_pkp_hosts_.end()) { 1659 end_(state.enabled_pkp_hosts_.end()) {
1658 } 1660 }
1659 1661
1660 TransportSecurityState::PKPStateIterator::~PKPStateIterator() { 1662 TransportSecurityState::PKPStateIterator::~PKPStateIterator() {
1661 } 1663 }
1662 1664
1663 } // namespace 1665 } // namespace
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698