| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 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 | 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_mac.h" | 5 #include "chrome/browser/safe_browsing/incident_reporting/binary_integrity_analy
zer_mac.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <utility> |
| 10 |
| 9 #include "base/files/file_util.h" | 11 #include "base/files/file_util.h" |
| 10 #include "base/mac/bundle_locations.h" | 12 #include "base/mac/bundle_locations.h" |
| 11 #include "chrome/browser/safe_browsing/incident_reporting/binary_integrity_incid
ent.h" | 13 #include "chrome/browser/safe_browsing/incident_reporting/binary_integrity_incid
ent.h" |
| 12 #include "chrome/browser/safe_browsing/incident_reporting/incident_receiver.h" | 14 #include "chrome/browser/safe_browsing/incident_reporting/incident_receiver.h" |
| 13 #include "chrome/browser/safe_browsing/signature_evaluator_mac.h" | 15 #include "chrome/browser/safe_browsing/signature_evaluator_mac.h" |
| 14 #include "chrome/common/safe_browsing/csd.pb.h" | 16 #include "chrome/common/safe_browsing/csd.pb.h" |
| 15 | 17 |
| 16 #define DEVELOPER_ID_APPLICATION_OID "field.1.2.840.113635.100.6.1.13" | 18 #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" | 19 #define DEVELOPER_ID_INTERMEDIATE_OID "field.1.2.840.113635.100.6.2.6" |
| 18 | 20 |
| 19 namespace safe_browsing { | 21 namespace safe_browsing { |
| 20 | 22 |
| 21 namespace { | 23 namespace { |
| 22 | 24 |
| 23 void VerifyBinaryIntegrityHelper(IncidentReceiver* incident_receiver, | 25 void VerifyBinaryIntegrityHelper(IncidentReceiver* incident_receiver, |
| 24 const base::FilePath& path, | 26 const base::FilePath& path, |
| 25 const std::string& requirement) { | 27 const std::string& requirement) { |
| 26 MacSignatureEvaluator evaluator(path, requirement); | 28 MacSignatureEvaluator evaluator(path, requirement); |
| 27 if (!evaluator.Initialize()) { | 29 if (!evaluator.Initialize()) { |
| 28 LOG(ERROR) << "Could not initialize mac signature evaluator"; | 30 LOG(ERROR) << "Could not initialize mac signature evaluator"; |
| 29 return; | 31 return; |
| 30 } | 32 } |
| 31 | 33 |
| 32 scoped_ptr<ClientIncidentReport_IncidentData_BinaryIntegrityIncident> | 34 scoped_ptr<ClientIncidentReport_IncidentData_BinaryIntegrityIncident> |
| 33 incident(new ClientIncidentReport_IncidentData_BinaryIntegrityIncident()); | 35 incident(new ClientIncidentReport_IncidentData_BinaryIntegrityIncident()); |
| 34 if (!evaluator.PerformEvaluation(incident.get())) { | 36 if (!evaluator.PerformEvaluation(incident.get())) { |
| 35 incident_receiver->AddIncidentForProcess( | 37 incident_receiver->AddIncidentForProcess( |
| 36 make_scoped_ptr(new BinaryIntegrityIncident(incident.Pass()))); | 38 make_scoped_ptr(new BinaryIntegrityIncident(std::move(incident)))); |
| 37 } else { | 39 } else { |
| 38 // Clear past incidents involving this bundle if the signature is | 40 // Clear past incidents involving this bundle if the signature is |
| 39 // now valid. | 41 // now valid. |
| 40 ClearBinaryIntegrityForFile(incident_receiver, path.BaseName().value()); | 42 ClearBinaryIntegrityForFile(incident_receiver, path.BaseName().value()); |
| 41 } | 43 } |
| 42 } | 44 } |
| 43 | 45 |
| 44 } // namespace | 46 } // namespace |
| 45 | 47 |
| 46 std::vector<PathAndRequirement> GetCriticalPathsAndRequirements() { | 48 std::vector<PathAndRequirement> GetCriticalPathsAndRequirements() { |
| (...skipping 23 matching lines...) Expand all Loading... |
| 70 void VerifyBinaryIntegrity(scoped_ptr<IncidentReceiver> incident_receiver) { | 72 void VerifyBinaryIntegrity(scoped_ptr<IncidentReceiver> incident_receiver) { |
| 71 size_t i = 0; | 73 size_t i = 0; |
| 72 for (const auto& p : GetCriticalPathsAndRequirements()) { | 74 for (const auto& p : GetCriticalPathsAndRequirements()) { |
| 73 base::TimeTicks time_before = base::TimeTicks::Now(); | 75 base::TimeTicks time_before = base::TimeTicks::Now(); |
| 74 VerifyBinaryIntegrityHelper(incident_receiver.get(), p.path, p.requirement); | 76 VerifyBinaryIntegrityHelper(incident_receiver.get(), p.path, p.requirement); |
| 75 RecordSignatureVerificationTime(i++, base::TimeTicks::Now() - time_before); | 77 RecordSignatureVerificationTime(i++, base::TimeTicks::Now() - time_before); |
| 76 } | 78 } |
| 77 } | 79 } |
| 78 | 80 |
| 79 } // namespace | 81 } // namespace |
| OLD | NEW |