summaryrefslogtreecommitdiff
path: root/cli
diff options
context:
space:
mode:
authorDavid Sherret <dsherret@users.noreply.github.com>2021-10-29 17:05:55 -0400
committerGitHub <noreply@github.com>2021-10-29 17:05:55 -0400
commitd44011a69e0674acfa9c59bd7ad7f0523eb61d42 (patch)
tree405e9d56408b94977fe5ccd11db0941d3225b46f /cli
parentb7341438f29de88f3458b32a835bfad560bda52e (diff)
fix(runtime): require full read and write permissions to create symlinks (#12554)
Diffstat (limited to 'cli')
-rw-r--r--cli/dts/lib.deno.ns.d.ts4
-rw-r--r--cli/tests/unit/symlink_test.ts28
2 files changed, 30 insertions, 2 deletions
diff --git a/cli/dts/lib.deno.ns.d.ts b/cli/dts/lib.deno.ns.d.ts
index 2e1cae306..a631315c3 100644
--- a/cli/dts/lib.deno.ns.d.ts
+++ b/cli/dts/lib.deno.ns.d.ts
@@ -2347,7 +2347,7 @@ declare namespace Deno {
* Deno.symlinkSync("old/name", "new/name");
* ```
*
- * Requires `allow-write` permission. */
+ * Requires full `allow-read` and `allow-write` permissions. */
export function symlinkSync(
oldpath: string | URL,
newpath: string | URL,
@@ -2364,7 +2364,7 @@ declare namespace Deno {
* await Deno.symlink("old/name", "new/name");
* ```
*
- * Requires `allow-write` permission. */
+ * Requires full `allow-read` and `allow-write` permissions. */
export function symlink(
oldpath: string | URL,
newpath: string | URL,
diff --git a/cli/tests/unit/symlink_test.ts b/cli/tests/unit/symlink_test.ts
index f0db2d615..782b03175 100644
--- a/cli/tests/unit/symlink_test.ts
+++ b/cli/tests/unit/symlink_test.ts
@@ -108,3 +108,31 @@ unitTest(
);
},
);
+
+unitTest(
+ { permissions: { read: true, write: ["."] } },
+ async function symlinkNoFullWritePermissions() {
+ await assertRejects(
+ () => Deno.symlink("old", "new"),
+ Deno.errors.PermissionDenied,
+ );
+ assertThrows(
+ () => Deno.symlinkSync("old", "new"),
+ Deno.errors.PermissionDenied,
+ );
+ },
+);
+
+unitTest(
+ { permissions: { read: ["."], write: true } },
+ async function symlinkNoFullReadPermissions() {
+ await assertRejects(
+ () => Deno.symlink("old", "new"),
+ Deno.errors.PermissionDenied,
+ );
+ assertThrows(
+ () => Deno.symlinkSync("old", "new"),
+ Deno.errors.PermissionDenied,
+ );
+ },
+);