Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Add sys permission kinds for node compat #24242

Merged
merged 3 commits into from
Jul 10, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
fix: Add sys permission kinds for node compat
* Support "statfs", "username", "getPriority" and "setPriority".
* Check username permission in node:os.userInfo() instead of unknown "userInfo" permission.
* Check for "uid" permission in node:process.geteuid() instead of "geteuid".
* Add missing "homedir" to SysPermissionDescriptor.kind union
  • Loading branch information
adamgreg committed Jun 26, 2024
commit a38a3caebda472b9898fe9f14c99e6e47cbc8275
7 changes: 6 additions & 1 deletion cli/tsc/dts/lib.deno.ns.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions ext/node/ops/os/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand All @@ -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)]
Expand Down
3 changes: 2 additions & 1 deletion runtime/permissions/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -915,7 +915,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" => Ok(kind),
| "systemMemoryInfo" | "uid" | "gid" | "username" | "cpus" | "homedir"
| "statfs" | "getPriority" | "setPriority" => Ok(kind),
_ => Err(type_error(format!("unknown system info kind \"{kind}\""))),
}
}
Expand Down