diff options
author | Asher Gomez <ashersaupingomez@gmail.com> | 2023-08-03 21:19:19 +1000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-08-03 13:19:19 +0200 |
commit | 6fb7e8d93bb9fd8cdd81130a394ae6061930c4f6 (patch) | |
tree | 2ec6dc2be234ef5a42023c1d75f1fc1316d80f06 /cli/args/mod.rs | |
parent | db287e216dd752bfcb3484cbfd93225e8463c363 (diff) |
feat(permissions): add "--deny-*" flags (#19070)
This commit adds new "--deny-*" permission flags. These are complimentary to
"--allow-*" flags.
These flags can be used to restrict access to certain resources, even if they
were granted using "--allow-*" flags or the "--allow-all" ("-A") flag.
Eg. specifying "--allow-read --deny-read" will result in a permission error,
while "--allow-read --deny-read=/etc" will allow read access to all FS but the
"/etc" directory.
Runtime permissions APIs ("Deno.permissions") were adjusted as well, mainly
by adding, a new "PermissionStatus.partial" field. This field denotes that
while permission might be granted to requested resource, it's only partial (ie.
a "--deny-*" flag was specified that excludes some of the requested resources).
Eg. specifying "--allow-read=foo/ --deny-read=foo/bar" and then querying for
permissions like "Deno.permissions.query({ name: "read", path: "foo/" })"
will return "PermissionStatus { state: "granted", onchange: null, partial: true }",
denoting that some of the subpaths don't have read access.
Closes #18804.
---------
Co-authored-by: Bartek IwaĆczuk <biwanczuk@gmail.com>
Co-authored-by: Nayeem Rahman <nayeemrmn99@gmail.com>
Diffstat (limited to 'cli/args/mod.rs')
-rw-r--r-- | cli/args/mod.rs | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/cli/args/mod.rs b/cli/args/mod.rs index cea0c0ca1..7b3b0aa83 100644 --- a/cli/args/mod.rs +++ b/cli/args/mod.rs @@ -2,7 +2,7 @@ mod config_file; mod flags; -mod flags_allow_net; +mod flags_net; mod import_map; mod lockfile; pub mod package_json; @@ -1105,13 +1105,21 @@ impl CliOptions { pub fn permissions_options(&self) -> PermissionsOptions { PermissionsOptions { allow_env: self.flags.allow_env.clone(), + deny_env: self.flags.deny_env.clone(), allow_hrtime: self.flags.allow_hrtime, + deny_hrtime: self.flags.deny_hrtime, allow_net: self.flags.allow_net.clone(), + deny_net: self.flags.deny_net.clone(), allow_ffi: self.flags.allow_ffi.clone(), + deny_ffi: self.flags.deny_ffi.clone(), allow_read: self.flags.allow_read.clone(), + deny_read: self.flags.deny_read.clone(), allow_run: self.flags.allow_run.clone(), + deny_run: self.flags.deny_run.clone(), allow_sys: self.flags.allow_sys.clone(), + deny_sys: self.flags.deny_sys.clone(), allow_write: self.flags.allow_write.clone(), + deny_write: self.flags.deny_write.clone(), prompt: !self.no_prompt(), } } |