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.h" | |
6 | |
7 #include "base/base_paths.h" | |
8 #include "base/files/file_util.h" | |
9 #include "base/path_service.h" | |
10 #include "chrome/browser/safe_browsing/incident_reporting/incident_receiver.h" | |
11 #include "chrome/browser/safe_browsing/incident_reporting/osx_binary_integrity_i ncident.h" | |
12 #include "chrome/browser/safe_browsing/signature_evaluator_mac.h" | |
13 #include "chrome/common/safe_browsing/csd.pb.h" | |
14 | |
15 #define DEVELOPER_ID_APPLICATION_OID "field.1.2.840.113635.100.6.1.13" | |
16 #define DEVELOPER_ID_INTERMEDIATE_OID "field.1.2.840.113635.100.6.2.6" | |
17 | |
18 namespace safe_browsing { | |
19 | |
20 std::vector<std::pair<base::FilePath, std::string>> | |
21 GetCriticalPathsAndRequirements() { | |
22 // Get the path to the main executable | |
23 std::vector<std::pair<base::FilePath, std::string>> critical_binaries; | |
24 base::FilePath main_exe; | |
25 if (!PathService::Get(base::FILE_EXE, &main_exe)) | |
26 NOTREACHED(); | |
27 std::string requirement = | |
28 "anchor apple generic and certificate 1[" DEVELOPER_ID_INTERMEDIATE_OID | |
29 "] exists and certificate leaf[" DEVELOPER_ID_APPLICATION_OID | |
30 "] exists and certificate leaf[subject.OU]=\"EQHXZ8M8AV\" and " | |
31 "(identifier=\"com.google.Chrome\" or " | |
32 "identifier=\"com.google.Chrome.canary\")"; | |
33 critical_binaries.push_back(std::make_pair(main_exe, requirement)); | |
34 // TODO(kerrnel): eventually add Adobe Flash Player to this list. | |
35 return critical_binaries; | |
36 } | |
37 | |
38 void VerifyBinaryIntegrityHelper(scoped_ptr<IncidentReceiver> incident_receiver, | |
39 const base::FilePath& path, | |
40 const std::string& requirement) { | |
41 base::FilePath binary_path(path); | |
42 if (!base::PathExists(binary_path)) | |
43 return; | |
44 | |
45 MacSignatureEvaluator evaluator(binary_path, requirement); | |
46 if (!evaluator.Initialize()) { | |
47 LOG(ERROR) << "Could not initialize mac signature evaluator"; | |
48 return; | |
49 } | |
50 | |
51 scoped_ptr<ClientIncidentReport_IncidentData_OSXBinaryIntegrityIncident> | |
52 incident( | |
53 new ClientIncidentReport_IncidentData_OSXBinaryIntegrityIncident()); | |
54 if (!evaluator.PerformEvaluation(incident.get())) { | |
55 incident_receiver->AddIncidentForProcess( | |
56 make_scoped_ptr(new OSXBinaryIntegrityIncident(incident.Pass()))); | |
57 } | |
58 } | |
59 | |
60 void VerifyBinaryIntegrity(scoped_ptr<IncidentReceiver> incident_receiver) { | |
61 std::vector<std::pair<base::FilePath, std::string>> bundles_and_requirements = | |
62 GetCriticalPathsAndRequirements(); | |
63 for (size_t i = 0; i < bundles_and_requirements.size(); i++) { | |
grt (UTC plus 2)
2015/10/03 20:03:00
for (const auto& p : bundles_and_requirements) {
Greg K
2015/10/07 22:54:28
Done.
| |
64 const auto& p = bundles_and_requirements[i]; | |
65 const base::FilePath& path = p.first; | |
66 const std::string& requirement = p.second; | |
67 base::TimeTicks time_before = base::TimeTicks::Now(); | |
68 VerifyBinaryIntegrityHelper(incident_receiver.Pass(), path, requirement); | |
grt (UTC plus 2)
2015/10/03 20:02:59
don't Pass() ownership of the receiver to the help
Greg K
2015/10/07 22:54:28
Done.
| |
69 RecordSignatureVerificationTime(i, base::TimeTicks::Now() - time_before); | |
70 } | |
71 } | |
72 | |
73 } // namespace | |
OLD | NEW |