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

Unified Diff: chrome/browser/safe_browsing/binary_integrity_service_win.cc

Issue 444123002: Adding a new delayed analysis that verify binaries signature. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@grt
Patch Set: Created 6 years, 4 months 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/binary_integrity_service_win.cc
diff --git a/chrome/browser/safe_browsing/binary_integrity_service_win.cc b/chrome/browser/safe_browsing/binary_integrity_service_win.cc
new file mode 100644
index 0000000000000000000000000000000000000000..6ca70474f2b05802f7ce319aef1f87dc9db162e1
--- /dev/null
+++ b/chrome/browser/safe_browsing/binary_integrity_service_win.cc
@@ -0,0 +1,74 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// 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/binary_integrity_service.h"
+
+#include "base/callback.h"
+#include "base/files/file_path.h"
+#include "base/file_util.h"
+#include "base/logging.h"
+#include "base/path_service.h"
+#include "base/strings/stringprintf.h"
+#include "base/strings/utf_string_conversions.h"
+#include "chrome/browser/safe_browsing/binary_feature_extractor.h"
+#include "chrome/common/safe_browsing/csd.pb.h"
+
+namespace safe_browsing {
+
+void VerifyBinaryIntegrity(const AddIncidentCallback& callback) {
+ scoped_refptr<BinaryFeatureExtractor> binary_feature_extractor(
+ new BinaryFeatureExtractor());
+
+ // Hold to the same signature info instance until we use it in a report.
robertshield 2014/08/07 14:57:24 s/Hold/Hold on/
pmonette_google.com 2014/08/07 21:29:29 Done.
+ scoped_ptr<ClientDownloadRequest_SignatureInfo> signature_info(
+ new ClientDownloadRequest_SignatureInfo());
mattm 2014/08/07 20:16:01 I think a new SignatureInfo needs to be created fo
pmonette_google.com 2014/08/07 21:29:29 That is true. Done.
+
+ 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;
+
+ binary_feature_extractor->CheckSignature(binary_path, signature_info.get());
+
+ // Only create a report if the signature is untrusted.
+ if (!signature_info->trusted()) {
+ scoped_ptr<ClientIncidentReport_IncidentData> incident_data(
+ new ClientIncidentReport_IncidentData());
+ ClientIncidentReport_IncidentData_BinaryIntegrityIncident*
+ binary_integrity = incident_data->mutable_binary_integrity();
+
+ binary_integrity->set_file(base::WideToUTF8(binary_path.value()));
grt (UTC plus 2) 2014/08/07 02:12:46 you can use binary_path.AsUTF8Unsafe() here
pmonette_google.com 2014/08/07 21:29:29 Done.
+ binary_integrity->set_allocated_signature(signature_info.release());
+
+ // Send the report.
+ callback.Run(incident_data.Pass());
+
+ signature_info.reset(new ClientDownloadRequest_SignatureInfo());
+ }
+ }
+}
+
+std::vector<base::FilePath> GetCriticalBinariesPath() {
+ const wchar_t* const critical_binary_name[] = {
grt (UTC plus 2) 2014/08/07 02:12:46 static
pmonette_google.com 2014/08/07 21:29:29 Done.
+ L"%ls\\chrome.dll", L"%ls\\chrome_elf.dll", L"chrome.exe",
+ };
+
+ // Find where chrome.exe is installed.
+ base::FilePath chrome_exe_dir;
+ if (!PathService::Get(base::DIR_EXE, &chrome_exe_dir))
+ NOTREACHED();
+
+ std::vector<base::FilePath> critical_binary;
mattm 2014/08/07 20:16:01 critical_binaries?
pmonette_google.com 2014/08/07 21:29:29 Done.
+
+ for (size_t i = 0; i < arraysize(critical_binary_name); ++i) {
grt (UTC plus 2) 2014/08/07 02:12:46 i like the use of the array to build the output, b
pmonette_google.com 2014/08/07 21:29:28 Done.
+ base::string16 binary_name =
+ base::StringPrintf(critical_binary_name[i], GetChromeVersion().c_str());
grt (UTC plus 2) 2014/08/07 02:12:46 remove GetChromeVersion altogether and either use
pmonette_google.com 2014/08/07 21:29:29 Went with the second suggestion.
+ critical_binary.push_back(chrome_exe_dir.Append(binary_name));
+ }
+
+ return critical_binary;
+}
+
+} // namespace safe_browsing

Powered by Google App Engine
This is Rietveld 408576698