Skip to content

Commit

Permalink
Add permission whitelist docs (denoland#2365)
Browse files Browse the repository at this point in the history
  • Loading branch information
sasurau4 authored and ry committed May 16, 2019
1 parent 6679c48 commit 9c9c58c
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
3 changes: 3 additions & 0 deletions cli/flags.rs
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,9 @@ ability to spawn subprocesses.
# run program with permission to read from disk and listen to network
deno run --allow-net --allow-read https://deno.land/std/http/file_server.ts
# run program with permission to read whitelist files from disk and listen to nework
deno run --allow-net --allow-read=$(pwd) https://deno.land/std/http/file_server.ts
# run program with all permissions
deno run -A https://deno.land/std/http/file_server.ts
",
Expand Down
31 changes: 31 additions & 0 deletions website/manual.md
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,37 @@ And if you ever want to upgrade to the latest published version:
$ file_server --reload
```

### Permissions whitelist

deno also provides permissions whitelist.

This is an example to restrict File system access by whitelist.

```shellsession
$ deno run --allow-read=/usr https://deno.land/std/examples/cat.ts /etc/passwd
⚠️ Deno requests read access to "/etc/passwd". Grant? [a/y/n/d (a = allow always, y = allow once, n = deny once, d = deny always)]
```

You can grant read permission under `/etc` dir

```shellsession
$ deno run --allow-read=/etc https://deno.land/std/examples/cat.ts /etc/passwd
```

`--allow-write` works same as `--allow-read`.

This is an example to restrict host.

```ts
(async () => {
const result = await fetch("https://deno.land/std/examples/echo_server.ts");
})();
```

```shellsession
$ deno run --allow-net=deno.land allow-net-whitelist-example.ts
```

### Run subprocess

[API Reference](https://deno.land/typedoc/index.html#run)
Expand Down

0 comments on commit 9c9c58c

Please sign in to comment.