summaryrefslogtreecommitdiff
path: root/runtime/permissions/lib.rs
AgeCommit message (Collapse)Author
2024-11-12chore: make fields public on `PermissionDeniedError` and ↵Richard Carson
`deno_kv::KvConfig` (#26798) A few small changes to avoid needing unsafe mem transmutes to instantiate the extensions --------- Signed-off-by: Richard Carson <Rscarson@rogers.com>
2024-11-12fix(ext/node): handle `--allow-sys=inspector` (#26836)Divy Srivastava
`op_inspector_open` checks for "inspector" as one of the allowed sys value.
2024-11-04refactor(runtime/permissions): use concrete error types (#26464)Leo Kettmeir
2024-10-31fix(node): Implement `os.userInfo` properly, add missing `toPrimitive` (#24702)Nathan Whitaker
Fixes the implementation of `os.userInfo`, and adds a missing `toPrimitive` for `tmpdir`. This allows us to enable the corresponding node_compat test.
2024-10-17feat(permissions): expose PromptResponse (#26358)Lucas Nogueira
follow-up for #26327
2024-10-17feat(permissions): expose PermissionPrompter and set_prompter function (#26327)Lucas Nogueira
when defining a custom runtime, it might be useful to define a custom prompter - for instance when you are not relying on the terminal and want a GUI prompter instead
2024-10-04refactor: improve node permission checks (#26028)David Sherret
Does less work when requesting permissions with `-A`
2024-10-03fix: don't prompt when using `Deno.permissions.request` with `--no-prompt` ↵Simon Lecoq
(#25811)
2024-09-30refactor: bury descriptor parsing in PermissionsContainer (#25936)David Sherret
Closes https://github.com/denoland/deno/issues/25634
2024-09-28refactor: use deno_path_util (#25918)David Sherret
2024-09-26feat: add `--allow-import` flag (#25469)Bartek Iwańczuk
This replaces `--allow-net` for import permissions and makes the security sandbox stricter by also checking permissions for statically analyzable imports. By default, this has a value of `--allow-import=deno.land:443,jsr.io:443,esm.sh:443,raw.githubusercontent.com:443,gist.githubusercontent.com:443`, but that can be overridden by providing a different set of hosts. Additionally, when no value is provided, import permissions are inferred from the CLI arguments so the following works because `fresh.deno.dev:443` will be added to the list of allowed imports: ```ts deno run -A -r https://fresh.deno.dev ``` --------- Co-authored-by: David Sherret <dsherret@gmail.com>
2024-09-20fix(flags): properly error out for urls (#25770)Leo Kettmeir
Closes https://github.com/denoland/deno/issues/25760
2024-09-18fix: do not panic running invalid file specifier (#25530)Yazan AbdAl-Rahman
Co-authored-by: Bedis Nbiba <bedisnbiba@gmail.com>
2024-09-16refactor(permissions): split up Descriptor into Allow, Deny, and Query (#25508)David Sherret
This makes the permission system more versatile.
2024-09-10feat(cli): use NotCapable error for permission errors (#25431)Luca Casonato
Closes #7394 --------- Co-authored-by: snek <snek@deno.com>
2024-09-06refactor(permissions): remove FromStr implementations, add ::parse methods ↵Bartek Iwańczuk
(#25473) The `.parse()` calls in permission code are only making it more confusing, verbosity is encouraged and welcome in this code even at the cost of not being concise. Left a couple TODOs to not use `AnyError`.
2024-09-04fix(regression): do not expose resolved path in Deno.Command permission ↵David Sherret
denied error (#25434) Regression from https://github.com/denoland/deno/pull/25370
2024-09-04fix: lock down allow-run permissions more (#25370)David Sherret
`--allow-run` even with an allow list has essentially been `--allow-all`... this locks it down more. 1. Resolves allow list for `--allow-run=` on startup to an absolute path, then uses these paths when evaluating if a command can execute. Also, adds these paths to `--deny-write` 1. Resolves the environment (cwd and env vars) before evaluating permissions and before executing a command. Then uses this environment to evaluate the permissions and then evaluate the command.
2024-09-03BREAKING(permissions): remove --allow-hrtime (#25367)Luca Casonato
Remove `--allow-hrtime` and `--deny-hrtime`. We are doing this because it is already possible to get access to high resolution timers through workers and SharedArrayBuffer. Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
2024-08-20fix(cli): update permission prompt message for compiled binaries (#24081)Yazan AbdAl-Rahman
Co-authored-by: David Sherret <dsherret@gmail.com>
2024-08-19chore: improve accessing special file test (#25099)David Sherret
2024-07-10fix: Add sys permission kinds for node compat (#24242)Adam Gregory
Fixes #24241 * Support "statfs", "username", "getPriority" and "setPriority" kinds for `--allow-sys`. * Check individual permissions in `node:os.userInfo()` instead of a single "userInfo" permission. * Check for "uid" permission in `node:process.geteuid()` instead of "geteuid". * Add missing "homedir" to `SysPermissionDescriptor.kind` union Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
2024-07-05fix(permissions): handle ipv6 addresses correctly (#24397)Luca Casonato
Also don't panic on invalid domain names and addresses. Extracted with cleanups up from #24080 Co-authored-by: Yazan AbdAl-Rahman <yazan.abdalrahman@exalt.ps>
2024-07-05fix(node): Implement `fs.lchown` (and `process.getegid`) (#24418)Nathan Whitaker
Closes https://github.com/denoland/deno/issues/21260. Part of https://github.com/denoland/deno/issues/18218. Implements `node:fs.lchown`, and enables the node_compat test for it. The test uses `process.getegid`, which we didn't have implemented, so I went ahead and implemented that as well to get the test working.
2024-06-14chore: upgrade to rust 1.79 (#24207)Satya Rohith
2024-05-16fix(ext/node): homedir() `getpwuid`/`SHGetKnownFolderPath` fallback (#23841)Divy Srivastava
**Unix**: Returns the value of the HOME environment variable if it is set even if it is an empty string. Otherwise, it tries to determine the home directory by invoking the [getpwuid_r](https://linux.die.net/man/3/getpwuid_r) function with the UID of the current user. **Windows**: Returns the value of the USERPROFILE environment variable if it is set and it is not an empty string. Otherwise, it tries to determine the home directory by invoking the [SHGetKnownFolderPath](https://learn.microsoft.com/en-us/windows/win32/api/shlobj_core/nf-shlobj_core-shgetknownfolderpath) function with [FOLDERID_Profile](https://learn.microsoft.com/en-us/windows/win32/shell/knownfolderid). Fixes https://github.com/denoland/deno/issues/23824
2024-05-10fix(runtime): Allow opening /dev/fd/XXX for unix (#23743)Matt Mastracci
`deno run script.ts <(some command)` is a valid use case -- let's allow this to work without `--allow-all`. Fixes #23703
2024-05-08fix(runtime): allow nul device on windows (#23741)Matt Mastracci
Fixes [23721](https://github.com/denoland/deno/issues/23721)
2024-05-07fix(runtime): allow r/w access to /etc without --allow-all (#23718)Luca Casonato
This is not a special path that can be used to escalate or bypass Deno permissions, such as `--allow-env`.
2024-04-19feat(runtime): Allow embedders to perform additional access checks on file ↵Matt Mastracci
open (#23208) Embedders may have special requirements around file opening, so we add a new `check_open` permission check that is called as part of the file open process.
2024-03-26fix(runtime): use FQDN in NetDescriptor (#23084)Nayeem Rahman
2024-03-13perf(permissions): Fast exit from checks when permission is in ↵Matt Mastracci
"fully-granted" state (#22894) Skips the access check if the specific unary permission is in an all-granted state. Generally prevents an allocation or two. Hooks up a quiet "all" permission that is automatically inherited. This permission will be used in the future to indicate that the user wishes to accept all side-effects of the permissions they explicitly granted. The "all" permission is an "ambient flag"-style permission that states whether "allow-all" was passed on the command-line.
2024-03-13chore(permissions): add allow_all flag (#22890)Matt Mastracci
Unlocking a potential perf optimization at a later date -- carry the `allow_all` flag into the permission container.
2024-03-12fix(runtime): negate partial condition for deny flags (#22866)Nayeem Rahman
2024-03-12refactor: add `deno_permissions` crate (#22236)Divy Srivastava
Issue https://github.com/denoland/deno/issues/22222 ![image](https://github.com/denoland/deno/assets/34997667/2af8474b-b919-4519-98ce-9d29bc7829f2) This PR moves `runtime/permissions` code to a upstream crate called `deno_permissions`. The `deno_permissions::PermissionsContainer` is put into the OpState and can be used instead of the current trait-based permissions system. For this PR, I've migrated `deno_fetch` to the new crate but kept the rest of the trait-based system as a wrapper of `deno_permissions` crate. Doing the migration all at once is error prone and hard to review. Comparing incremental compile times for `ext/fetch` on Mac M1: | profile | `cargo build --bin deno` | `cargo plonk build --bin deno` | | --------- | ------------- | ------------------- | | `debug` | 20 s | 0.8s | | `release` | 4 mins 12 s | 1.4s |