diff options
author | Bartek IwaĆczuk <biwanczuk@gmail.com> | 2020-05-11 13:13:27 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-05-11 13:13:27 +0200 |
commit | 32aeec9630dc91162f0408b95dd86e1c26e4c1d3 (patch) | |
tree | f93d8e6b665df0c3054dba56973712412916493e /docs/runtime/workers.md | |
parent | 0d148c6e80583dfe029d5362f61b92334a22341a (diff) |
refactor: check permissions in SourceFileFetcher (#5011)
This PR hot-fixes permission escapes in dynamic imports, workers
and runtime compiler APIs.
"permissions" parameter was added to public APIs of SourceFileFetcher
and appropriate permission checks are performed during loading of
local and remote files.
Diffstat (limited to 'docs/runtime/workers.md')
-rw-r--r-- | docs/runtime/workers.md | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/docs/runtime/workers.md b/docs/runtime/workers.md index 3c39d2cee..16099a35b 100644 --- a/docs/runtime/workers.md +++ b/docs/runtime/workers.md @@ -18,6 +18,49 @@ new Worker("./worker.js"); new Worker("./worker.js", { type: "classic" }); ``` +### Permissions + +Creating a new `Worker` instance is similar to a dynamic import; therefore Deno +requires appropriate permission for this action. + +For workers using local modules; `--allow-read` permission is required: + +```ts +// main.ts +new Worker("./worker.ts", { type: "module" }); + +// worker.ts +console.log("hello world"); +self.close(); +``` + +```shell +$ deno run main.ts +error: Uncaught PermissionDenied: read access to "./worker.ts", run again with the --allow-read flag + +$ deno run --allow-read main.ts +hello world +``` + +For workers using remote modules; `--allow-read` permission is required: + +```ts +// main.ts +new Worker("https://example.com/worker.ts", { type: "module" }); + +// worker.ts +console.log("hello world"); +self.close(); +``` + +```shell +$ deno run main.ts +error: Uncaught PermissionDenied: net access to "https://example.com/worker.ts", run again with the --allow-net flag + +$ deno run --allow-net main.ts +hello world +``` + ### Using Deno in worker > This is an unstable Deno feature. Learn more about |