aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorRobin Appelman <icewind@owncloud.com>2016-05-30 15:44:19 +0200
committerArthur Schiwon <blizzz@arthur-schiwon.de>2016-06-09 14:00:01 +0200
commitbee918693a70427efc2f33034176e89d7a776bc3 (patch)
tree58a1ebb24c8b4deea8507db3e6d800c15b8cc726 /tests
parenta6134a6d2f4407cb0fa8948877cd7d6e7064d370 (diff)
downloadnextcloud-server-bee918693a70427efc2f33034176e89d7a776bc3.tar.gz
nextcloud-server-bee918693a70427efc2f33034176e89d7a776bc3.zip
dissalow symlinks in local storages that point outside the datadir
Diffstat (limited to 'tests')
-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');
+ }
}