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

Side by Side Diff: chrome/browser/safe_browsing/incident_reporting/binary_integrity_analyzer.cc

Issue 856543004: Replace incident type handlers with implementations of Incident. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: robertshield comments Created 5 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "chrome/browser/safe_browsing/incident_reporting/binary_integrity_analy zer.h" 5 #include "chrome/browser/safe_browsing/incident_reporting/binary_integrity_analy zer.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/callback.h" 10 #include "base/callback.h"
11 #include "base/files/file_util.h" 11 #include "base/files/file_util.h"
12 #include "base/metrics/histogram.h" 12 #include "base/metrics/histogram.h"
13 #include "base/strings/string_number_conversions.h" 13 #include "base/strings/string_number_conversions.h"
14 #include "base/strings/string_util.h" 14 #include "base/strings/string_util.h"
15 #include "base/strings/stringprintf.h" 15 #include "base/strings/stringprintf.h"
16 #include "base/time/time.h" 16 #include "base/time/time.h"
17 #include "chrome/browser/browser_process.h" 17 #include "chrome/browser/browser_process.h"
18 #include "chrome/browser/safe_browsing/binary_feature_extractor.h" 18 #include "chrome/browser/safe_browsing/binary_feature_extractor.h"
19 #include "chrome/browser/safe_browsing/incident_reporting/binary_integrity_incid ent.h"
19 #include "chrome/browser/safe_browsing/safe_browsing_service.h" 20 #include "chrome/browser/safe_browsing/safe_browsing_service.h"
20 #include "chrome/common/safe_browsing/csd.pb.h" 21 #include "chrome/common/safe_browsing/csd.pb.h"
21 22
22 namespace safe_browsing { 23 namespace safe_browsing {
23 24
24 namespace { 25 namespace {
25 26
26 void RecordSignatureVerificationTime(size_t file_index, 27 void RecordSignatureVerificationTime(size_t file_index,
27 const base::TimeDelta& verification_time) { 28 const base::TimeDelta& verification_time) {
28 static const char kHistogramName[] = "SBIRS.VerifyBinaryIntegrity."; 29 static const char kHistogramName[] = "SBIRS.VerifyBinaryIntegrity.";
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 63
63 scoped_ptr<ClientDownloadRequest_SignatureInfo> signature_info( 64 scoped_ptr<ClientDownloadRequest_SignatureInfo> signature_info(
64 new ClientDownloadRequest_SignatureInfo()); 65 new ClientDownloadRequest_SignatureInfo());
65 66
66 base::TimeTicks time_before = base::TimeTicks::Now(); 67 base::TimeTicks time_before = base::TimeTicks::Now();
67 binary_feature_extractor->CheckSignature(binary_path, signature_info.get()); 68 binary_feature_extractor->CheckSignature(binary_path, signature_info.get());
68 RecordSignatureVerificationTime(i, base::TimeTicks::Now() - time_before); 69 RecordSignatureVerificationTime(i, base::TimeTicks::Now() - time_before);
69 70
70 // Only create a report if the signature is untrusted. 71 // Only create a report if the signature is untrusted.
71 if (!signature_info->trusted()) { 72 if (!signature_info->trusted()) {
72 scoped_ptr<ClientIncidentReport_IncidentData> incident_data( 73 scoped_ptr<ClientIncidentReport_IncidentData_BinaryIntegrityIncident>
73 new ClientIncidentReport_IncidentData()); 74 incident(
74 ClientIncidentReport_IncidentData_BinaryIntegrityIncident* 75 new ClientIncidentReport_IncidentData_BinaryIntegrityIncident());
75 binary_integrity = incident_data->mutable_binary_integrity();
76 76
77 binary_integrity->set_file_basename( 77 incident->set_file_basename(binary_path.BaseName().AsUTF8Unsafe());
78 binary_path.BaseName().AsUTF8Unsafe()); 78 incident->set_allocated_signature(signature_info.release());
79 binary_integrity->set_allocated_signature(signature_info.release());
80 79
81 // Send the report. 80 // Send the report.
82 callback.Run(incident_data.Pass()); 81 callback.Run(make_scoped_ptr(
82 new BinaryIntegrityIncident(incident.Pass())));
83 } 83 }
84 } 84 }
85 } 85 }
86 86
87 #if !defined(OS_WIN) 87 #if !defined(OS_WIN)
88 std::vector<base::FilePath> GetCriticalBinariesPath() { 88 std::vector<base::FilePath> GetCriticalBinariesPath() {
89 return std::vector<base::FilePath>(); 89 return std::vector<base::FilePath>();
90 } 90 }
91 #endif // !defined(OS_WIN) 91 #endif // !defined(OS_WIN)
92 92
93 } // namespace safe_browsing 93 } // namespace safe_browsing
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698