1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-12-25 00:29:09 -05:00

fix: enable "--allow-sys=cpus" for "deno run" (#22260)

Fixes #22221 with the suggested fix, and added "cpus" to the existing
tests.
This commit is contained in:
restlessronin 2024-02-07 12:08:40 +05:30 committed by GitHub
parent 6c15dc3f06
commit b16e6220a2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 5 additions and 2 deletions

View file

@ -41,6 +41,7 @@ Deno.test(async function permissionSysValidKind() {
await Deno.permissions.query({ name: "sys", kind: "hostname" }); await Deno.permissions.query({ name: "sys", kind: "hostname" });
await Deno.permissions.query({ name: "sys", kind: "uid" }); await Deno.permissions.query({ name: "sys", kind: "uid" });
await Deno.permissions.query({ name: "sys", kind: "gid" }); await Deno.permissions.query({ name: "sys", kind: "gid" });
await Deno.permissions.query({ name: "sys", kind: "cpus" });
}); });
Deno.test(function permissionSysValidKindSync() { Deno.test(function permissionSysValidKindSync() {
@ -51,6 +52,7 @@ Deno.test(function permissionSysValidKindSync() {
Deno.permissions.querySync({ name: "sys", kind: "hostname" }); Deno.permissions.querySync({ name: "sys", kind: "hostname" });
Deno.permissions.querySync({ name: "sys", kind: "uid" }); Deno.permissions.querySync({ name: "sys", kind: "uid" });
Deno.permissions.querySync({ name: "sys", kind: "gid" }); Deno.permissions.querySync({ name: "sys", kind: "gid" });
Deno.permissions.querySync({ name: "sys", kind: "cpus" });
}); });
Deno.test(async function permissionSysInvalidKind() { Deno.test(async function permissionSysInvalidKind() {

View file

@ -4936,7 +4936,8 @@ declare namespace Deno {
| "osRelease" | "osRelease"
| "osUptime" | "osUptime"
| "uid" | "uid"
| "gid"; | "gid"
| "cpus";
} }
/** The permission descriptor for the `allow-ffi` and `deny-ffi` permissions, which controls /** The permission descriptor for the `allow-ffi` and `deny-ffi` permissions, which controls

View file

@ -688,7 +688,7 @@ impl Descriptor for SysDescriptor {
pub fn parse_sys_kind(kind: &str) -> Result<&str, AnyError> { pub fn parse_sys_kind(kind: &str) -> Result<&str, AnyError> {
match kind { match kind {
"hostname" | "osRelease" | "osUptime" | "loadavg" | "networkInterfaces" "hostname" | "osRelease" | "osUptime" | "loadavg" | "networkInterfaces"
| "systemMemoryInfo" | "uid" | "gid" => Ok(kind), | "systemMemoryInfo" | "uid" | "gid" | "cpus" => Ok(kind),
_ => Err(type_error(format!("unknown system info kind \"{kind}\""))), _ => Err(type_error(format!("unknown system info kind \"{kind}\""))),
} }
} }