diff options
author | Adam Gregory <adam@aguilaengineering.com> | 2024-07-10 14:15:43 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-07-10 15:15:43 +0200 |
commit | 82f9216610ec9cc32697ca77cb95da4b229117d4 (patch) | |
tree | 96db85051b07a8979355d54b458fa6f283db713d | |
parent | 9a0d59d95df29202080cf40a6e0bda52ca7fa6a8 (diff) |
fix: Add sys permission kinds for node compat (#24242)
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>
-rw-r--r-- | cli/tsc/dts/lib.deno.ns.d.ts | 7 | ||||
-rw-r--r-- | ext/node/ops/os/mod.rs | 4 | ||||
-rw-r--r-- | runtime/permissions/lib.rs | 5 |
3 files changed, 10 insertions, 6 deletions
diff --git a/cli/tsc/dts/lib.deno.ns.d.ts b/cli/tsc/dts/lib.deno.ns.d.ts index c3a80e6db..ae8d4acf8 100644 --- a/cli/tsc/dts/lib.deno.ns.d.ts +++ b/cli/tsc/dts/lib.deno.ns.d.ts @@ -4969,7 +4969,12 @@ declare namespace Deno { | "osUptime" | "uid" | "gid" - | "cpus"; + | "username" + | "cpus" + | "homedir" + | "statfs" + | "getPriority" + | "setPriority"; } /** The permission descriptor for the `allow-ffi` and `deny-ffi` permissions, which controls diff --git a/ext/node/ops/os/mod.rs b/ext/node/ops/os/mod.rs index b7374dc32..ca91895f2 100644 --- a/ext/node/ops/os/mod.rs +++ b/ext/node/ops/os/mod.rs @@ -50,7 +50,7 @@ where { { let permissions = state.borrow_mut::<P>(); - permissions.check_sys("userInfo", "node:os.userInfo()")?; + permissions.check_sys("username", "node:os.userInfo()")?; } Ok(deno_whoami::username()) @@ -63,7 +63,7 @@ where { { let permissions = state.borrow_mut::<P>(); - permissions.check_sys("geteuid", "node:os.geteuid()")?; + permissions.check_sys("uid", "node:os.geteuid()")?; } #[cfg(windows)] diff --git a/runtime/permissions/lib.rs b/runtime/permissions/lib.rs index a2245316b..0d9d37a36 100644 --- a/runtime/permissions/lib.rs +++ b/runtime/permissions/lib.rs @@ -997,9 +997,8 @@ impl Descriptor for SysDescriptor { pub fn parse_sys_kind(kind: &str) -> Result<&str, AnyError> { match kind { "hostname" | "osRelease" | "osUptime" | "loadavg" | "networkInterfaces" - | "systemMemoryInfo" | "uid" | "gid" | "cpus" | "homedir" | "getegid" => { - Ok(kind) - } + | "systemMemoryInfo" | "uid" | "gid" | "cpus" | "homedir" | "getegid" + | "username" | "statfs" | "getPriority" | "setPriority" => Ok(kind), _ => Err(type_error(format!("unknown system info kind \"{kind}\""))), } } |