Chromium Code Reviews| OLD | NEW |
|---|---|
| (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/base_paths.h" | |
|
grt (UTC plus 2)
2015/10/28 17:49:51
unused
Greg K
2015/10/29 23:51:31
Done.
| |
| 8 #include "base/files/file_util.h" | |
| 9 #include "base/mac/bundle_locations.h" | |
| 10 #include "base/path_service.h" | |
|
grt (UTC plus 2)
2015/10/28 17:49:51
unused
Greg K
2015/10/29 23:51:31
Done.
| |
| 11 #include "chrome/browser/safe_browsing/incident_reporting/binary_integrity_incid ent.h" | |
| 12 #include "chrome/browser/safe_browsing/incident_reporting/incident_receiver.h" | |
| 13 #include "chrome/browser/safe_browsing/signature_evaluator_mac.h" | |
| 14 #include "chrome/common/safe_browsing/csd.pb.h" | |
| 15 | |
| 16 #define DEVELOPER_ID_APPLICATION_OID "field.1.2.840.113635.100.6.1.13" | |
| 17 #define DEVELOPER_ID_INTERMEDIATE_OID "field.1.2.840.113635.100.6.2.6" | |
| 18 | |
| 19 namespace safe_browsing { | |
| 20 | |
| 21 namespace { | |
| 22 | |
| 23 void VerifyBinaryIntegrityHelper(IncidentReceiver* incident_receiver, | |
| 24 const base::FilePath& path, | |
| 25 const std::string& requirement) { | |
| 26 MacSignatureEvaluator evaluator(path, requirement); | |
| 27 if (!evaluator.Initialize()) { | |
| 28 LOG(ERROR) << "Could not initialize mac signature evaluator"; | |
| 29 return; | |
| 30 } | |
| 31 | |
| 32 scoped_ptr<ClientIncidentReport_IncidentData_BinaryIntegrityIncident> | |
| 33 incident(new ClientIncidentReport_IncidentData_BinaryIntegrityIncident()); | |
| 34 if (!evaluator.PerformEvaluation(incident.get())) { | |
| 35 VLOG(1) << "Signature verification failed: " << path.value(); | |
|
grt (UTC plus 2)
2015/10/28 17:49:51
DVLOG or no log at all
Greg K
2015/10/29 23:51:31
Why no log at all? I actually want this log in pro
grt (UTC plus 2)
2015/10/30 15:47:04
VLOG adds weight to shipping builds.
| |
| 36 incident_receiver->AddIncidentForProcess( | |
| 37 make_scoped_ptr(new BinaryIntegrityIncident(incident.Pass()))); | |
| 38 } else { | |
| 39 // Clear past incidents involving this bundle if the signature is | |
| 40 // now valid. | |
| 41 ClearIntegrityReports(incident_receiver, path.BaseName().value()); | |
| 42 } | |
| 43 } | |
| 44 | |
| 45 } // namespace | |
| 46 | |
| 47 std::vector<PathAndRequirement> GetCriticalPathsAndRequirements() { | |
| 48 // Get the path to the main executable. | |
| 49 std::vector<PathAndRequirement> critical_binaries; | |
| 50 // This requirement describes a developer ID signed application, | |
| 51 // with Google's team identifier, and the com.Google.Chrome[.canary] | |
| 52 // identifier. | |
| 53 std::string requirement = | |
| 54 "anchor apple generic and certificate 1[" DEVELOPER_ID_INTERMEDIATE_OID | |
| 55 "] exists and certificate leaf[" DEVELOPER_ID_APPLICATION_OID | |
| 56 "] exists and certificate leaf[subject.OU]=\"EQHXZ8M8AV\" and " | |
| 57 "(identifier=\"com.google.Chrome\" or " | |
| 58 "identifier=\"com.google.Chrome.canary\")"; | |
| 59 critical_binaries.push_back(PathAndRequirement(base::mac::OuterBundlePath(), | |
| 60 requirement)); | |
| 61 // TODO(kerrnel): eventually add Adobe Flash Player to this list. | |
| 62 return critical_binaries; | |
| 63 } | |
| 64 | |
| 65 void VerifyBinaryIntegrityForTesting(IncidentReceiver* incident_receiver, | |
| 66 const base::FilePath& path, | |
| 67 const std::string& requirement) { | |
| 68 VerifyBinaryIntegrityHelper(incident_receiver, path, requirement); | |
| 69 } | |
| 70 | |
| 71 void VerifyBinaryIntegrity(scoped_ptr<IncidentReceiver> incident_receiver) { | |
| 72 size_t i = 0; | |
| 73 for (const auto& p : GetCriticalPathsAndRequirements()) { | |
| 74 base::TimeTicks time_before = base::TimeTicks::Now(); | |
| 75 VerifyBinaryIntegrityHelper(incident_receiver.get(), | |
|
grt (UTC plus 2)
2015/10/28 17:49:51
VerifyBinaryIntegrityHelper(incident_receiver.get(
Greg K
2015/10/29 23:51:31
Done.
| |
| 76 p.path, | |
| 77 p.requirement); | |
| 78 RecordSignatureVerificationTime(i++, base::TimeTicks::Now() - time_before); | |
| 79 } | |
| 80 } | |
| 81 | |
| 82 } // namespac | |
| OLD | NEW |