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

Side by Side Diff: sandbox/win/src/file_policy_test.cc

Issue 432543005: Replace NT prefix in sandbox rules match string to handle correct wildcard escaping (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added missing include statement 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 (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 <algorithm> 5 #include <algorithm>
6 #include <cctype> 6 #include <cctype>
7 7
8 #include <windows.h> 8 #include <windows.h>
9 #include <winioctl.h> 9 #include <winioctl.h>
10 10
11 #include "base/win/scoped_handle.h" 11 #include "base/win/scoped_handle.h"
12 #include "sandbox/win/src/filesystem_policy.h"
12 #include "sandbox/win/src/nt_internals.h" 13 #include "sandbox/win/src/nt_internals.h"
13 #include "sandbox/win/src/sandbox.h" 14 #include "sandbox/win/src/sandbox.h"
14 #include "sandbox/win/src/sandbox_factory.h" 15 #include "sandbox/win/src/sandbox_factory.h"
15 #include "sandbox/win/src/sandbox_policy.h" 16 #include "sandbox/win/src/sandbox_policy.h"
16 #include "sandbox/win/src/win_utils.h" 17 #include "sandbox/win/src/win_utils.h"
17 #include "sandbox/win/tests/common/controller.h" 18 #include "sandbox/win/tests/common/controller.h"
18 #include "sandbox/win/tests/common/test_utils.h" 19 #include "sandbox/win/tests/common/test_utils.h"
19 #include "testing/gtest/include/gtest/gtest.h" 20 #include "testing/gtest/include/gtest/gtest.h"
20 21
21 #define BINDNTDLL(name) \ 22 #define BINDNTDLL(name) \
(...skipping 567 matching lines...) Expand 10 before | Expand all | Expand 10 after
589 NULL); 590 NULL);
590 EXPECT_TRUE(INVALID_HANDLE_VALUE != dir); 591 EXPECT_TRUE(INVALID_HANDLE_VALUE != dir);
591 EXPECT_TRUE(DeleteReparsePoint(dir)); 592 EXPECT_TRUE(DeleteReparsePoint(dir));
592 EXPECT_TRUE(::CloseHandle(dir)); 593 EXPECT_TRUE(::CloseHandle(dir));
593 594
594 // Cleanup. 595 // Cleanup.
595 EXPECT_TRUE(::DeleteFile(temp_file_in_temp.c_str())); 596 EXPECT_TRUE(::DeleteFile(temp_file_in_temp.c_str()));
596 EXPECT_TRUE(::RemoveDirectory(subfolder.c_str())); 597 EXPECT_TRUE(::RemoveDirectory(subfolder.c_str()));
597 } 598 }
598 599
600 TEST(FilePolicyTest, CheckExistingNTPrefixEscape) {
601 base::string16 name = L"\\??\\NAME";
602
603 base::string16 result = FixNTPrefixForMatch(name);
604
605 EXPECT_STREQ(result.c_str(), L"\\/?/?\\NAME");
606 }
607
608 TEST(FilePolicyTest, CheckEscapedNTPrefixNoEscape) {
609 base::string16 name = L"\\/?/?\\NAME";
610
611 base::string16 result = FixNTPrefixForMatch(name);
612
613 EXPECT_STREQ(result.c_str(), name.c_str());
614 }
615
616 TEST(FilePolicyTest, CheckMissingNTPrefixEscape) {
617 base::string16 name = L"C:\\NAME";
618
619 base::string16 result = FixNTPrefixForMatch(name);
620
621 EXPECT_STREQ(result.c_str(), L"\\/?/?\\C:\\NAME");
622 }
623
599 } // namespace sandbox 624 } // namespace sandbox
OLDNEW
« no previous file with comments | « no previous file | sandbox/win/src/filesystem_policy.h » ('j') | sandbox/win/src/filesystem_policy.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698