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

Side by Side Diff: chrome/browser/safe_browsing/incident_reporting/binary_integrity_analyzer_mac.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: Refinements per grt's code review 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "chrome/browser/safe_browsing/incident_reporting/binary_integrity_analy zer_mac.h"
6
7 #include "base/files/file_util.h"
8 #include "base/mac/bundle_locations.h"
9 #include "chrome/browser/safe_browsing/incident_reporting/binary_integrity_incid ent.h"
10 #include "chrome/browser/safe_browsing/incident_reporting/incident_receiver.h"
11 #include "chrome/browser/safe_browsing/signature_evaluator_mac.h"
12 #include "chrome/common/safe_browsing/csd.pb.h"
13
14 #define DEVELOPER_ID_APPLICATION_OID "field.1.2.840.113635.100.6.1.13"
15 #define DEVELOPER_ID_INTERMEDIATE_OID "field.1.2.840.113635.100.6.2.6"
16
17 namespace safe_browsing {
18
19 namespace {
20
21 void VerifyBinaryIntegrityHelper(IncidentReceiver* incident_receiver,
22 const base::FilePath& path,
23 const std::string& requirement) {
24 MacSignatureEvaluator evaluator(path, requirement);
25 if (!evaluator.Initialize()) {
26 LOG(ERROR) << "Could not initialize mac signature evaluator";
27 return;
28 }
29
30 scoped_ptr<ClientIncidentReport_IncidentData_BinaryIntegrityIncident>
31 incident(new ClientIncidentReport_IncidentData_BinaryIntegrityIncident());
32 if (!evaluator.PerformEvaluation(incident.get())) {
33 VLOG(1) << "Signature verification failed: " << path.value();
Greg K 2015/10/30 20:05:13 Removing this.
34 incident_receiver->AddIncidentForProcess(
35 make_scoped_ptr(new BinaryIntegrityIncident(incident.Pass())));
36 } else {
37 // Clear past incidents involving this bundle if the signature is
38 // now valid.
39 ClearBinaryIntegrityForFile(incident_receiver, path.BaseName().value());
40 }
41 }
42
43 } // namespace
44
45 std::vector<PathAndRequirement> GetCriticalPathsAndRequirements() {
46 // Get the path to the main executable.
47 std::vector<PathAndRequirement> critical_binaries;
48 // This requirement describes a developer ID signed application,
49 // with Google's team identifier, and the com.Google.Chrome[.canary]
50 // identifier.
51 std::string requirement =
52 "anchor apple generic and certificate 1[" DEVELOPER_ID_INTERMEDIATE_OID
53 "] exists and certificate leaf[" DEVELOPER_ID_APPLICATION_OID
54 "] exists and certificate leaf[subject.OU]=\"EQHXZ8M8AV\" and "
55 "(identifier=\"com.google.Chrome\" or "
56 "identifier=\"com.google.Chrome.canary\")";
57 critical_binaries.push_back(PathAndRequirement(base::mac::OuterBundlePath(),
58 requirement));
59 // TODO(kerrnel): eventually add Adobe Flash Player to this list.
60 return critical_binaries;
61 }
62
63 void VerifyBinaryIntegrityForTesting(IncidentReceiver* incident_receiver,
64 const base::FilePath& path,
65 const std::string& requirement) {
66 VerifyBinaryIntegrityHelper(incident_receiver, path, requirement);
67 }
68
69 void VerifyBinaryIntegrity(scoped_ptr<IncidentReceiver> incident_receiver) {
70 size_t i = 0;
71 for (const auto& p : GetCriticalPathsAndRequirements()) {
72 base::TimeTicks time_before = base::TimeTicks::Now();
73 VerifyBinaryIntegrityHelper(incident_receiver.get(), p.path, p.requirement);
74 RecordSignatureVerificationTime(i++, base::TimeTicks::Now() - time_before);
75 }
76 }
77
78 } // namespace
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698