mirror of
https://github.com/denoland/deno.git
synced 2024-11-24 15:19:26 -05:00
feat(cli): use NotCapable error for permission errors (#25431)
Closes #7394 --------- Co-authored-by: snek <snek@deno.com>
This commit is contained in:
parent
be5419d479
commit
7bfcb4dd10
71 changed files with 207 additions and 206 deletions
16
Cargo.lock
generated
16
Cargo.lock
generated
|
@ -1405,9 +1405,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "deno_core"
|
||||
version = "0.307.0"
|
||||
version = "0.308.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "154b0902402807a043579102f949e6dd6f3a09d2d5049929fd710fc3192bf109"
|
||||
checksum = "62fc8250fa9da059cc05b18328319a9048c73e4889ca929cc60877a8a1bfc4d4"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"bincode",
|
||||
|
@ -1887,9 +1887,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "deno_ops"
|
||||
version = "0.183.0"
|
||||
version = "0.184.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9114f9eb6419839f1ab9668f91c463238945bb974e1998629a703f72b4608daf"
|
||||
checksum = "24a465b7d691ad7cae41e8f51bd954b1e3ffd201b84dc30de2c16cf91034946e"
|
||||
dependencies = [
|
||||
"proc-macro-rules",
|
||||
"proc-macro2",
|
||||
|
@ -6257,9 +6257,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "serde_v8"
|
||||
version = "0.216.0"
|
||||
version = "0.217.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1733b8192f123beedd2fc7998efeaf2a0b8bfa35c01537f50b690e786db8024c"
|
||||
checksum = "467c0a7bfc67cd918f1f7ab7a5ab70a9e744e466ff428cd728ff2c03bc77874c"
|
||||
dependencies = [
|
||||
"num-bigint",
|
||||
"serde",
|
||||
|
@ -7912,9 +7912,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "v8"
|
||||
version = "0.105.0"
|
||||
version = "0.106.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "692624c4fd58ff50aa6d690c159df18e7881c13970005b9b2bff77dc425fd370"
|
||||
checksum = "a381badc47c6f15acb5fe0b5b40234162349ed9d4e4fd7c83a7f5547c0fc69c5"
|
||||
dependencies = [
|
||||
"bindgen",
|
||||
"bitflags 2.6.0",
|
||||
|
|
|
@ -45,7 +45,7 @@ repository = "https://github.com/denoland/deno"
|
|||
|
||||
[workspace.dependencies]
|
||||
deno_ast = { version = "=0.42.0", features = ["transpiling"] }
|
||||
deno_core = { version = "0.307.0" }
|
||||
deno_core = { version = "0.308.0" }
|
||||
|
||||
deno_bench_util = { version = "0.162.0", path = "./bench_util" }
|
||||
deno_lockfile = "=0.23.0"
|
||||
|
|
16
cli/tsc/dts/lib.deno.ns.d.ts
vendored
16
cli/tsc/dts/lib.deno.ns.d.ts
vendored
|
@ -175,8 +175,11 @@ declare namespace Deno {
|
|||
/**
|
||||
* Raised when the underlying operating system indicates the current user
|
||||
* which the Deno process is running under does not have the appropriate
|
||||
* permissions to a file or resource, or the user _did not_ provide required
|
||||
* `--allow-*` flag.
|
||||
* permissions to a file or resource.
|
||||
*
|
||||
* Before Deno 2.0, this error was raised when the user _did not_ provide
|
||||
* required `--allow-*` flag. As of Deno 2.0, that case is now handled by
|
||||
* the {@link NotCapable} error.
|
||||
*
|
||||
* @category Errors */
|
||||
export class PermissionDenied extends Error {}
|
||||
|
@ -314,6 +317,15 @@ declare namespace Deno {
|
|||
*
|
||||
* @category Errors */
|
||||
export class NotADirectory extends Error {}
|
||||
/**
|
||||
* Raised when trying to perform an operation while the relevant Deno
|
||||
* permission (like `--allow-read`) has not been granted.
|
||||
*
|
||||
* Before Deno 2.0, this condition was covered by the {@link PermissionDenied}
|
||||
* error.
|
||||
*
|
||||
* @category Errors */
|
||||
export class NotCapable extends Error {}
|
||||
}
|
||||
|
||||
/** The current process ID of this instance of the Deno CLI.
|
||||
|
|
|
@ -91,7 +91,7 @@ impl FsPermissions for deno_permissions::PermissionsContainer {
|
|||
if resolved {
|
||||
self
|
||||
.check_special_file(path, api_name)
|
||||
.map_err(FsError::PermissionDenied)?;
|
||||
.map_err(FsError::NotCapable)?;
|
||||
return Ok(Cow::Borrowed(path));
|
||||
}
|
||||
|
||||
|
@ -99,11 +99,11 @@ impl FsPermissions for deno_permissions::PermissionsContainer {
|
|||
let read = read || !write;
|
||||
if read {
|
||||
FsPermissions::check_read(self, path, api_name)
|
||||
.map_err(|_| FsError::PermissionDenied("read"))?;
|
||||
.map_err(|_| FsError::NotCapable("read"))?;
|
||||
}
|
||||
if write {
|
||||
FsPermissions::check_write(self, path, api_name)
|
||||
.map_err(|_| FsError::PermissionDenied("write"))?;
|
||||
.map_err(|_| FsError::NotCapable("write"))?;
|
||||
}
|
||||
Ok(Cow::Borrowed(path))
|
||||
}
|
||||
|
|
|
@ -60,7 +60,7 @@ fn map_permission_error(
|
|||
path: &Path,
|
||||
) -> AnyError {
|
||||
match error {
|
||||
FsError::PermissionDenied(err) => {
|
||||
FsError::NotCapable(err) => {
|
||||
let path = format!("{path:?}");
|
||||
let (path, truncated) = if path.len() > 1024 {
|
||||
(&path[0..1024], "...(truncated)")
|
||||
|
@ -74,7 +74,7 @@ fn map_permission_error(
|
|||
format!(
|
||||
"Requires {err} access to {path}{truncated}, run again with the --allow-{err} flag")
|
||||
};
|
||||
custom_error("PermissionDenied", msg)
|
||||
custom_error("NotCapable", msg)
|
||||
}
|
||||
err => Err::<(), _>(err)
|
||||
.context_path(operation, path)
|
||||
|
|
10
ext/io/fs.rs
10
ext/io/fs.rs
|
@ -22,7 +22,7 @@ pub enum FsError {
|
|||
Io(io::Error),
|
||||
FileBusy,
|
||||
NotSupported,
|
||||
PermissionDenied(&'static str),
|
||||
NotCapable(&'static str),
|
||||
}
|
||||
|
||||
impl FsError {
|
||||
|
@ -31,7 +31,7 @@ impl FsError {
|
|||
Self::Io(err) => err.kind(),
|
||||
Self::FileBusy => io::ErrorKind::Other,
|
||||
Self::NotSupported => io::ErrorKind::Other,
|
||||
Self::PermissionDenied(_) => io::ErrorKind::PermissionDenied,
|
||||
Self::NotCapable(_) => io::ErrorKind::Other,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -40,7 +40,7 @@ impl FsError {
|
|||
FsError::Io(err) => err,
|
||||
FsError::FileBusy => io::Error::new(self.kind(), "file busy"),
|
||||
FsError::NotSupported => io::Error::new(self.kind(), "not supported"),
|
||||
FsError::PermissionDenied(err) => {
|
||||
FsError::NotCapable(err) => {
|
||||
io::Error::new(self.kind(), format!("requires {err} access"))
|
||||
}
|
||||
}
|
||||
|
@ -65,8 +65,8 @@ impl From<FsError> for AnyError {
|
|||
FsError::Io(err) => AnyError::from(err),
|
||||
FsError::FileBusy => resource_unavailable(),
|
||||
FsError::NotSupported => not_supported(),
|
||||
FsError::PermissionDenied(err) => {
|
||||
custom_error("PermissionDenied", format!("permission denied: {err}"))
|
||||
FsError::NotCapable(err) => {
|
||||
custom_error("NotCapable", format!("permission denied: {err}"))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -53,8 +53,8 @@ function denoEnvGet(name: string) {
|
|||
} catch (e) {
|
||||
if (
|
||||
ObjectPrototypeIsPrototypeOf(TypeErrorPrototype, e) ||
|
||||
// TODO(iuioiua): Use `PermissionDeniedPrototype` when it's available
|
||||
ObjectPrototypeIsPrototypeOf(Deno.errors.PermissionDenied.prototype, e)
|
||||
// TODO(iuioiua): Use `NotCapablePrototype` when it's available
|
||||
ObjectPrototypeIsPrototypeOf(Deno.errors.NotCapable.prototype, e)
|
||||
) {
|
||||
return undefined;
|
||||
}
|
||||
|
|
|
@ -160,16 +160,8 @@ export class Pipe extends ConnectionWrap {
|
|||
}
|
||||
},
|
||||
(e) => {
|
||||
// TODO(cmorten): correct mapping of connection error to status code.
|
||||
let code: number;
|
||||
|
||||
if (e instanceof Deno.errors.NotFound) {
|
||||
code = codeMap.get("ENOENT")!;
|
||||
} else if (e instanceof Deno.errors.PermissionDenied) {
|
||||
code = codeMap.get("EACCES")!;
|
||||
} else {
|
||||
code = codeMap.get("ECONNREFUSED")!;
|
||||
}
|
||||
const code = codeMap.get(e.code ?? "UNKNOWN") ??
|
||||
codeMap.get("UNKNOWN")!;
|
||||
|
||||
try {
|
||||
this.afterConnect(req, code);
|
||||
|
@ -207,16 +199,10 @@ export class Pipe extends ConnectionWrap {
|
|||
try {
|
||||
listener = Deno.listen(listenOptions);
|
||||
} catch (e) {
|
||||
if (e instanceof Deno.errors.AddrInUse) {
|
||||
return codeMap.get("EADDRINUSE")!;
|
||||
} else if (e instanceof Deno.errors.AddrNotAvailable) {
|
||||
return codeMap.get("EADDRNOTAVAIL")!;
|
||||
} else if (e instanceof Deno.errors.PermissionDenied) {
|
||||
if (e instanceof Deno.errors.NotCapable) {
|
||||
throw e;
|
||||
}
|
||||
|
||||
// TODO(cmorten): map errors to appropriate error codes.
|
||||
return codeMap.get("UNKNOWN")!;
|
||||
return codeMap.get(e.code ?? "UNKNOWN") ?? codeMap.get("UNKNOWN")!;
|
||||
}
|
||||
|
||||
const address = listener.addr as Deno.UnixAddr;
|
||||
|
|
|
@ -212,16 +212,10 @@ export class TCP extends ConnectionWrap {
|
|||
try {
|
||||
listener = Deno.listen(listenOptions);
|
||||
} catch (e) {
|
||||
if (e instanceof Deno.errors.AddrInUse) {
|
||||
return codeMap.get("EADDRINUSE")!;
|
||||
} else if (e instanceof Deno.errors.AddrNotAvailable) {
|
||||
return codeMap.get("EADDRNOTAVAIL")!;
|
||||
} else if (e instanceof Deno.errors.PermissionDenied) {
|
||||
if (e instanceof Deno.errors.NotCapable) {
|
||||
throw e;
|
||||
}
|
||||
|
||||
// TODO(cmorten): map errors to appropriate error codes.
|
||||
return codeMap.get("UNKNOWN")!;
|
||||
return codeMap.get(e.code ?? "UNKNOWN") ?? codeMap.get("UNKNOWN")!;
|
||||
}
|
||||
|
||||
const address = listener.addr as Deno.NetAddr;
|
||||
|
|
|
@ -337,16 +337,10 @@ export class UDP extends HandleWrap {
|
|||
try {
|
||||
listener = DenoListenDatagram(listenOptions);
|
||||
} catch (e) {
|
||||
if (e instanceof Deno.errors.AddrInUse) {
|
||||
return codeMap.get("EADDRINUSE")!;
|
||||
} else if (e instanceof Deno.errors.AddrNotAvailable) {
|
||||
return codeMap.get("EADDRNOTAVAIL")!;
|
||||
} else if (e instanceof Deno.errors.PermissionDenied) {
|
||||
if (e instanceof Deno.errors.NotCapable) {
|
||||
throw e;
|
||||
}
|
||||
|
||||
// TODO(cmorten): map errors to appropriate error codes.
|
||||
return codeMap.get("UNKNOWN")!;
|
||||
return codeMap.get(e.code ?? "UNKNOWN") ?? codeMap.get("UNKNOWN")!;
|
||||
}
|
||||
|
||||
const address = listener.addr as Deno.NetAddr;
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
|
||||
|
||||
import { core, primordials } from "ext:core/mod.js";
|
||||
const { BadResource, Interrupted, PermissionDenied } = core;
|
||||
const { BadResource, Interrupted, NotCapable } = core;
|
||||
const { Error } = primordials;
|
||||
|
||||
class NotFound extends Error {
|
||||
|
@ -116,6 +116,13 @@ class Busy extends Error {
|
|||
}
|
||||
}
|
||||
|
||||
class PermissionDenied extends Error {
|
||||
constructor(msg) {
|
||||
super(msg);
|
||||
this.name = "PermissionDenied";
|
||||
}
|
||||
}
|
||||
|
||||
class NotSupported extends Error {
|
||||
constructor(msg) {
|
||||
super(msg);
|
||||
|
@ -176,6 +183,7 @@ const errors = {
|
|||
IsADirectory,
|
||||
NetworkUnreachable,
|
||||
NotADirectory,
|
||||
NotCapable,
|
||||
};
|
||||
|
||||
export { errors };
|
||||
|
|
|
@ -294,6 +294,7 @@ core.registerErrorClass("NotConnected", errors.NotConnected);
|
|||
core.registerErrorClass("AddrInUse", errors.AddrInUse);
|
||||
core.registerErrorClass("AddrNotAvailable", errors.AddrNotAvailable);
|
||||
core.registerErrorClass("BrokenPipe", errors.BrokenPipe);
|
||||
core.registerErrorClass("PermissionDenied", errors.PermissionDenied);
|
||||
core.registerErrorClass("AlreadyExists", errors.AlreadyExists);
|
||||
core.registerErrorClass("InvalidData", errors.InvalidData);
|
||||
core.registerErrorClass("TimedOut", errors.TimedOut);
|
||||
|
|
|
@ -609,7 +609,7 @@ fn check_run_permission(
|
|||
// we don't allow users to launch subprocesses with any LD_ or DYLD_*
|
||||
// env vars set because this allows executing code (ex. LD_PRELOAD)
|
||||
return Err(deno_core::error::custom_error(
|
||||
"PermissionDenied",
|
||||
"NotCapable",
|
||||
format!(
|
||||
"Requires --allow-all permissions to spawn subprocess with {} environment variable{}.",
|
||||
env_var_names.join(", "),
|
||||
|
|
|
@ -144,7 +144,7 @@ impl PermissionState {
|
|||
name
|
||||
)
|
||||
};
|
||||
custom_error("PermissionDenied", msg)
|
||||
custom_error("NotCapable", msg)
|
||||
}
|
||||
|
||||
/// Check the permission state. bool is whether a prompt was issued.
|
||||
|
@ -1999,10 +1999,7 @@ fn parse_run_list(
|
|||
}
|
||||
|
||||
fn escalation_error() -> AnyError {
|
||||
custom_error(
|
||||
"PermissionDenied",
|
||||
"Can't escalate parent thread permissions",
|
||||
)
|
||||
custom_error("NotCapable", "Can't escalate parent thread permissions")
|
||||
}
|
||||
|
||||
#[derive(Debug, Eq, PartialEq)]
|
||||
|
|
|
@ -367,7 +367,7 @@ fn standalone_runtime_flags() {
|
|||
.run()
|
||||
.assert_stdout_matches_text("0.147205063401058\n")
|
||||
.assert_stderr_matches_text(
|
||||
"[WILDCARD]PermissionDenied: Requires write access to[WILDCARD]",
|
||||
"[WILDCARD]NotCapable: Requires write access to[WILDCARD]",
|
||||
)
|
||||
.assert_exit_code(1);
|
||||
}
|
||||
|
|
|
@ -3145,7 +3145,7 @@ fn issue9750() {
|
|||
console.write_line_raw("n");
|
||||
console.expect_all(&[
|
||||
"Denied env access to \"SECRET\".",
|
||||
"PermissionDenied: Requires env access to \"SECRET\", run again with the --allow-env flag",
|
||||
"NotCapable: Requires env access to \"SECRET\", run again with the --allow-env flag",
|
||||
]);
|
||||
});
|
||||
}
|
||||
|
@ -4051,7 +4051,7 @@ async fn test_resolve_dns() {
|
|||
let out = String::from_utf8_lossy(&output.stdout);
|
||||
assert!(!output.status.success());
|
||||
assert!(err.starts_with("Check file"));
|
||||
assert!(err.contains(r#"error: Uncaught (in promise) PermissionDenied: Requires net access to "127.0.0.1:4553""#));
|
||||
assert!(err.contains(r#"error: Uncaught (in promise) NotCapable: Requires net access to "127.0.0.1:4553""#));
|
||||
assert!(out.is_empty());
|
||||
}
|
||||
|
||||
|
@ -4072,7 +4072,7 @@ async fn test_resolve_dns() {
|
|||
let out = String::from_utf8_lossy(&output.stdout);
|
||||
assert!(!output.status.success());
|
||||
assert!(err.starts_with("Check file"));
|
||||
assert!(err.contains(r#"error: Uncaught (in promise) PermissionDenied: Requires net access to "127.0.0.1:4553""#));
|
||||
assert!(err.contains(r#"error: Uncaught (in promise) NotCapable: Requires net access to "127.0.0.1:4553""#));
|
||||
assert!(out.is_empty());
|
||||
}
|
||||
|
||||
|
|
|
@ -6,16 +6,16 @@ Runtime | Deno [WILDLINE] ([WILDLINE])
|
|||
|
||||
benchmark time/iter (avg) iter/s (min … max) p75 p99 p995
|
||||
----------- ----------------------------- --------------------- --------------------------
|
||||
read error: PermissionDenied: Can't escalate parent thread permissions
|
||||
read error: NotCapable: Can't escalate parent thread permissions
|
||||
[WILDCARD]
|
||||
write error: PermissionDenied: Can't escalate parent thread permissions
|
||||
write error: NotCapable: Can't escalate parent thread permissions
|
||||
[WILDCARD]
|
||||
net error: PermissionDenied: Can't escalate parent thread permissions
|
||||
net error: NotCapable: Can't escalate parent thread permissions
|
||||
[WILDCARD]
|
||||
env error: PermissionDenied: Can't escalate parent thread permissions
|
||||
env error: NotCapable: Can't escalate parent thread permissions
|
||||
[WILDCARD]
|
||||
run error: PermissionDenied: Can't escalate parent thread permissions
|
||||
run error: NotCapable: Can't escalate parent thread permissions
|
||||
[WILDCARD]
|
||||
ffi error: PermissionDenied: Can't escalate parent thread permissions
|
||||
ffi error: NotCapable: Can't escalate parent thread permissions
|
||||
[WILDCARD]
|
||||
error: Bench failed
|
||||
|
|
|
@ -5,6 +5,6 @@ Runtime | Deno [WILDCARD] ([WILDCARD])
|
|||
|
||||
benchmark time/iter (avg) iter/s (min … max) p75 p99 p995
|
||||
----------- ----------------------------- --------------------- --------------------------
|
||||
no prompt error: PermissionDenied: Requires read access to "./some_file.txt", run again with the --allow-read flag
|
||||
no prompt error: NotCapable: Requires read access to "./some_file.txt", run again with the --allow-read flag
|
||||
[WILDCARD]
|
||||
error: Bench failed
|
||||
|
|
|
@ -5,6 +5,6 @@ Runtime | Deno [WILDCARD] ([WILDCARD])
|
|||
|
||||
benchmark time/iter (avg) iter/s (min … max) p75 p99 p995
|
||||
----------- ----------------------------- --------------------- --------------------------
|
||||
no prompt error: PermissionDenied: Requires read access to "./some_file.txt", run again with the --allow-read flag
|
||||
no prompt error: NotCapable: Requires read access to "./some_file.txt", run again with the --allow-read flag
|
||||
[WILDCARD]
|
||||
error: Bench failed
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
error: Uncaught (in promise) PermissionDenied: Requires run access to "deno", specify the required permissions during compilation using `deno compile --allow-run`
|
||||
error: Uncaught (in promise) NotCapable: Requires run access to "deno", specify the required permissions during compilation using `deno compile --allow-run`
|
||||
[WILDCARD]
|
|
@ -1,11 +1,11 @@
|
|||
Running...
|
||||
PermissionDenied: Requires run access to "deno", run again with the --allow-run flag
|
||||
NotCapable: Requires run access to "deno", run again with the --allow-run flag
|
||||
[WILDCARD]
|
||||
at file:///[WILDLINE]/sub.ts:15:5 {
|
||||
name: "PermissionDenied"
|
||||
name: "NotCapable"
|
||||
}
|
||||
PermissionDenied: Requires run access to "deno", run again with the --allow-run flag
|
||||
NotCapable: Requires run access to "deno", run again with the --allow-run flag
|
||||
[WILDCARD]
|
||||
at file:///[WILDLINE]/sub.ts:23:22 {
|
||||
name: "PermissionDenied"
|
||||
name: "NotCapable"
|
||||
}
|
||||
|
|
|
@ -7,10 +7,10 @@ const testCases = [
|
|||
[["darwin", "linux"], null, "/etc/passwd"],
|
||||
[["windows"], null, "\\\\.\\nul"],
|
||||
// Denied, requires `--allow-all`
|
||||
[["darwin", "linux"], /PermissionDenied/, "/dev/ptmx"],
|
||||
[["linux"], /PermissionDenied/, "/proc/self/environ"],
|
||||
[["linux"], /PermissionDenied/, "/proc/self/mem"],
|
||||
[["windows"], /PermissionDenied/, "\\\\.\\PhysicalDrive0"],
|
||||
[["darwin", "linux"], /NotCapable/, "/dev/ptmx"],
|
||||
[["linux"], /NotCapable/, "/proc/self/environ"],
|
||||
[["linux"], /NotCapable/, "/proc/self/mem"],
|
||||
[["windows"], /NotCapable/, "\\\\.\\PhysicalDrive0"],
|
||||
];
|
||||
|
||||
const os = Deno.build.os;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
Running...
|
||||
error: Uncaught (in promise) PermissionDenied: Requires write access to "binary[WILDLINE]", run again with the --allow-write flag
|
||||
error: Uncaught (in promise) NotCapable: Requires write access to "binary[WILDLINE]", run again with the --allow-write flag
|
||||
Deno.writeTextFileSync(binaryName, "");
|
||||
^
|
||||
at [WILDCARD]
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
PermissionDenied: Requires --allow-all permissions to spawn subprocess with LD_PRELOAD environment variable.
|
||||
NotCapable: Requires --allow-all permissions to spawn subprocess with LD_PRELOAD environment variable.
|
||||
[WILDCARD]
|
||||
name: "PermissionDenied"
|
||||
name: "NotCapable"
|
||||
}
|
||||
PermissionDenied: Requires --allow-all permissions to spawn subprocess with LD_PRELOAD environment variable.
|
||||
NotCapable: Requires --allow-all permissions to spawn subprocess with LD_PRELOAD environment variable.
|
||||
[WILDCARD]
|
||||
name: "PermissionDenied"
|
||||
name: "NotCapable"
|
||||
}
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
PermissionDenied: Requires --allow-all permissions to spawn subprocess with LD_PRELOAD environment variable.
|
||||
NotCapable: Requires --allow-all permissions to spawn subprocess with LD_PRELOAD environment variable.
|
||||
[WILDCARD]
|
||||
name: "PermissionDenied"
|
||||
name: "NotCapable"
|
||||
}
|
||||
PermissionDenied: Requires --allow-all permissions to spawn subprocess with DYLD_FALLBACK_LIBRARY_PATH, LD_PRELOAD environment variables.
|
||||
NotCapable: Requires --allow-all permissions to spawn subprocess with DYLD_FALLBACK_LIBRARY_PATH, LD_PRELOAD environment variables.
|
||||
[WILDCARD]
|
||||
name: "PermissionDenied"
|
||||
name: "NotCapable"
|
||||
}
|
||||
|
|
12
tests/testdata/bench/allow_none.out
vendored
12
tests/testdata/bench/allow_none.out
vendored
|
@ -6,16 +6,16 @@ Runtime | Deno [WILDCARD] ([WILDCARD])
|
|||
|
||||
benchmark time/iter (avg) iter/s (min … max) p75 p99 p995
|
||||
----------- ----------------------------- --------------------- --------------------------
|
||||
read error: PermissionDenied: Can't escalate parent thread permissions
|
||||
read error: NotCapable: Can't escalate parent thread permissions
|
||||
[WILDCARD]
|
||||
write error: PermissionDenied: Can't escalate parent thread permissions
|
||||
write error: NotCapable: Can't escalate parent thread permissions
|
||||
[WILDCARD]
|
||||
net error: PermissionDenied: Can't escalate parent thread permissions
|
||||
net error: NotCapable: Can't escalate parent thread permissions
|
||||
[WILDCARD]
|
||||
env error: PermissionDenied: Can't escalate parent thread permissions
|
||||
env error: NotCapable: Can't escalate parent thread permissions
|
||||
[WILDCARD]
|
||||
run error: PermissionDenied: Can't escalate parent thread permissions
|
||||
run error: NotCapable: Can't escalate parent thread permissions
|
||||
[WILDCARD]
|
||||
ffi error: PermissionDenied: Can't escalate parent thread permissions
|
||||
ffi error: NotCapable: Can't escalate parent thread permissions
|
||||
[WILDCARD]
|
||||
error: Bench failed
|
||||
|
|
|
@ -5,6 +5,6 @@ Runtime | Deno [WILDCARD] ([WILDCARD])
|
|||
|
||||
benchmark time/iter (avg) iter/s (min … max) p75 p99 p995
|
||||
----------- ----------------------------- --------------------- --------------------------
|
||||
no prompt error: PermissionDenied: Requires read access to "./some_file.txt", run again with the --allow-read flag
|
||||
no prompt error: NotCapable: Requires read access to "./some_file.txt", run again with the --allow-read flag
|
||||
[WILDCARD]
|
||||
error: Bench failed
|
||||
|
|
|
@ -5,6 +5,6 @@ Runtime | Deno [WILDCARD] ([WILDCARD])
|
|||
|
||||
benchmark time/iter (avg) iter/s (min … max) p75 p99 p995
|
||||
----------- ----------------------------- --------------------- --------------------------
|
||||
no prompt error: PermissionDenied: Requires read access to "./some_file.txt", run again with the --allow-read flag
|
||||
no prompt error: NotCapable: Requires read access to "./some_file.txt", run again with the --allow-read flag
|
||||
[WILDCARD]
|
||||
error: Bench failed
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
error: Uncaught PermissionDenied: Requires read access to <CWD>, specify the required permissions during compilation using `deno compile --allow-read`
|
||||
error: Uncaught NotCapable: Requires read access to <CWD>, specify the required permissions during compilation using `deno compile --allow-read`
|
||||
[WILDCARD]
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
[WILDCARD]error: Uncaught (in promise) PermissionDenied: Requires read access to "non-existent", run again with the --allow-read flag
|
||||
[WILDCARD]error: Uncaught (in promise) NotCapable: Requires read access to "non-existent", run again with the --allow-read flag
|
||||
Deno.readFileSync("non-existent");
|
||||
^
|
||||
at [WILDCARD]
|
||||
|
|
2
tests/testdata/run/089_run_allow_list.ts.out
vendored
2
tests/testdata/run/089_run_allow_list.ts.out
vendored
|
@ -1,3 +1,3 @@
|
|||
[WILDCARD]PermissionDenied: Requires run access to "ls", run again with the --allow-run flag
|
||||
[WILDCARD]NotCapable: Requires run access to "ls", run again with the --allow-run flag
|
||||
[WILDCARD]
|
||||
true
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
ok
|
||||
[WILDCARD]error: Uncaught (in promise) PermissionDenied: Requires env access to "NOT_NODE_DEBUG", run again with the --allow-env flag
|
||||
[WILDCARD]error: Uncaught (in promise) NotCapable: Requires env access to "NOT_NODE_DEBUG", run again with the --allow-env flag
|
||||
Deno.env.get("NOT_NODE_DEBUG");
|
||||
^
|
||||
at [WILDCARD]
|
||||
|
|
12
tests/testdata/test/allow_none.out
vendored
12
tests/testdata/test/allow_none.out
vendored
|
@ -10,27 +10,27 @@ ffi ... FAILED [WILDCARD]
|
|||
ERRORS
|
||||
|
||||
read => ./test/allow_none.ts:[WILDCARD]
|
||||
error: PermissionDenied: Can't escalate parent thread permissions
|
||||
error: NotCapable: Can't escalate parent thread permissions
|
||||
[WILDCARD]
|
||||
|
||||
write => ./test/allow_none.ts:[WILDCARD]
|
||||
error: PermissionDenied: Can't escalate parent thread permissions
|
||||
error: NotCapable: Can't escalate parent thread permissions
|
||||
[WILDCARD]
|
||||
|
||||
net => ./test/allow_none.ts:[WILDCARD]
|
||||
error: PermissionDenied: Can't escalate parent thread permissions
|
||||
error: NotCapable: Can't escalate parent thread permissions
|
||||
[WILDCARD]
|
||||
|
||||
env => ./test/allow_none.ts:[WILDCARD]
|
||||
error: PermissionDenied: Can't escalate parent thread permissions
|
||||
error: NotCapable: Can't escalate parent thread permissions
|
||||
[WILDCARD]
|
||||
|
||||
run => ./test/allow_none.ts:[WILDCARD]
|
||||
error: PermissionDenied: Can't escalate parent thread permissions
|
||||
error: NotCapable: Can't escalate parent thread permissions
|
||||
[WILDCARD]
|
||||
|
||||
ffi => ./test/allow_none.ts:[WILDCARD]
|
||||
error: PermissionDenied: Can't escalate parent thread permissions
|
||||
error: NotCapable: Can't escalate parent thread permissions
|
||||
[WILDCARD]
|
||||
|
||||
FAILURES
|
||||
|
|
2
tests/testdata/test/no_prompt_by_default.out
vendored
2
tests/testdata/test/no_prompt_by_default.out
vendored
|
@ -4,7 +4,7 @@ no prompt ... FAILED ([WILDCARD]s)
|
|||
ERRORS
|
||||
|
||||
no prompt => ./test/no_prompt_by_default.ts:[WILDCARD]
|
||||
error: PermissionDenied: Requires read access to "./some_file.txt", run again with the --allow-read flag
|
||||
error: NotCapable: Requires read access to "./some_file.txt", run again with the --allow-read flag
|
||||
[WILDCARD]
|
||||
|
||||
FAILURES
|
||||
|
|
|
@ -4,7 +4,7 @@ no prompt ... FAILED ([WILDCARD]s)
|
|||
ERRORS
|
||||
|
||||
no prompt => ./test/no_prompt_with_denied_perms.ts:[WILDCARD]
|
||||
error: PermissionDenied: Requires read access to "./some_file.txt", run again with the --allow-read flag
|
||||
error: NotCapable: Requires read access to "./some_file.txt", run again with the --allow-read flag
|
||||
[WILDCARD]
|
||||
|
||||
FAILURES
|
||||
|
|
|
@ -94,7 +94,7 @@ Deno.test({ permissions: { write: true } }, function chmodSyncFailure() {
|
|||
Deno.test({ permissions: { write: false } }, function chmodSyncPerm() {
|
||||
assertThrows(() => {
|
||||
Deno.chmodSync("/somefile.txt", 0o777);
|
||||
}, Deno.errors.PermissionDenied);
|
||||
}, Deno.errors.NotCapable);
|
||||
});
|
||||
|
||||
Deno.test(
|
||||
|
@ -186,5 +186,5 @@ Deno.test({ permissions: { write: true } }, async function chmodFailure() {
|
|||
Deno.test({ permissions: { write: false } }, async function chmodPerm() {
|
||||
await assertRejects(async () => {
|
||||
await Deno.chmod("/somefile.txt", 0o777);
|
||||
}, Deno.errors.PermissionDenied);
|
||||
}, Deno.errors.NotCapable);
|
||||
});
|
||||
|
|
|
@ -26,7 +26,7 @@ Deno.test(
|
|||
const filePath = "chown_test_file.txt";
|
||||
await assertRejects(async () => {
|
||||
await Deno.chown(filePath, 1000, 1000);
|
||||
}, Deno.errors.PermissionDenied);
|
||||
}, Deno.errors.NotCapable);
|
||||
},
|
||||
);
|
||||
|
||||
|
|
|
@ -382,7 +382,7 @@ Deno.test(
|
|||
await new Deno.Command(Deno.execPath(), {
|
||||
args: ["eval", "console.log('hello world')"],
|
||||
}).output();
|
||||
}, Deno.errors.PermissionDenied);
|
||||
}, Deno.errors.NotCapable);
|
||||
},
|
||||
);
|
||||
|
||||
|
@ -393,7 +393,7 @@ Deno.test(
|
|||
new Deno.Command(Deno.execPath(), {
|
||||
args: ["eval", "console.log('hello world')"],
|
||||
}).outputSync();
|
||||
}, Deno.errors.PermissionDenied);
|
||||
}, Deno.errors.NotCapable);
|
||||
},
|
||||
);
|
||||
|
||||
|
|
|
@ -84,7 +84,7 @@ Deno.test(
|
|||
function copyFileSyncPerm1() {
|
||||
assertThrows(() => {
|
||||
Deno.copyFileSync("/from.txt", "/to.txt");
|
||||
}, Deno.errors.PermissionDenied);
|
||||
}, Deno.errors.NotCapable);
|
||||
},
|
||||
);
|
||||
|
||||
|
@ -93,7 +93,7 @@ Deno.test(
|
|||
function copyFileSyncPerm2() {
|
||||
assertThrows(() => {
|
||||
Deno.copyFileSync("/from.txt", "/to.txt");
|
||||
}, Deno.errors.PermissionDenied);
|
||||
}, Deno.errors.NotCapable);
|
||||
},
|
||||
);
|
||||
|
||||
|
@ -197,7 +197,7 @@ Deno.test(
|
|||
async function copyFilePerm1() {
|
||||
await assertRejects(async () => {
|
||||
await Deno.copyFile("/from.txt", "/to.txt");
|
||||
}, Deno.errors.PermissionDenied);
|
||||
}, Deno.errors.NotCapable);
|
||||
},
|
||||
);
|
||||
|
||||
|
@ -206,7 +206,7 @@ Deno.test(
|
|||
async function copyFilePerm2() {
|
||||
await assertRejects(async () => {
|
||||
await Deno.copyFile("/from.txt", "/to.txt");
|
||||
}, Deno.errors.PermissionDenied);
|
||||
}, Deno.errors.NotCapable);
|
||||
},
|
||||
);
|
||||
|
||||
|
|
|
@ -43,7 +43,7 @@ Deno.test({ permissions: { read: false } }, function dirCwdPermError() {
|
|||
() => {
|
||||
Deno.cwd();
|
||||
},
|
||||
Deno.errors.PermissionDenied,
|
||||
Deno.errors.NotCapable,
|
||||
"Requires read access to <CWD>, run again with the --allow-read flag",
|
||||
);
|
||||
});
|
||||
|
|
|
@ -22,6 +22,7 @@ Deno.test("Errors work", () => {
|
|||
assert(new Deno.errors.Http("msg") instanceof Error);
|
||||
assert(new Deno.errors.Busy("msg") instanceof Error);
|
||||
assert(new Deno.errors.NotSupported("msg") instanceof Error);
|
||||
assert(new Deno.errors.NotCapable("msg") instanceof Error);
|
||||
});
|
||||
|
||||
Deno.test("Errors have some tamper resistance", () => {
|
||||
|
|
|
@ -124,7 +124,7 @@ Deno.test({ permissions: { net: true } }, async function fetchJsonSuccess() {
|
|||
Deno.test({ permissions: { net: false } }, async function fetchPerm() {
|
||||
await assertRejects(async () => {
|
||||
await fetch("http://localhost:4545/assets/fixture.json");
|
||||
}, Deno.errors.PermissionDenied);
|
||||
}, Deno.errors.NotCapable);
|
||||
});
|
||||
|
||||
Deno.test({ permissions: { net: true } }, async function fetchUrl() {
|
||||
|
@ -1637,7 +1637,7 @@ Deno.test(
|
|||
Deno.test({ permissions: { read: false } }, async function fetchFilePerm() {
|
||||
await assertRejects(async () => {
|
||||
await fetch(import.meta.resolve("../testdata/subdir/json_1.json"));
|
||||
}, Deno.errors.PermissionDenied);
|
||||
}, Deno.errors.NotCapable);
|
||||
});
|
||||
|
||||
Deno.test(
|
||||
|
@ -1645,7 +1645,7 @@ Deno.test(
|
|||
async function fetchFilePermDoesNotExist() {
|
||||
await assertRejects(async () => {
|
||||
await fetch(import.meta.resolve("./bad.json"));
|
||||
}, Deno.errors.PermissionDenied);
|
||||
}, Deno.errors.NotCapable);
|
||||
},
|
||||
);
|
||||
|
||||
|
|
|
@ -24,10 +24,10 @@ Deno.test({ permissions: { ffi: true } }, function dlopenInvalidArguments() {
|
|||
}, TypeError);
|
||||
});
|
||||
|
||||
Deno.test({ permissions: { ffi: false } }, function ffiPermissionDenied() {
|
||||
Deno.test({ permissions: { ffi: false } }, function ffiNotCapable() {
|
||||
assertThrows(() => {
|
||||
Deno.dlopen("/usr/lib/libc.so.6", {});
|
||||
}, Deno.errors.PermissionDenied);
|
||||
}, Deno.errors.NotCapable);
|
||||
const fnptr = new Deno.UnsafeFnPointer(
|
||||
// @ts-expect-error: Not NonNullable but null check is after permissions check.
|
||||
null,
|
||||
|
@ -38,44 +38,44 @@ Deno.test({ permissions: { ffi: false } }, function ffiPermissionDenied() {
|
|||
);
|
||||
assertThrows(() => {
|
||||
fnptr.call(123, null);
|
||||
}, Deno.errors.PermissionDenied);
|
||||
}, Deno.errors.NotCapable);
|
||||
assertThrows(() => {
|
||||
Deno.UnsafePointer.of(new Uint8Array(0));
|
||||
}, Deno.errors.PermissionDenied);
|
||||
}, Deno.errors.NotCapable);
|
||||
const ptrView = new Deno.UnsafePointerView(
|
||||
// @ts-expect-error: Not NonNullable but null check is after permissions check.
|
||||
null,
|
||||
);
|
||||
assertThrows(() => {
|
||||
ptrView.copyInto(new Uint8Array(0));
|
||||
}, Deno.errors.PermissionDenied);
|
||||
}, Deno.errors.NotCapable);
|
||||
assertThrows(() => {
|
||||
ptrView.getCString();
|
||||
}, Deno.errors.PermissionDenied);
|
||||
}, Deno.errors.NotCapable);
|
||||
assertThrows(() => {
|
||||
ptrView.getUint8();
|
||||
}, Deno.errors.PermissionDenied);
|
||||
}, Deno.errors.NotCapable);
|
||||
assertThrows(() => {
|
||||
ptrView.getInt8();
|
||||
}, Deno.errors.PermissionDenied);
|
||||
}, Deno.errors.NotCapable);
|
||||
assertThrows(() => {
|
||||
ptrView.getUint16();
|
||||
}, Deno.errors.PermissionDenied);
|
||||
}, Deno.errors.NotCapable);
|
||||
assertThrows(() => {
|
||||
ptrView.getInt16();
|
||||
}, Deno.errors.PermissionDenied);
|
||||
}, Deno.errors.NotCapable);
|
||||
assertThrows(() => {
|
||||
ptrView.getUint32();
|
||||
}, Deno.errors.PermissionDenied);
|
||||
}, Deno.errors.NotCapable);
|
||||
assertThrows(() => {
|
||||
ptrView.getInt32();
|
||||
}, Deno.errors.PermissionDenied);
|
||||
}, Deno.errors.NotCapable);
|
||||
assertThrows(() => {
|
||||
ptrView.getFloat32();
|
||||
}, Deno.errors.PermissionDenied);
|
||||
}, Deno.errors.NotCapable);
|
||||
assertThrows(() => {
|
||||
ptrView.getFloat64();
|
||||
}, Deno.errors.PermissionDenied);
|
||||
}, Deno.errors.NotCapable);
|
||||
});
|
||||
|
||||
Deno.test({ permissions: { ffi: true } }, function pointerOf() {
|
||||
|
|
|
@ -127,7 +127,7 @@ Deno.test(
|
|||
for (const options of openOptions) {
|
||||
await assertRejects(async () => {
|
||||
await Deno.open(filename, options);
|
||||
}, Deno.errors.PermissionDenied);
|
||||
}, Deno.errors.NotCapable);
|
||||
}
|
||||
},
|
||||
);
|
||||
|
@ -170,7 +170,7 @@ Deno.test(async function openOptions() {
|
|||
Deno.test({ permissions: { read: false } }, async function readPermFailure() {
|
||||
await assertRejects(async () => {
|
||||
await Deno.open("package.json", { read: true });
|
||||
}, Deno.errors.PermissionDenied);
|
||||
}, Deno.errors.NotCapable);
|
||||
});
|
||||
|
||||
Deno.test(
|
||||
|
@ -229,7 +229,7 @@ Deno.test(
|
|||
const filename = "tests/hello.txt";
|
||||
await assertRejects(async () => {
|
||||
await Deno.open(filename, { read: true });
|
||||
}, Deno.errors.PermissionDenied);
|
||||
}, Deno.errors.NotCapable);
|
||||
},
|
||||
);
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@ import { assert, assertEquals, assertThrows, delay } from "./test_util.ts";
|
|||
Deno.test({ permissions: { read: false } }, function watchFsPermissions() {
|
||||
assertThrows(() => {
|
||||
Deno.watchFs(".");
|
||||
}, Deno.errors.PermissionDenied);
|
||||
}, Deno.errors.NotCapable);
|
||||
});
|
||||
|
||||
Deno.test({ permissions: { read: true } }, function watchFsInvalidPath() {
|
||||
|
|
|
@ -87,7 +87,7 @@ Deno.test(
|
|||
function linkSyncReadPerm() {
|
||||
assertThrows(() => {
|
||||
Deno.linkSync("oldbaddir", "newbaddir");
|
||||
}, Deno.errors.PermissionDenied);
|
||||
}, Deno.errors.NotCapable);
|
||||
},
|
||||
);
|
||||
|
||||
|
@ -96,7 +96,7 @@ Deno.test(
|
|||
function linkSyncWritePerm() {
|
||||
assertThrows(() => {
|
||||
Deno.linkSync("oldbaddir", "newbaddir");
|
||||
}, Deno.errors.PermissionDenied);
|
||||
}, Deno.errors.NotCapable);
|
||||
},
|
||||
);
|
||||
|
||||
|
@ -181,7 +181,7 @@ Deno.test(
|
|||
async function linkReadPerm() {
|
||||
await assertRejects(async () => {
|
||||
await Deno.link("oldbaddir", "newbaddir");
|
||||
}, Deno.errors.PermissionDenied);
|
||||
}, Deno.errors.NotCapable);
|
||||
},
|
||||
);
|
||||
|
||||
|
@ -190,6 +190,6 @@ Deno.test(
|
|||
async function linkWritePerm() {
|
||||
await assertRejects(async () => {
|
||||
await Deno.link("oldbaddir", "newbaddir");
|
||||
}, Deno.errors.PermissionDenied);
|
||||
}, Deno.errors.NotCapable);
|
||||
},
|
||||
);
|
||||
|
|
|
@ -42,7 +42,7 @@ Deno.test({ permissions: { write: false } }, function makeTempDirSyncPerm() {
|
|||
// makeTempDirSync should require write permissions (for now).
|
||||
assertThrows(() => {
|
||||
Deno.makeTempDirSync({ dir: "/baddir" });
|
||||
}, Deno.errors.PermissionDenied);
|
||||
}, Deno.errors.NotCapable);
|
||||
});
|
||||
|
||||
Deno.test(
|
||||
|
@ -117,7 +117,7 @@ Deno.test({ permissions: { write: false } }, function makeTempFileSyncPerm() {
|
|||
// makeTempFileSync should require write permissions (for now).
|
||||
assertThrows(() => {
|
||||
Deno.makeTempFileSync({ dir: "/baddir" });
|
||||
}, Deno.errors.PermissionDenied);
|
||||
}, Deno.errors.NotCapable);
|
||||
});
|
||||
|
||||
Deno.test(
|
||||
|
|
|
@ -36,7 +36,7 @@ Deno.test(
|
|||
Deno.test({ permissions: { write: false } }, function mkdirSyncPerm() {
|
||||
assertThrows(() => {
|
||||
Deno.mkdirSync("/baddir");
|
||||
}, Deno.errors.PermissionDenied);
|
||||
}, Deno.errors.NotCapable);
|
||||
});
|
||||
|
||||
Deno.test(
|
||||
|
|
|
@ -100,7 +100,7 @@ Deno.test(
|
|||
assert(socket.addr.transport === "unix");
|
||||
assertEquals(socket.addr.path, filePath);
|
||||
socket.close();
|
||||
}, Deno.errors.PermissionDenied);
|
||||
}, Deno.errors.NotCapable);
|
||||
},
|
||||
);
|
||||
|
||||
|
@ -119,7 +119,7 @@ Deno.test(
|
|||
assert(socket.addr.transport === "unixpacket");
|
||||
assertEquals(socket.addr.path, filePath);
|
||||
socket.close();
|
||||
}, Deno.errors.PermissionDenied);
|
||||
}, Deno.errors.NotCapable);
|
||||
},
|
||||
);
|
||||
|
||||
|
|
|
@ -48,16 +48,16 @@ Deno.test({ permissions: { env: true } }, function avoidEmptyNamedEnv() {
|
|||
assertThrows(() => Deno.env.delete("a\0a"), TypeError);
|
||||
});
|
||||
|
||||
Deno.test({ permissions: { env: false } }, function envPermissionDenied1() {
|
||||
Deno.test({ permissions: { env: false } }, function envPerm1() {
|
||||
assertThrows(() => {
|
||||
Deno.env.toObject();
|
||||
}, Deno.errors.PermissionDenied);
|
||||
}, Deno.errors.NotCapable);
|
||||
});
|
||||
|
||||
Deno.test({ permissions: { env: false } }, function envPermissionDenied2() {
|
||||
Deno.test({ permissions: { env: false } }, function envPerm2() {
|
||||
assertThrows(() => {
|
||||
Deno.env.get("PATH");
|
||||
}, Deno.errors.PermissionDenied);
|
||||
}, Deno.errors.NotCapable);
|
||||
});
|
||||
|
||||
// This test verifies that on Windows, environment variables are
|
||||
|
@ -191,7 +191,7 @@ Deno.test({ permissions: { read: false } }, function execPathPerm() {
|
|||
() => {
|
||||
Deno.execPath();
|
||||
},
|
||||
Deno.errors.PermissionDenied,
|
||||
Deno.errors.NotCapable,
|
||||
"Requires read access to <exec_path>, run again with the --allow-read flag",
|
||||
);
|
||||
});
|
||||
|
@ -206,7 +206,7 @@ Deno.test(
|
|||
() => {
|
||||
Deno.readTextFileSync("/proc/net/dev");
|
||||
},
|
||||
Deno.errors.PermissionDenied,
|
||||
Deno.errors.NotCapable,
|
||||
`Requires all access to "/proc/net/dev", run again with the --allow-all flag`,
|
||||
);
|
||||
},
|
||||
|
@ -223,7 +223,7 @@ Deno.test(
|
|||
Deno.test({ permissions: { sys: false } }, function loadavgPerm() {
|
||||
assertThrows(() => {
|
||||
Deno.loadavg();
|
||||
}, Deno.errors.PermissionDenied);
|
||||
}, Deno.errors.NotCapable);
|
||||
});
|
||||
|
||||
Deno.test(
|
||||
|
@ -253,7 +253,7 @@ Deno.test(
|
|||
Deno.test({ permissions: { sys: false } }, function hostnamePerm() {
|
||||
assertThrows(() => {
|
||||
Deno.hostname();
|
||||
}, Deno.errors.PermissionDenied);
|
||||
}, Deno.errors.NotCapable);
|
||||
});
|
||||
|
||||
Deno.test(
|
||||
|
@ -266,7 +266,7 @@ Deno.test(
|
|||
Deno.test({ permissions: { sys: false } }, function releasePerm() {
|
||||
assertThrows(() => {
|
||||
Deno.osRelease();
|
||||
}, Deno.errors.PermissionDenied);
|
||||
}, Deno.errors.NotCapable);
|
||||
});
|
||||
|
||||
Deno.test({ permissions: { sys: ["osUptime"] } }, function osUptime() {
|
||||
|
@ -278,7 +278,7 @@ Deno.test({ permissions: { sys: ["osUptime"] } }, function osUptime() {
|
|||
Deno.test({ permissions: { sys: false } }, function osUptimePerm() {
|
||||
assertThrows(() => {
|
||||
Deno.osUptime();
|
||||
}, Deno.errors.PermissionDenied);
|
||||
}, Deno.errors.NotCapable);
|
||||
});
|
||||
|
||||
Deno.test(
|
||||
|
|
|
@ -17,7 +17,7 @@ Deno.test(
|
|||
Deno.run({
|
||||
cmd: [Deno.execPath(), "eval", "console.log('hello world')"],
|
||||
});
|
||||
}, Deno.errors.PermissionDenied);
|
||||
}, Deno.errors.NotCapable);
|
||||
},
|
||||
);
|
||||
|
||||
|
@ -517,7 +517,7 @@ Deno.test({ permissions: { run: false } }, function killPermissions() {
|
|||
// process - assuming that Deno does not have a special handler set for it
|
||||
// and will just continue even if a signal is erroneously sent.
|
||||
Deno.kill(Deno.pid, "SIGCONT");
|
||||
}, Deno.errors.PermissionDenied);
|
||||
}, Deno.errors.NotCapable);
|
||||
});
|
||||
|
||||
Deno.test(
|
||||
|
|
|
@ -35,7 +35,7 @@ Deno.test({ permissions: { read: true } }, function readDirSyncWithUrl() {
|
|||
Deno.test({ permissions: { read: false } }, function readDirSyncPerm() {
|
||||
assertThrows(() => {
|
||||
Deno.readDirSync("tests/");
|
||||
}, Deno.errors.PermissionDenied);
|
||||
}, Deno.errors.NotCapable);
|
||||
});
|
||||
|
||||
Deno.test({ permissions: { read: true } }, function readDirSyncNotDir() {
|
||||
|
@ -79,7 +79,7 @@ Deno.test({ permissions: { read: true } }, async function readDirWithUrl() {
|
|||
Deno.test({ permissions: { read: false } }, async function readDirPerm() {
|
||||
await assertRejects(async () => {
|
||||
await Deno.readDir("tests/")[Symbol.asyncIterator]().next();
|
||||
}, Deno.errors.PermissionDenied);
|
||||
}, Deno.errors.NotCapable);
|
||||
});
|
||||
|
||||
Deno.test(
|
||||
|
|
|
@ -31,7 +31,7 @@ Deno.test({ permissions: { read: true } }, function readFileSyncUrl() {
|
|||
Deno.test({ permissions: { read: false } }, function readFileSyncPerm() {
|
||||
assertThrows(() => {
|
||||
Deno.readFileSync("tests/testdata/assets/fixture.json");
|
||||
}, Deno.errors.PermissionDenied);
|
||||
}, Deno.errors.NotCapable);
|
||||
});
|
||||
|
||||
Deno.test({ permissions: { read: true } }, function readFileSyncNotFound() {
|
||||
|
@ -63,7 +63,7 @@ Deno.test({ permissions: { read: true } }, async function readFileSuccess() {
|
|||
Deno.test({ permissions: { read: false } }, async function readFilePerm() {
|
||||
await assertRejects(async () => {
|
||||
await Deno.readFile("tests/testdata/assets/fixture.json");
|
||||
}, Deno.errors.PermissionDenied);
|
||||
}, Deno.errors.NotCapable);
|
||||
});
|
||||
|
||||
Deno.test({ permissions: { read: true } }, function readFileSyncLoop() {
|
||||
|
|
|
@ -39,7 +39,7 @@ Deno.test(
|
|||
Deno.test({ permissions: { read: false } }, function readLinkSyncPerm() {
|
||||
assertThrows(() => {
|
||||
Deno.readLinkSync("/symlink");
|
||||
}, Deno.errors.PermissionDenied);
|
||||
}, Deno.errors.NotCapable);
|
||||
});
|
||||
|
||||
Deno.test({ permissions: { read: true } }, function readLinkSyncNotFound() {
|
||||
|
@ -85,7 +85,7 @@ Deno.test(
|
|||
Deno.test({ permissions: { read: false } }, async function readLinkPerm() {
|
||||
await assertRejects(async () => {
|
||||
await Deno.readLink("/symlink");
|
||||
}, Deno.errors.PermissionDenied);
|
||||
}, Deno.errors.NotCapable);
|
||||
});
|
||||
|
||||
Deno.test({ permissions: { read: true } }, async function readLinkNotFound() {
|
||||
|
|
|
@ -28,7 +28,7 @@ Deno.test({ permissions: { read: true } }, function readTextFileSyncByUrl() {
|
|||
Deno.test({ permissions: { read: false } }, function readTextFileSyncPerm() {
|
||||
assertThrows(() => {
|
||||
Deno.readTextFileSync("tests/testdata/assets/fixture.json");
|
||||
}, Deno.errors.PermissionDenied);
|
||||
}, Deno.errors.NotCapable);
|
||||
});
|
||||
|
||||
Deno.test({ permissions: { read: true } }, function readTextFileSyncNotFound() {
|
||||
|
@ -61,7 +61,7 @@ Deno.test({ permissions: { read: true } }, async function readTextFileByUrl() {
|
|||
Deno.test({ permissions: { read: false } }, async function readTextFilePerm() {
|
||||
await assertRejects(async () => {
|
||||
await Deno.readTextFile("tests/testdata/assets/fixture.json");
|
||||
}, Deno.errors.PermissionDenied);
|
||||
}, Deno.errors.NotCapable);
|
||||
});
|
||||
|
||||
Deno.test({ permissions: { read: true } }, function readTextFileSyncLoop() {
|
||||
|
|
|
@ -50,7 +50,7 @@ Deno.test(
|
|||
Deno.test({ permissions: { read: false } }, function realPathSyncPerm() {
|
||||
assertThrows(() => {
|
||||
Deno.realPathSync("some_file");
|
||||
}, Deno.errors.PermissionDenied);
|
||||
}, Deno.errors.NotCapable);
|
||||
});
|
||||
|
||||
Deno.test({ permissions: { read: true } }, function realPathSyncNotFound() {
|
||||
|
@ -104,7 +104,7 @@ Deno.test(
|
|||
Deno.test({ permissions: { read: false } }, async function realPathPerm() {
|
||||
await assertRejects(async () => {
|
||||
await Deno.realPath("some_file");
|
||||
}, Deno.errors.PermissionDenied);
|
||||
}, Deno.errors.NotCapable);
|
||||
});
|
||||
|
||||
Deno.test({ permissions: { read: true } }, async function realPathNotFound() {
|
||||
|
|
|
@ -153,7 +153,7 @@ Deno.test({ permissions: { write: false } }, async function removePerm() {
|
|||
for (const method of REMOVE_METHODS) {
|
||||
await assertRejects(async () => {
|
||||
await Deno[method]("/baddir");
|
||||
}, Deno.errors.PermissionDenied);
|
||||
}, Deno.errors.NotCapable);
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -233,7 +233,7 @@ Deno.test({ permissions: { write: false } }, async function removeAllPerm() {
|
|||
for (const method of REMOVE_METHODS) {
|
||||
await assertRejects(async () => {
|
||||
await Deno[method]("/baddir", { recursive: true });
|
||||
}, Deno.errors.PermissionDenied);
|
||||
}, Deno.errors.NotCapable);
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
@ -70,7 +70,7 @@ Deno.test(
|
|||
const oldpath = "/oldbaddir";
|
||||
const newpath = "/newbaddir";
|
||||
Deno.renameSync(oldpath, newpath);
|
||||
}, Deno.errors.PermissionDenied);
|
||||
}, Deno.errors.NotCapable);
|
||||
},
|
||||
);
|
||||
|
||||
|
@ -81,7 +81,7 @@ Deno.test(
|
|||
const oldpath = "/oldbaddir";
|
||||
const newpath = "/newbaddir";
|
||||
Deno.renameSync(oldpath, newpath);
|
||||
}, Deno.errors.PermissionDenied);
|
||||
}, Deno.errors.NotCapable);
|
||||
},
|
||||
);
|
||||
|
||||
|
|
|
@ -74,7 +74,7 @@ Deno.test(
|
|||
Deno.test({ permissions: { read: false } }, function statSyncPerm() {
|
||||
assertThrows(() => {
|
||||
Deno.statSync("README.md");
|
||||
}, Deno.errors.PermissionDenied);
|
||||
}, Deno.errors.NotCapable);
|
||||
});
|
||||
|
||||
Deno.test({ permissions: { read: true } }, function statSyncNotFound() {
|
||||
|
@ -118,7 +118,7 @@ Deno.test({ permissions: { read: true } }, function lstatSyncSuccess() {
|
|||
Deno.test({ permissions: { read: false } }, function lstatSyncPerm() {
|
||||
assertThrows(() => {
|
||||
Deno.lstatSync("assets/hello.txt");
|
||||
}, Deno.errors.PermissionDenied);
|
||||
}, Deno.errors.NotCapable);
|
||||
});
|
||||
|
||||
Deno.test({ permissions: { read: true } }, function lstatSyncNotFound() {
|
||||
|
@ -200,7 +200,7 @@ Deno.test(
|
|||
Deno.test({ permissions: { read: false } }, async function statPerm() {
|
||||
await assertRejects(async () => {
|
||||
await Deno.stat("README.md");
|
||||
}, Deno.errors.PermissionDenied);
|
||||
}, Deno.errors.NotCapable);
|
||||
});
|
||||
|
||||
Deno.test({ permissions: { read: true } }, async function statNotFound() {
|
||||
|
@ -244,7 +244,7 @@ Deno.test({ permissions: { read: true } }, async function lstatSuccess() {
|
|||
Deno.test({ permissions: { read: false } }, async function lstatPerm() {
|
||||
await assertRejects(async () => {
|
||||
await Deno.lstat("README.md");
|
||||
}, Deno.errors.PermissionDenied);
|
||||
}, Deno.errors.NotCapable);
|
||||
});
|
||||
|
||||
Deno.test({ permissions: { read: true } }, async function lstatNotFound() {
|
||||
|
|
|
@ -62,7 +62,7 @@ Deno.test(
|
|||
function symlinkSyncPerm() {
|
||||
assertThrows(() => {
|
||||
Deno.symlinkSync("oldbaddir", "newbaddir");
|
||||
}, Deno.errors.PermissionDenied);
|
||||
}, Deno.errors.NotCapable);
|
||||
},
|
||||
);
|
||||
|
||||
|
@ -152,11 +152,11 @@ Deno.test(
|
|||
async function symlinkNoFullWritePermissions() {
|
||||
await assertRejects(
|
||||
() => Deno.symlink("old", "new"),
|
||||
Deno.errors.PermissionDenied,
|
||||
Deno.errors.NotCapable,
|
||||
);
|
||||
assertThrows(
|
||||
() => Deno.symlinkSync("old", "new"),
|
||||
Deno.errors.PermissionDenied,
|
||||
Deno.errors.NotCapable,
|
||||
);
|
||||
},
|
||||
);
|
||||
|
@ -166,11 +166,11 @@ Deno.test(
|
|||
async function symlinkNoFullReadPermissions() {
|
||||
await assertRejects(
|
||||
() => Deno.symlink("old", "new"),
|
||||
Deno.errors.PermissionDenied,
|
||||
Deno.errors.NotCapable,
|
||||
);
|
||||
assertThrows(
|
||||
() => Deno.symlinkSync("old", "new"),
|
||||
Deno.errors.PermissionDenied,
|
||||
Deno.errors.NotCapable,
|
||||
);
|
||||
},
|
||||
);
|
||||
|
|
|
@ -55,7 +55,7 @@ function unreachable(): never {
|
|||
Deno.test({ permissions: { net: false } }, async function connectTLSNoPerm() {
|
||||
await assertRejects(async () => {
|
||||
await Deno.connectTls({ hostname: "deno.land", port: 443 });
|
||||
}, Deno.errors.PermissionDenied);
|
||||
}, Deno.errors.NotCapable);
|
||||
});
|
||||
|
||||
Deno.test(
|
||||
|
@ -76,7 +76,7 @@ Deno.test(
|
|||
port: 443,
|
||||
certFile: "tests/testdata/tls/RootCA.crt",
|
||||
});
|
||||
}, Deno.errors.PermissionDenied);
|
||||
}, Deno.errors.NotCapable);
|
||||
},
|
||||
);
|
||||
|
||||
|
@ -116,7 +116,7 @@ Deno.test(
|
|||
certFile: "tests/testdata/tls/localhost.crt",
|
||||
keyFile: "tests/testdata/tls/localhost.key",
|
||||
});
|
||||
}, Deno.errors.PermissionDenied);
|
||||
}, Deno.errors.NotCapable);
|
||||
},
|
||||
);
|
||||
|
||||
|
|
|
@ -76,13 +76,13 @@ Deno.test(
|
|||
Deno.test({ permissions: { write: false } }, function truncateSyncPerm() {
|
||||
assertThrows(() => {
|
||||
Deno.truncateSync("/test_truncateSyncPermission.txt");
|
||||
}, Deno.errors.PermissionDenied);
|
||||
}, Deno.errors.NotCapable);
|
||||
});
|
||||
|
||||
Deno.test({ permissions: { write: false } }, async function truncatePerm() {
|
||||
await assertRejects(async () => {
|
||||
await Deno.truncate("/test_truncatePermission.txt");
|
||||
}, Deno.errors.PermissionDenied);
|
||||
}, Deno.errors.NotCapable);
|
||||
});
|
||||
|
||||
Deno.test(
|
||||
|
|
|
@ -176,7 +176,7 @@ Deno.test(
|
|||
|
||||
assertThrows(() => {
|
||||
Deno.utimeSync("/some_dir", atime, mtime);
|
||||
}, Deno.errors.PermissionDenied);
|
||||
}, Deno.errors.NotCapable);
|
||||
},
|
||||
);
|
||||
|
||||
|
@ -291,6 +291,6 @@ Deno.test(
|
|||
|
||||
await assertRejects(async () => {
|
||||
await Deno.utime("/some_dir", atime, mtime);
|
||||
}, Deno.errors.PermissionDenied);
|
||||
}, Deno.errors.NotCapable);
|
||||
},
|
||||
);
|
||||
|
|
|
@ -7,7 +7,7 @@ const serveUrl = `ws://localhost:${servePort}/`;
|
|||
Deno.test({ permissions: "none" }, function websocketPermissionless() {
|
||||
assertThrows(
|
||||
() => new WebSocket("ws://localhost"),
|
||||
Deno.errors.PermissionDenied,
|
||||
Deno.errors.NotCapable,
|
||||
);
|
||||
});
|
||||
|
||||
|
|
|
@ -546,7 +546,7 @@ Deno.test({
|
|||
);
|
||||
worker.terminate();
|
||||
},
|
||||
Deno.errors.PermissionDenied,
|
||||
Deno.errors.NotCapable,
|
||||
"Can't escalate parent thread permissions",
|
||||
);
|
||||
},
|
||||
|
|
|
@ -57,7 +57,7 @@ Deno.test({ permissions: { write: false } }, function writeFileSyncPerm() {
|
|||
// The following should fail due to no write permission
|
||||
assertThrows(() => {
|
||||
Deno.writeFileSync(filename, data);
|
||||
}, Deno.errors.PermissionDenied);
|
||||
}, Deno.errors.NotCapable);
|
||||
});
|
||||
|
||||
Deno.test(
|
||||
|
@ -190,7 +190,7 @@ Deno.test(
|
|||
// The following should fail due to no write permission
|
||||
await assertRejects(async () => {
|
||||
await Deno.writeFile(filename, data);
|
||||
}, Deno.errors.PermissionDenied);
|
||||
}, Deno.errors.NotCapable);
|
||||
},
|
||||
);
|
||||
|
||||
|
|
|
@ -45,7 +45,7 @@ Deno.test({ permissions: { write: false } }, function writeTextFileSyncPerm() {
|
|||
// The following should fail due to no write permission
|
||||
assertThrows(() => {
|
||||
Deno.writeTextFileSync(filename, "Hello");
|
||||
}, Deno.errors.PermissionDenied);
|
||||
}, Deno.errors.NotCapable);
|
||||
});
|
||||
|
||||
Deno.test(
|
||||
|
@ -144,7 +144,7 @@ Deno.test(
|
|||
// The following should fail due to no write permission
|
||||
await assertRejects(async () => {
|
||||
await Deno.writeTextFile(filename, "Hello");
|
||||
}, Deno.errors.PermissionDenied);
|
||||
}, Deno.errors.NotCapable);
|
||||
},
|
||||
);
|
||||
|
||||
|
|
|
@ -88,7 +88,7 @@ Deno.test(
|
|||
() => {
|
||||
assertThrows(() => {
|
||||
existsSync("tests/testdata/assets/fixture.json");
|
||||
}, Deno.errors.PermissionDenied);
|
||||
}, Deno.errors.NotCapable);
|
||||
},
|
||||
);
|
||||
|
||||
|
|
|
@ -113,7 +113,7 @@ Deno.test({
|
|||
const s = new net.Server();
|
||||
s.listen(3000);
|
||||
} catch (e) {
|
||||
assert(e instanceof Deno.errors.PermissionDenied);
|
||||
assert(e instanceof Deno.errors.NotCapable);
|
||||
}
|
||||
},
|
||||
});
|
||||
|
|
|
@ -8,6 +8,7 @@ import {
|
|||
assertNotEquals,
|
||||
assertThrows,
|
||||
} from "@std/assert";
|
||||
import console from "node:console";
|
||||
|
||||
Deno.test({
|
||||
name: "build architecture is a string",
|
||||
|
@ -298,7 +299,14 @@ Deno.test({
|
|||
args: ["eval", "while (true) { console.log('foo') }"],
|
||||
}).spawn();
|
||||
assertThrows(
|
||||
() => os.setPriority(child.pid, os.constants.priority.PRIORITY_HIGH),
|
||||
() => {
|
||||
try {
|
||||
os.setPriority(child.pid, os.constants.priority.PRIORITY_HIGH);
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
throw err;
|
||||
}
|
||||
},
|
||||
Deno.errors.PermissionDenied,
|
||||
);
|
||||
os.getPriority(child.pid);
|
||||
|
|
|
@ -48,7 +48,7 @@ pub use fs::TempDir;
|
|||
|
||||
pub const PERMISSION_VARIANTS: [&str; 5] =
|
||||
["read", "write", "env", "net", "run"];
|
||||
pub const PERMISSION_DENIED_PATTERN: &str = "PermissionDenied";
|
||||
pub const PERMISSION_DENIED_PATTERN: &str = "NotCapable";
|
||||
|
||||
static GUARD: Lazy<Mutex<HttpServerCount>> = Lazy::new(Default::default);
|
||||
|
||||
|
|
Loading…
Reference in a new issue