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

Side by Side Diff: chrome_elf/blacklist/test/blacklist_test.cc

Issue 346763003: Adding blacklisted dlls to safe browsing incident reports. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@updatedWard2
Patch Set: rebasing again... Created 6 years, 5 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
« no previous file with comments | « chrome_elf/blacklist/blacklist.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "base/environment.h" 5 #include "base/environment.h"
6 #include "base/files/file_path.h" 6 #include "base/files/file_path.h"
7 #include "base/files/scoped_temp_dir.h" 7 #include "base/files/scoped_temp_dir.h"
8 #include "base/i18n/case_conversion.h" 8 #include "base/i18n/case_conversion.h"
9 #include "base/path_service.h" 9 #include "base/path_service.h"
10 #include "base/scoped_native_library.h" 10 #include "base/scoped_native_library.h"
(...skipping 14 matching lines...) Expand all
25 25
26 const wchar_t kDll2Beacon[] = L"{F70A0100-2889-4629-9B44-610FE5C73231}"; 26 const wchar_t kDll2Beacon[] = L"{F70A0100-2889-4629-9B44-610FE5C73231}";
27 const wchar_t kDll3Beacon[] = L"{9E056AEC-169E-400c-B2D0-5A07E3ACE2EB}"; 27 const wchar_t kDll3Beacon[] = L"{9E056AEC-169E-400c-B2D0-5A07E3ACE2EB}";
28 28
29 extern const wchar_t* kEnvVars[]; 29 extern const wchar_t* kEnvVars[];
30 30
31 extern "C" { 31 extern "C" {
32 // When modifying the blacklist in the test process, use the exported test dll 32 // When modifying the blacklist in the test process, use the exported test dll
33 // functions on the test blacklist dll, not the ones linked into the test 33 // functions on the test blacklist dll, not the ones linked into the test
34 // executable itself. 34 // executable itself.
35 __declspec(dllimport) bool TestDll_AddDllsFromRegistryToBlacklist(); 35 __declspec(dllimport) void TestDll_AddDllsFromRegistryToBlacklist();
36 __declspec(dllimport) bool TestDll_AddDllToBlacklist(const wchar_t* dll_name); 36 __declspec(dllimport) bool TestDll_AddDllToBlacklist(const wchar_t* dll_name);
37 __declspec(dllimport) bool TestDll_IsBlacklistInitialized(); 37 __declspec(dllimport) bool TestDll_IsBlacklistInitialized();
38 __declspec(dllimport) bool TestDll_RemoveDllFromBlacklist( 38 __declspec(dllimport) bool TestDll_RemoveDllFromBlacklist(
39 const wchar_t* dll_name); 39 const wchar_t* dll_name);
40 __declspec(dllimport) bool TestDll_SuccessfullyBlocked( 40 __declspec(dllimport) bool TestDll_SuccessfullyBlocked(
41 const wchar_t** blocked_dlls, 41 const wchar_t** blocked_dlls,
42 int* size); 42 int* size);
43 } 43 }
44 44
45 namespace { 45 namespace {
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after
233 // Add the test dlls to the registry (with their name as both key and value). 233 // Add the test dlls to the registry (with their name as both key and value).
234 base::win::RegKey finch_blacklist_registry_key( 234 base::win::RegKey finch_blacklist_registry_key(
235 HKEY_CURRENT_USER, 235 HKEY_CURRENT_USER,
236 blacklist::kRegistryFinchListPath, 236 blacklist::kRegistryFinchListPath,
237 KEY_QUERY_VALUE | KEY_SET_VALUE); 237 KEY_QUERY_VALUE | KEY_SET_VALUE);
238 for (int i = 0; i < arraysize(test_data); ++i) { 238 for (int i = 0; i < arraysize(test_data); ++i) {
239 finch_blacklist_registry_key.WriteValue(test_data[i].dll_name, 239 finch_blacklist_registry_key.WriteValue(test_data[i].dll_name,
240 test_data[i].dll_name); 240 test_data[i].dll_name);
241 } 241 }
242 242
243 EXPECT_TRUE(TestDll_AddDllsFromRegistryToBlacklist()); 243 TestDll_AddDllsFromRegistryToBlacklist();
244 CheckBlacklistedDllsNotLoaded(); 244 CheckBlacklistedDllsNotLoaded();
245 } 245 }
246 246
247 void TestResetBeacon(scoped_ptr<base::win::RegKey>& key, 247 void TestResetBeacon(scoped_ptr<base::win::RegKey>& key,
248 DWORD input_state, 248 DWORD input_state,
249 DWORD expected_output_state) { 249 DWORD expected_output_state) {
250 LONG result = key->WriteValue(blacklist::kBeaconState, input_state); 250 LONG result = key->WriteValue(blacklist::kBeaconState, input_state);
251 EXPECT_EQ(ERROR_SUCCESS, result); 251 EXPECT_EQ(ERROR_SUCCESS, result);
252 252
253 EXPECT_TRUE(blacklist::ResetBeacon()); 253 EXPECT_TRUE(blacklist::ResetBeacon());
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
317 &blacklist_state); 317 &blacklist_state);
318 EXPECT_EQ(blacklist_state, blacklist::BLACKLIST_SETUP_RUNNING); 318 EXPECT_EQ(blacklist_state, blacklist::BLACKLIST_SETUP_RUNNING);
319 319
320 DWORD attempt_count = blacklist::kBeaconMaxAttempts; 320 DWORD attempt_count = blacklist::kBeaconMaxAttempts;
321 blacklist_registry_key_->ReadValueDW(blacklist::kBeaconAttemptCount, 321 blacklist_registry_key_->ReadValueDW(blacklist::kBeaconAttemptCount,
322 &attempt_count); 322 &attempt_count);
323 EXPECT_EQ(static_cast<DWORD>(0), attempt_count); 323 EXPECT_EQ(static_cast<DWORD>(0), attempt_count);
324 } 324 }
325 325
326 } // namespace 326 } // namespace
OLDNEW
« no previous file with comments | « chrome_elf/blacklist/blacklist.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698