OLD | NEW |
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/incident_reporting/environment_data_colle
ction_win.h" | 5 #include "chrome/browser/safe_browsing/incident_reporting/environment_data_colle
ction_win.h" |
6 | 6 |
7 #include <stdint.h> | 7 #include <stdint.h> |
8 | 8 |
9 #include <set> | 9 #include <set> |
10 #include <string> | 10 #include <string> |
11 | 11 |
12 #include "base/i18n/case_conversion.h" | 12 #include "base/i18n/case_conversion.h" |
13 #include "base/macros.h" | 13 #include "base/macros.h" |
14 #include "base/memory/ref_counted.h" | 14 #include "base/memory/ref_counted.h" |
15 #include "base/metrics/histogram_macros.h" | 15 #include "base/metrics/histogram_macros.h" |
16 #include "base/strings/string16.h" | 16 #include "base/strings/string16.h" |
17 #include "base/strings/string_util.h" | 17 #include "base/strings/string_util.h" |
18 #include "base/strings/utf_string_conversions.h" | 18 #include "base/strings/utf_string_conversions.h" |
19 #include "base/win/registry.h" | 19 #include "base/win/registry.h" |
20 #include "base/win/win_util.h" | 20 #include "base/win/win_util.h" |
21 #include "chrome/browser/install_verification/win/module_info.h" | 21 #include "chrome/browser/install_verification/win/module_info.h" |
22 #include "chrome/browser/install_verification/win/module_verification_common.h" | 22 #include "chrome/browser/install_verification/win/module_verification_common.h" |
23 #include "chrome/browser/net/service_providers_win.h" | 23 #include "chrome/browser/net/service_providers_win.h" |
24 #include "chrome/browser/safe_browsing/incident_reporting/module_integrity_verif
ier_win.h" | 24 #include "chrome/browser/safe_browsing/incident_reporting/module_integrity_verif
ier_win.h" |
25 #include "chrome/browser/safe_browsing/path_sanitizer.h" | 25 #include "chrome/browser/safe_browsing/path_sanitizer.h" |
26 #include "chrome/common/safe_browsing/binary_feature_extractor.h" | 26 #include "chrome/common/safe_browsing/binary_feature_extractor.h" |
27 #include "chrome/common/safe_browsing/csd.pb.h" | 27 #include "chrome/common/safe_browsing/csd.pb.h" |
28 #include "chrome_elf/chrome_elf_constants.h" | |
29 #include "components/variations/variations_associated_data.h" | 28 #include "components/variations/variations_associated_data.h" |
30 | 29 |
31 namespace safe_browsing { | 30 namespace safe_browsing { |
32 | 31 |
33 namespace { | 32 namespace { |
34 | 33 |
35 const REGSAM kKeyReadNoNotify = (KEY_READ) & ~(KEY_NOTIFY); | 34 const REGSAM kKeyReadNoNotify = (KEY_READ) & ~(KEY_NOTIFY); |
36 | 35 |
37 // The modules on which we will run VerifyModule. | 36 // The modules on which we will run VerifyModule. |
38 const wchar_t* const kModulesToVerify[] = { | 37 const wchar_t* const kModulesToVerify[] = { |
39 L"chrome.dll", | 38 L"chrome.dll", |
40 L"chrome_elf.dll", | |
41 L"ntdll.dll", | 39 L"ntdll.dll", |
42 }; | 40 }; |
43 | 41 |
44 // The registry keys to collect data from. | 42 // The registry keys to collect data from. |
45 const RegistryKeyInfo kRegKeysToCollect[] = { | 43 const RegistryKeyInfo kRegKeysToCollect[] = { |
46 {HKEY_CURRENT_USER, L"Software\\CSAStats"}, | 44 {HKEY_CURRENT_USER, L"Software\\CSAStats"}, |
47 }; | 45 }; |
48 | 46 |
49 // Helper function for expanding all environment variables in |path|. | 47 // Helper function for expanding all environment variables in |path|. |
50 std::wstring ExpandEnvironmentVariables(const std::wstring& path) { | 48 std::wstring ExpandEnvironmentVariables(const std::wstring& path) { |
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
228 for (int i = 0; i < process->dll_size(); ++i) { | 226 for (int i = 0; i < process->dll_size(); ++i) { |
229 if (lsp_paths.count(base::UTF8ToWide(process->dll(i).path()))) { | 227 if (lsp_paths.count(base::UTF8ToWide(process->dll(i).path()))) { |
230 process->mutable_dll(i) | 228 process->mutable_dll(i) |
231 ->add_feature(ClientIncidentReport_EnvironmentData_Process_Dll::LSP); | 229 ->add_feature(ClientIncidentReport_EnvironmentData_Process_Dll::LSP); |
232 } | 230 } |
233 } | 231 } |
234 } | 232 } |
235 | 233 |
236 void CollectDllBlacklistData( | 234 void CollectDllBlacklistData( |
237 ClientIncidentReport_EnvironmentData_Process* process) { | 235 ClientIncidentReport_EnvironmentData_Process* process) { |
238 PathSanitizer path_sanitizer; | 236 // TODO(implement this). |
239 base::win::RegistryValueIterator iter(HKEY_CURRENT_USER, | |
240 blacklist::kRegistryFinchListPath); | |
241 for (; iter.Valid(); ++iter) { | |
242 base::FilePath dll_name(iter.Value()); | |
243 path_sanitizer.StripHomeDirectory(&dll_name); | |
244 process->add_blacklisted_dll(dll_name.AsUTF8Unsafe()); | |
245 } | |
246 } | 237 } |
247 | 238 |
248 void CollectModuleVerificationData( | 239 void CollectModuleVerificationData( |
249 const wchar_t* const modules_to_verify[], | 240 const wchar_t* const modules_to_verify[], |
250 size_t num_modules_to_verify, | 241 size_t num_modules_to_verify, |
251 ClientIncidentReport_EnvironmentData_Process* process) { | 242 ClientIncidentReport_EnvironmentData_Process* process) { |
252 #if !defined(_WIN64) | 243 #if !defined(_WIN64) |
253 using ModuleState = ClientIncidentReport_EnvironmentData_Process_ModuleState; | 244 using ModuleState = ClientIncidentReport_EnvironmentData_Process_ModuleState; |
254 | 245 |
255 for (size_t i = 0; i < num_modules_to_verify; ++i) { | 246 for (size_t i = 0; i < num_modules_to_verify; ++i) { |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
318 void CollectPlatformOSData(ClientIncidentReport_EnvironmentData_OS* os_data) { | 309 void CollectPlatformOSData(ClientIncidentReport_EnvironmentData_OS* os_data) { |
319 const std::string reg_data_param_value = variations::GetVariationParamValue( | 310 const std::string reg_data_param_value = variations::GetVariationParamValue( |
320 "SafeBrowsingIncidentReportingService", "collect_reg_data"); | 311 "SafeBrowsingIncidentReportingService", "collect_reg_data"); |
321 if (reg_data_param_value == "true") { | 312 if (reg_data_param_value == "true") { |
322 CollectRegistryData(kRegKeysToCollect, arraysize(kRegKeysToCollect), | 313 CollectRegistryData(kRegKeysToCollect, arraysize(kRegKeysToCollect), |
323 os_data->mutable_registry_key()); | 314 os_data->mutable_registry_key()); |
324 } | 315 } |
325 CollectDomainEnrollmentData(os_data); | 316 CollectDomainEnrollmentData(os_data); |
326 } | 317 } |
327 } // namespace safe_browsing | 318 } // namespace safe_browsing |
OLD | NEW |