summaryrefslogtreecommitdiffstats
path: root/tests/lib
diff options
context:
space:
mode:
authorVincent Petry <pvince81@owncloud.com>2016-06-08 10:19:24 +0200
committerVincent Petry <pvince81@owncloud.com>2016-06-08 10:19:24 +0200
commit8d0948977e2c943c468b6365b5c0104c398a32bf (patch)
tree2f24be08e668094be4b314a32fd6adb0c8a98bef /tests/lib
parented92f4c4272a1681e32e2b1c33997e9c0281cca4 (diff)
parentf119769c2683ae55aee440e6188933c7b59998cd (diff)
downloadnextcloud-server-8d0948977e2c943c468b6365b5c0104c398a32bf.tar.gz
nextcloud-server-8d0948977e2c943c468b6365b5c0104c398a32bf.zip
Merge pull request #24899 from owncloud/local-storage-symlinks
dissalow symlinks in local storages that point outside the datadir
Diffstat (limited to 'tests/lib')
-rw-r--r--tests/lib/Files/Storage/LocalTest.php31
1 files changed, 31 insertions, 0 deletions
diff --git a/tests/lib/Files/Storage/LocalTest.php b/tests/lib/Files/Storage/LocalTest.php
index 7b8ae6a24b2..cca4d6a6676 100644
--- a/tests/lib/Files/Storage/LocalTest.php
+++ b/tests/lib/Files/Storage/LocalTest.php
@@ -84,5 +84,36 @@ class LocalTest extends Storage {
public function testInvalidArgumentsNoArray() {
new \OC\Files\Storage\Local(null);
}
+
+ /**
+ * @expectedException \OCP\Files\ForbiddenException
+ */
+ public function testDisallowSymlinksOutsideDatadir() {
+ $subDir1 = $this->tmpDir . 'sub1';
+ $subDir2 = $this->tmpDir . 'sub2';
+ $sym = $this->tmpDir . 'sub1/sym';
+ mkdir($subDir1);
+ mkdir($subDir2);
+
+ symlink($subDir2, $sym);
+
+ $storage = new \OC\Files\Storage\Local(['datadir' => $subDir1]);
+
+ $storage->file_put_contents('sym/foo', 'bar');
+ }
+
+ public function testDisallowSymlinksInsideDatadir() {
+ $subDir1 = $this->tmpDir . 'sub1';
+ $subDir2 = $this->tmpDir . 'sub1/sub2';
+ $sym = $this->tmpDir . 'sub1/sym';
+ mkdir($subDir1);
+ mkdir($subDir2);
+
+ symlink($subDir2, $sym);
+
+ $storage = new \OC\Files\Storage\Local(['datadir' => $subDir1]);
+
+ $storage->file_put_contents('sym/foo', 'bar');
+ }
}