Deno allow all permissions

半城伤御伤魂 提交于 2020-05-29 09:00:06

问题


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.


回答1:


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



回答2:


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.




回答3:


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


来源:https://stackoverflow.com/questions/61878523/deno-allow-all-permissions

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!