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

Side by Side Diff: chrome/browser/safe_browsing/environment_data_collection_win.cc

Issue 440753002: The incident reporting service now calls VerifyModule. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
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 unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/environment_data_collection_win.h" 5 #include "chrome/browser/safe_browsing/environment_data_collection_win.h"
6 6
7 #include <windows.h> 7 #include <windows.h>
8 #include <set> 8 #include <set>
9 9
10 #include "base/i18n/case_conversion.h" 10 #include "base/i18n/case_conversion.h"
11 #include "base/strings/string_util.h" 11 #include "base/strings/string_util.h"
12 #include "base/strings/utf_string_conversions.h" 12 #include "base/strings/utf_string_conversions.h"
13 #include "base/win/registry.h" 13 #include "base/win/registry.h"
14 #include "chrome/browser/install_verification/win/module_info.h" 14 #include "chrome/browser/install_verification/win/module_info.h"
15 #include "chrome/browser/install_verification/win/module_verification_common.h" 15 #include "chrome/browser/install_verification/win/module_verification_common.h"
16 #include "chrome/browser/net/service_providers_win.h" 16 #include "chrome/browser/net/service_providers_win.h"
17 #include "chrome/browser/safe_browsing/module_integrity_verifier_win.h"
17 #include "chrome/browser/safe_browsing/path_sanitizer.h" 18 #include "chrome/browser/safe_browsing/path_sanitizer.h"
18 #include "chrome/common/safe_browsing/csd.pb.h" 19 #include "chrome/common/safe_browsing/csd.pb.h"
19 #include "chrome_elf/chrome_elf_constants.h" 20 #include "chrome_elf/chrome_elf_constants.h"
20 21
21 namespace safe_browsing { 22 namespace safe_browsing {
22 23
23 namespace { 24 namespace {
24 25
26 // The modules on which we will run VerifyModule.
27 const wchar_t* const kModulesToVerify[] = {
28 L"chrome.dll",
29 L"chrome_elf.dll",
30 L"ntdll.dll",
31 NULL,
grt (UTC plus 2) 2014/08/08 01:08:51 remove NULL
krstnmnlsn 2014/08/08 13:18:08 Done.
32 };
33
25 // Helper function for expanding all environment variables in |path|. 34 // Helper function for expanding all environment variables in |path|.
26 std::wstring ExpandEnvironmentVariables(const std::wstring& path) { 35 std::wstring ExpandEnvironmentVariables(const std::wstring& path) {
27 static const DWORD kMaxBuffer = 32 * 1024; // Max according to MSDN. 36 static const DWORD kMaxBuffer = 32 * 1024; // Max according to MSDN.
28 std::wstring path_expanded; 37 std::wstring path_expanded;
29 DWORD path_len = MAX_PATH; 38 DWORD path_len = MAX_PATH;
30 do { 39 do {
31 DWORD result = ExpandEnvironmentStrings( 40 DWORD result = ExpandEnvironmentStrings(
32 path.c_str(), WriteInto(&path_expanded, path_len), path_len); 41 path.c_str(), WriteInto(&path_expanded, path_len), path_len);
33 if (!result) { 42 if (!result) {
34 // Failed to expand variables. Return the original string. 43 // Failed to expand variables. Return the original string.
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 PathSanitizer path_sanitizer; 104 PathSanitizer path_sanitizer;
96 base::win::RegistryValueIterator iter(HKEY_CURRENT_USER, 105 base::win::RegistryValueIterator iter(HKEY_CURRENT_USER,
97 blacklist::kRegistryFinchListPath); 106 blacklist::kRegistryFinchListPath);
98 for (; iter.Valid(); ++iter) { 107 for (; iter.Valid(); ++iter) {
99 base::FilePath dll_name(iter.Value()); 108 base::FilePath dll_name(iter.Value());
100 path_sanitizer.StripHomeDirectory(&dll_name); 109 path_sanitizer.StripHomeDirectory(&dll_name);
101 process->add_blacklisted_dll(dll_name.AsUTF8Unsafe()); 110 process->add_blacklisted_dll(dll_name.AsUTF8Unsafe());
102 } 111 }
103 } 112 }
104 113
114 void CollectModuleVerificationData(
115 const wchar_t* const modules_to_verify[],
116 size_t num_modules_to_verify,
117 ClientIncidentReport_EnvironmentData_Process* process) {
118 for (size_t i = 0; i < num_modules_to_verify; ++i) {
119 std::set<std::string> modified_exports;
120 int modified = VerifyModule(modules_to_verify[i], &modified_exports);
grt (UTC plus 2) 2014/08/08 01:08:51 should this just continue when this returns MODULE
krstnmnlsn 2014/08/08 13:18:08 We don't need to send back the value no.
121
122 ClientIncidentReport_EnvironmentData_Process_ModuleState* module_state =
123 process->add_module_state();
124
125 module_state->set_name(
126 base::WideToUTF8(std::wstring(modules_to_verify[i])));
127 // Add 1 to the ModuleState enum to get the corresponding value in the
128 // protobuf's ModuleState enum.
129 module_state->set_modified_state(static_cast<
130 ClientIncidentReport_EnvironmentData_Process_ModuleState_ModifiedState>(
131 modified + 1));
132 for (std::set<std::string>::iterator it = modified_exports.begin();
133 it != modified_exports.end();
134 ++it) {
135 module_state->add_modified_export(*it);
136 }
137 }
138 }
139
105 void CollectPlatformProcessData( 140 void CollectPlatformProcessData(
106 ClientIncidentReport_EnvironmentData_Process* process) { 141 ClientIncidentReport_EnvironmentData_Process* process) {
107 CollectDlls(process); 142 CollectDlls(process);
108 RecordLspFeature(process); 143 RecordLspFeature(process);
109 CollectDllBlacklistData(process); 144 CollectDllBlacklistData(process);
145 CollectModuleVerificationData(
146 kModulesToVerify, arraysize(kModulesToVerify), process);
110 } 147 }
111 148
112 } // namespace safe_browsing 149 } // namespace safe_browsing
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698