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

Unified Diff: chrome/browser/safe_browsing/incident_reporting/blacklist_load_analyzer_win_unittest.cc

Issue 433513008: Add blacklist incidents to incident reporting service. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: mattm feedback 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/incident_reporting/blacklist_load_analyzer_win_unittest.cc
diff --git a/chrome/browser/safe_browsing/incident_reporting/blacklist_load_analyzer_win_unittest.cc b/chrome/browser/safe_browsing/incident_reporting/blacklist_load_analyzer_win_unittest.cc
new file mode 100644
index 0000000000000000000000000000000000000000..6edafbf83893459332cea7ecfd81ec4c9e2e9398
--- /dev/null
+++ b/chrome/browser/safe_browsing/incident_reporting/blacklist_load_analyzer_win_unittest.cc
@@ -0,0 +1,51 @@
+// 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/incident_reporting/blacklist_load_analyzer.h"
+
+#include <vector>
+
+#include "base/files/file_path.h"
+#include "base/path_service.h"
+#include "base/scoped_native_library.h"
+#include "base/strings/string_util.h"
+#include "chrome_elf/blacklist/blacklist.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+namespace {
+const wchar_t kTestDllName[] = L"blacklist_test_dll_1.dll";
+}
+
+namespace safe_browsing {
+
+TEST(BlacklistLoadAnalyzer, TestBlacklistBypass) {
+ base::FilePath current_dir;
+ ASSERT_TRUE(PathService::Get(base::DIR_EXE, &current_dir));
+
+ // Load test dll.
+ base::ScopedNativeLibrary dll1(current_dir.Append(kTestDllName));
+
+ // No blacklisted dlls should be found.
+ std::vector<base::string16> module_names;
+ EXPECT_TRUE(GetLoadedBlacklistedModules(&module_names));
+ EXPECT_TRUE(module_names.empty());
+
+ std::vector<base::string16>::const_iterator module_iter(module_names.begin());
+ for (; module_iter != module_names.end(); ++module_iter) {
+ LOG(ERROR) << "Found blacklisted module: " << *module_iter;
+ }
+
+ // Add test dll to blacklist
+ blacklist::AddDllToBlacklist(kTestDllName);
+
+ // Check that the test dll appears in list.
+ module_names.clear();
+ EXPECT_TRUE(GetLoadedBlacklistedModules(&module_names));
+ ASSERT_EQ(1, module_names.size());
+ EXPECT_STREQ(kTestDllName,
+ base::StringToLowerASCII(
+ base::FilePath(module_names[0]).BaseName().value()).c_str());
+}
+
+} // namespace safe_browsing

Powered by Google App Engine
This is Rietveld 408576698