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

Unified Diff: content/browser/child_process_security_policy_unittest.cc

Issue 6623015: Add a path for a web page to request the enumeration of a directory. This, t... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 9 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
« no previous file with comments | « content/browser/child_process_security_policy.cc ('k') | content/browser/renderer_host/render_view_host.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/child_process_security_policy_unittest.cc
===================================================================
--- content/browser/child_process_security_policy_unittest.cc (revision 79702)
+++ content/browser/child_process_security_policy_unittest.cc (working copy)
@@ -215,6 +215,38 @@
p->Remove(kRendererID);
}
+TEST_F(ChildProcessSecurityPolicyTest, CanReadDirectories) {
+ ChildProcessSecurityPolicy* p = ChildProcessSecurityPolicy::GetInstance();
+
+ p->Add(kRendererID);
+
+ EXPECT_FALSE(p->CanReadDirectory(kRendererID,
+ FilePath(FILE_PATH_LITERAL("/etc/"))));
+ p->GrantReadDirectory(kRendererID, FilePath(FILE_PATH_LITERAL("/etc/")));
+ EXPECT_TRUE(p->CanReadDirectory(kRendererID,
+ FilePath(FILE_PATH_LITERAL("/etc/"))));
+ EXPECT_TRUE(p->CanReadFile(kRendererID,
+ FilePath(FILE_PATH_LITERAL("/etc/passwd"))));
+
+ p->Remove(kRendererID);
+ p->Add(kRendererID);
+
+ EXPECT_FALSE(p->CanReadDirectory(kRendererID,
+ FilePath(FILE_PATH_LITERAL("/etc/"))));
+ EXPECT_FALSE(p->CanReadFile(kRendererID,
+ FilePath(FILE_PATH_LITERAL("/etc/passwd"))));
+
+ // Just granting read permission as a file doesn't imply reading as a
+ // directory.
+ p->GrantReadFile(kRendererID, FilePath(FILE_PATH_LITERAL("/etc/")));
+ EXPECT_TRUE(p->CanReadFile(kRendererID,
+ FilePath(FILE_PATH_LITERAL("/etc/passwd"))));
+ EXPECT_FALSE(p->CanReadDirectory(kRendererID,
+ FilePath(FILE_PATH_LITERAL("/etc/"))));
+
+ p->Remove(kRendererID);
+}
+
TEST_F(ChildProcessSecurityPolicyTest, FilePermissions) {
ChildProcessSecurityPolicy* p = ChildProcessSecurityPolicy::GetInstance();
« no previous file with comments | « content/browser/child_process_security_policy.cc ('k') | content/browser/renderer_host/render_view_host.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698