| Index: content/browser/child_process_security_policy_unittest.cc
|
| diff --git a/content/browser/child_process_security_policy_unittest.cc b/content/browser/child_process_security_policy_unittest.cc
|
| index e98b8411c6024d18cc54aadeaf23f444c6132498..9b9f4b41028399aa34b882b9fb18e42521f54fac 100644
|
| --- a/content/browser/child_process_security_policy_unittest.cc
|
| +++ b/content/browser/child_process_security_policy_unittest.cc
|
| @@ -1,4 +1,4 @@
|
| -// Copyright (c) 2012 The Chromium Authors. All rights reserved.
|
| +base::// Copyright (c) 2012 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.
|
|
|
| @@ -300,16 +300,21 @@ TEST_F(ChildProcessSecurityPolicyTest, CanReadFiles) {
|
|
|
| p->Add(kRendererID);
|
|
|
| - EXPECT_FALSE(p->CanReadFile(kRendererID, FilePath(TEST_PATH("/etc/passwd"))));
|
| - p->GrantReadFile(kRendererID, FilePath(TEST_PATH("/etc/passwd")));
|
| - EXPECT_TRUE(p->CanReadFile(kRendererID, FilePath(TEST_PATH("/etc/passwd"))));
|
| - EXPECT_FALSE(p->CanReadFile(kRendererID, FilePath(TEST_PATH("/etc/shadow"))));
|
| + EXPECT_FALSE(p->CanReadFile(kRendererID,
|
| + base::FilePath(TEST_PATH("/etc/passwd"))));
|
| + p->GrantReadFile(kRendererID, base::FilePath(TEST_PATH("/etc/passwd")));
|
| + EXPECT_TRUE(p->CanReadFile(kRendererID,
|
| + base::FilePath(TEST_PATH("/etc/passwd"))));
|
| + EXPECT_FALSE(p->CanReadFile(kRendererID,
|
| + base::FilePath(TEST_PATH("/etc/shadow"))));
|
|
|
| p->Remove(kRendererID);
|
| p->Add(kRendererID);
|
|
|
| - EXPECT_FALSE(p->CanReadFile(kRendererID, FilePath(TEST_PATH("/etc/passwd"))));
|
| - EXPECT_FALSE(p->CanReadFile(kRendererID, FilePath(TEST_PATH("/etc/shadow"))));
|
| + EXPECT_FALSE(p->CanReadFile(kRendererID,
|
| + base::FilePath(TEST_PATH("/etc/passwd"))));
|
| + EXPECT_FALSE(p->CanReadFile(kRendererID,
|
| + base::FilePath(TEST_PATH("/etc/shadow"))));
|
|
|
| p->Remove(kRendererID);
|
| }
|
| @@ -320,40 +325,49 @@ TEST_F(ChildProcessSecurityPolicyTest, CanReadDirectories) {
|
|
|
| p->Add(kRendererID);
|
|
|
| - EXPECT_FALSE(p->CanReadDirectory(kRendererID, FilePath(TEST_PATH("/etc/"))));
|
| - p->GrantReadDirectory(kRendererID, FilePath(TEST_PATH("/etc/")));
|
| - EXPECT_TRUE(p->CanReadDirectory(kRendererID, FilePath(TEST_PATH("/etc/"))));
|
| - EXPECT_TRUE(p->CanReadFile(kRendererID, FilePath(TEST_PATH("/etc/passwd"))));
|
| + EXPECT_FALSE(p->CanReadDirectory(kRendererID,
|
| + base::FilePath(TEST_PATH("/etc/"))));
|
| + p->GrantReadDirectory(kRendererID,
|
| + base::FilePath(TEST_PATH("/etc/")));
|
| + EXPECT_TRUE(p->CanReadDirectory(kRendererID,
|
| + base::FilePath(TEST_PATH("/etc/"))));
|
| + EXPECT_TRUE(p->CanReadFile(kRendererID,
|
| + base::FilePath(TEST_PATH("/etc/passwd"))));
|
|
|
| p->Remove(kRendererID);
|
| p->Add(kRendererID);
|
|
|
| - EXPECT_FALSE(p->CanReadDirectory(kRendererID, FilePath(TEST_PATH("/etc/"))));
|
| - EXPECT_FALSE(p->CanReadFile(kRendererID, FilePath(TEST_PATH("/etc/passwd"))));
|
| + EXPECT_FALSE(p->CanReadDirectory(kRendererID,
|
| + base::FilePath(TEST_PATH("/etc/"))));
|
| + EXPECT_FALSE(p->CanReadFile(kRendererID,
|
| + base::FilePath(TEST_PATH("/etc/passwd"))));
|
|
|
| // Just granting read permission as a file doesn't imply reading as a
|
| // directory.
|
| - p->GrantReadFile(kRendererID, FilePath(TEST_PATH("/etc/")));
|
| - EXPECT_TRUE(p->CanReadFile(kRendererID, FilePath(TEST_PATH("/etc/passwd"))));
|
| - EXPECT_FALSE(p->CanReadDirectory(kRendererID, FilePath(TEST_PATH("/etc/"))));
|
| + p->GrantReadFile(kRendererID, base::FilePath(TEST_PATH("/etc/")));
|
| + EXPECT_TRUE(p->CanReadFile(kRendererID,
|
| + base::FilePath(TEST_PATH("/etc/passwd"))));
|
| + EXPECT_FALSE(p->CanReadDirectory(kRendererID,
|
| + base::FilePath(TEST_PATH("/etc/"))));
|
|
|
| p->Remove(kRendererID);
|
| }
|
|
|
| TEST_F(ChildProcessSecurityPolicyTest, FilePermissions) {
|
| - FilePath granted_file = FilePath(TEST_PATH("/home/joe"));
|
| - FilePath sibling_file = FilePath(TEST_PATH("/home/bob"));
|
| - FilePath child_file = FilePath(TEST_PATH("/home/joe/file"));
|
| - FilePath parent_file = FilePath(TEST_PATH("/home"));
|
| - FilePath parent_slash_file = FilePath(TEST_PATH("/home/"));
|
| - FilePath child_traversal1 = FilePath(TEST_PATH("/home/joe/././file"));
|
| - FilePath child_traversal2 = FilePath(
|
| + base::FilePath granted_file = FilePath(TEST_PATH("/home/joe"));
|
| + base::FilePath sibling_file = FilePath(TEST_PATH("/home/bob"));
|
| + base::FilePath child_file = FilePath(TEST_PATH("/home/joe/file"));
|
| + base::FilePath parent_file = FilePath(TEST_PATH("/home"));
|
| + base::FilePath parent_slash_file = FilePath(TEST_PATH("/home/"));
|
| + base::FilePath child_traversal1 = FilePath(TEST_PATH("/home/joe/././file"));
|
| + base::FilePath child_traversal2 = FilePath(
|
| TEST_PATH("/home/joe/file/../otherfile"));
|
| - FilePath evil_traversal1 = FilePath(TEST_PATH("/home/joe/../../etc/passwd"));
|
| - FilePath evil_traversal2 = FilePath(
|
| + base::FilePath evil_traversal1 =
|
| + FilePath(TEST_PATH("/home/joe/../../etc/passwd"));
|
| + base::FilePath evil_traversal2 = FilePath(
|
| TEST_PATH("/home/joe/./.././../etc/passwd"));
|
| - FilePath self_traversal = FilePath(TEST_PATH("/home/joe/../joe/file"));
|
| - FilePath relative_file = FilePath(FILE_PATH_LITERAL("home/joe"));
|
| + base::FilePath self_traversal = FilePath(TEST_PATH("/home/joe/../joe/file"));
|
| + base::FilePath relative_file = FilePath(FILE_PATH_LITERAL("home/joe"));
|
|
|
| ChildProcessSecurityPolicyImpl* p =
|
| ChildProcessSecurityPolicyImpl::GetInstance();
|
| @@ -510,7 +524,7 @@ TEST_F(ChildProcessSecurityPolicyTest, RemoveRace) {
|
| ChildProcessSecurityPolicyImpl::GetInstance();
|
|
|
| GURL url("file:///etc/passwd");
|
| - FilePath file(TEST_PATH("/etc/passwd"));
|
| + base::FilePath file(TEST_PATH("/etc/passwd"));
|
|
|
| p->Add(kRendererID);
|
|
|
|
|