Deno allow all permissions

Viewed 1862

I often find myself typing at least two or three permission options when playing with Deno:

deno run --allow-net --allow-read --allow-env app.ts

There's a way to escape explicit permissions.

4 Answers

You can use: --allow-all or the short option -A to allow all permissions.

Have in mind that it will include all of the following permissions:

--allow-env                    
    Allow environment access

--allow-hrtime                 
    Allow high resolution time measurement

--allow-net=<allow-net>        
    Allow network access

--allow-plugin                 
    Allow loading plugins

--allow-read=<allow-read>      
    Allow file system read access

--allow-run                    
    Allow running subprocesses

--allow-write=<allow-write>    
    Allow file system write access

There's a nice option -A to allow all permissions.

deno run -A app.ts

Important: This is insecure and should be used for experimentation only.

When developing real applications prefer explicit permissions.

I created a tool that aims to help with that https://github.com/BentoumiTech/denox/

You can specify your scripts in a deno-workspace.yml file with permissions list

scripts:
  # "denox run start" will execute app.ts with --allow-net --allow-read --allow-env permissions
  start:
    file: app.ts
    deno_options:
      allow-net: true 
      allow-read: true
      allow-env: true

$ deno install -Af -n denox https://denopkg.com/BentoumiTech/denox/denox.ts

$ denox run start will translate to deno run --allow-net --allow-read --allow-env app.ts

It also supports all the other deno options

allow-all, allow-env, allow-hrtime, allow-net, allow-plugin, allow-read, allow-run,
allow-write, cached-only, cert, config, importmap, inspect, inspect-brk, lock, lock-write,
log-level, no-remote, quiet, reload, seed, unstable, v8-flags

You could use denon https://deno.land/x/denon, is a tool like nodemon. An awesome thing about this is that includes a denon.json where you can add the attribute "allow": as an array and add the flags you want.

"allow": ["net", "read", "write"]

and then in the terminal run the script for start your application

denon start yourapp.ts

This will run:

deno run --allow-net --allow-read --allow-write yourapp.ts

Now, when you make a change and save, it will run it again.

It has other cool attributes to add like the "unstable": true. Give it a try and read the README from denon for more information.

Related