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

Unified Diff: chrome/browser/safe_browsing/incident_reporting/binary_integrity_analyzer_win.cc

Issue 1363613004: Implement anonymous, opt-in, collection of OS X binary integrity incidents. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Ran git cl format Created 5 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/safe_browsing/incident_reporting/binary_integrity_analyzer_win.cc
diff --git a/chrome/browser/safe_browsing/incident_reporting/binary_integrity_analyzer_win.cc b/chrome/browser/safe_browsing/incident_reporting/binary_integrity_analyzer_win.cc
index e2013cb46fb1fcf838bfba15d82bf6ad89604d36..54148e32e37d951de7190f126aae0b421a28783a 100644
--- a/chrome/browser/safe_browsing/incident_reporting/binary_integrity_analyzer_win.cc
+++ b/chrome/browser/safe_browsing/incident_reporting/binary_integrity_analyzer_win.cc
@@ -2,12 +2,17 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "chrome/browser/safe_browsing/incident_reporting/binary_integrity_analyzer.h"
+#include "chrome/browser/safe_browsing/incident_reporting/binary_integrity_analyzer_win.h"
#include "base/files/file_path.h"
+#include "base/files/file_util.h"
#include "base/logging.h"
#include "base/path_service.h"
+#include "chrome/browser/safe_browsing/incident_reporting/binary_integrity_incident.h"
+#include "chrome/browser/safe_browsing/incident_reporting/incident_receiver.h"
#include "chrome/common/chrome_version.h"
+#include "chrome/common/safe_browsing/binary_feature_extractor.h"
+#include "chrome/common/safe_browsing/csd.pb.h"
namespace safe_browsing {
@@ -43,4 +48,42 @@ std::vector<base::FilePath> GetCriticalBinariesPath() {
return critical_binaries;
}
+void VerifyBinaryIntegrity(scoped_ptr<IncidentReceiver> incident_receiver) {
+ scoped_refptr<BinaryFeatureExtractor> binary_feature_extractor(
+ new BinaryFeatureExtractor());
+
+ std::vector<base::FilePath> critical_binaries = GetCriticalBinariesPath();
+ for (size_t i = 0; i < critical_binaries.size(); ++i) {
+ base::FilePath binary_path(critical_binaries[i]);
+ if (!base::PathExists(binary_path))
+ continue;
+
+ scoped_ptr<ClientDownloadRequest_SignatureInfo> signature_info(
+ new ClientDownloadRequest_SignatureInfo());
+
+ base::TimeTicks time_before = base::TimeTicks::Now();
+ binary_feature_extractor->CheckSignature(binary_path, signature_info.get());
+ RecordSignatureVerificationTime(i, base::TimeTicks::Now() - time_before);
+
+ // Only create a report if the signature is untrusted.
+ if (!signature_info->trusted()) {
+ scoped_ptr<ClientIncidentReport_IncidentData_BinaryIntegrityIncident>
+ incident(
+ new ClientIncidentReport_IncidentData_BinaryIntegrityIncident());
+
+ incident->set_file_basename(binary_path.BaseName().AsUTF8Unsafe());
+ incident->set_allocated_signature(signature_info.release());
+
+ // Send the report.
+ incident_receiver->AddIncidentForProcess(
+ make_scoped_ptr(new BinaryIntegrityIncident(incident.Pass())));
+ } else {
+ // The binary is integral, remove previous report so that next incidents
+ // for the binary will be reported.
+ ClearBinaryIntegrityForFile(incident_receiver.get(),
+ binary_path.BaseName().AsUTF8Unsafe());
+ }
+ }
+}
+
} // namespace safe_browsing

Powered by Google App Engine
This is Rietveld 408576698