mirror of
https://github.com/denoland/deno.git
synced 2024-12-21 23:04:45 -05:00
feat(permissions): link to docs in permission prompt (#24948)
This commit updates permission prompt to add a link to the documentation for particular flag. Additionally the box drawings around the prompt have been slightly altered for better visibility. <img width="737" alt="Screenshot 2024-08-08 at 12 42 32" src="https://github.com/user-attachments/assets/6ae748cd-4f29-439d-b0ee-f28f565f211a">
This commit is contained in:
parent
e9e3ab4628
commit
ab8802f49b
2 changed files with 143 additions and 106 deletions
|
@ -319,16 +319,29 @@ impl PermissionPrompter for TtyPrompter {
|
|||
// output everything in one shot to make the tests more reliable
|
||||
{
|
||||
let mut output = String::new();
|
||||
write!(&mut output, "┌ {PERMISSION_EMOJI} ").unwrap();
|
||||
write!(&mut output, "┏ {PERMISSION_EMOJI} ").unwrap();
|
||||
write!(&mut output, "{}", colors::bold("Deno requests ")).unwrap();
|
||||
write!(&mut output, "{}", colors::bold(message.clone())).unwrap();
|
||||
writeln!(&mut output, "{}", colors::bold(".")).unwrap();
|
||||
if let Some(api_name) = api_name.clone() {
|
||||
writeln!(&mut output, "├ Requested by `{api_name}` API.").unwrap();
|
||||
writeln!(
|
||||
&mut output,
|
||||
"┠─ Requested by `{}` API.",
|
||||
colors::bold(api_name)
|
||||
)
|
||||
.unwrap();
|
||||
}
|
||||
let msg = format!(
|
||||
"Learn more at: {}",
|
||||
colors::cyan_with_underline(&format!(
|
||||
"https://docs.deno.com/go/--allow-{}",
|
||||
name
|
||||
))
|
||||
);
|
||||
writeln!(&mut output, "┠─ {}", colors::italic(&msg)).unwrap();
|
||||
let msg = format!("Run again with --allow-{name} to bypass this prompt.");
|
||||
writeln!(&mut output, "├ {}", colors::italic(&msg)).unwrap();
|
||||
write!(&mut output, "└ {}", colors::bold("Allow?")).unwrap();
|
||||
writeln!(&mut output, "┠─ {}", colors::italic(&msg)).unwrap();
|
||||
write!(&mut output, "┗ {}", colors::bold("Allow?")).unwrap();
|
||||
write!(&mut output, " {opts} > ").unwrap();
|
||||
|
||||
stderr_lock.write_all(output.as_bytes()).unwrap();
|
||||
|
@ -355,7 +368,7 @@ impl PermissionPrompter for TtyPrompter {
|
|||
'y' | 'Y' => {
|
||||
clear_n_lines(
|
||||
&mut stderr_lock,
|
||||
if api_name.is_some() { 4 } else { 3 },
|
||||
if api_name.is_some() { 5 } else { 4 },
|
||||
);
|
||||
let msg = format!("Granted {message}.");
|
||||
writeln!(stderr_lock, "✅ {}", colors::bold(&msg)).unwrap();
|
||||
|
@ -364,7 +377,7 @@ impl PermissionPrompter for TtyPrompter {
|
|||
'n' | 'N' | '\x1b' => {
|
||||
clear_n_lines(
|
||||
&mut stderr_lock,
|
||||
if api_name.is_some() { 4 } else { 3 },
|
||||
if api_name.is_some() { 5 } else { 4 },
|
||||
);
|
||||
let msg = format!("Denied {message}.");
|
||||
writeln!(stderr_lock, "❌ {}", colors::bold(&msg)).unwrap();
|
||||
|
@ -373,7 +386,7 @@ impl PermissionPrompter for TtyPrompter {
|
|||
'A' if is_unary => {
|
||||
clear_n_lines(
|
||||
&mut stderr_lock,
|
||||
if api_name.is_some() { 4 } else { 3 },
|
||||
if api_name.is_some() { 5 } else { 4 },
|
||||
);
|
||||
let msg = format!("Granted all {name} access.");
|
||||
writeln!(stderr_lock, "✅ {}", colors::bold(&msg)).unwrap();
|
||||
|
@ -384,7 +397,7 @@ impl PermissionPrompter for TtyPrompter {
|
|||
clear_n_lines(&mut stderr_lock, 1);
|
||||
write!(
|
||||
stderr_lock,
|
||||
"└ {} {opts} > ",
|
||||
"┗ {} {opts} > ",
|
||||
colors::bold("Unrecognized option. Allow?")
|
||||
)
|
||||
.unwrap();
|
||||
|
|
|
@ -511,19 +511,21 @@ fn _090_run_permissions_request() {
|
|||
.args_vec(["run", "--quiet", "run/090_run_permissions_request.ts"])
|
||||
.with_pty(|mut console| {
|
||||
console.expect(concat!(
|
||||
"┌ ⚠️ Deno requests run access to \"ls\".\r\n",
|
||||
"├ Requested by `Deno.permissions.request()` API.\r\n",
|
||||
"├ Run again with --allow-run to bypass this prompt.\r\n",
|
||||
"└ Allow? [y/n/A] (y = yes, allow; n = no, deny; A = allow all run permissions)",
|
||||
"┏ ⚠️ Deno requests run access to \"ls\".\r\n",
|
||||
"┠─ Requested by `Deno.permissions.request()` API.\r\n",
|
||||
"┠─ Learn more at: https://docs.deno.com/go/--allow-run\r\n",
|
||||
"┠─ Run again with --allow-run to bypass this prompt.\r\n",
|
||||
"┗ Allow? [y/n/A] (y = yes, allow; n = no, deny; A = allow all run permissions)",
|
||||
));
|
||||
console.human_delay();
|
||||
console.write_line_raw("y");
|
||||
console.expect("Granted run access to \"ls\".");
|
||||
console.expect(concat!(
|
||||
"┌ ⚠️ Deno requests run access to \"cat\".\r\n",
|
||||
"├ Requested by `Deno.permissions.request()` API.\r\n",
|
||||
"├ Run again with --allow-run to bypass this prompt.\r\n",
|
||||
"└ Allow? [y/n/A] (y = yes, allow; n = no, deny; A = allow all run permissions)",
|
||||
"┏ ⚠️ Deno requests run access to \"cat\".\r\n",
|
||||
"┠─ Requested by `Deno.permissions.request()` API.\r\n",
|
||||
"┠─ Learn more at: https://docs.deno.com/go/--allow-run\r\n",
|
||||
"┠─ Run again with --allow-run to bypass this prompt.\r\n",
|
||||
"┗ Allow? [y/n/A] (y = yes, allow; n = no, deny; A = allow all run permissions)",
|
||||
));
|
||||
console.human_delay();
|
||||
console.write_line_raw("n");
|
||||
|
@ -540,19 +542,21 @@ fn _090_run_permissions_request_sync() {
|
|||
.args_vec(["run", "--quiet", "run/090_run_permissions_request_sync.ts"])
|
||||
.with_pty(|mut console| {
|
||||
console.expect(concat!(
|
||||
"┌ ⚠️ Deno requests run access to \"ls\".\r\n",
|
||||
"├ Requested by `Deno.permissions.request()` API.\r\n",
|
||||
"├ Run again with --allow-run to bypass this prompt.\r\n",
|
||||
"└ Allow? [y/n/A] (y = yes, allow; n = no, deny; A = allow all run permissions)",
|
||||
"┏ ⚠️ Deno requests run access to \"ls\".\r\n",
|
||||
"┠─ Requested by `Deno.permissions.request()` API.\r\n",
|
||||
"┠─ Learn more at: https://docs.deno.com/go/--allow-run\r\n",
|
||||
"┠─ Run again with --allow-run to bypass this prompt.\r\n",
|
||||
"┗ Allow? [y/n/A] (y = yes, allow; n = no, deny; A = allow all run permissions)",
|
||||
));
|
||||
console.human_delay();
|
||||
console.write_line_raw("y");
|
||||
console.expect("Granted run access to \"ls\".");
|
||||
console.expect(concat!(
|
||||
"┌ ⚠️ Deno requests run access to \"cat\".\r\n",
|
||||
"├ Requested by `Deno.permissions.request()` API.\r\n",
|
||||
"├ Run again with --allow-run to bypass this prompt.\r\n",
|
||||
"└ Allow? [y/n/A] (y = yes, allow; n = no, deny; A = allow all run permissions)",
|
||||
"┏ ⚠️ Deno requests run access to \"cat\".\r\n",
|
||||
"┠─ Requested by `Deno.permissions.request()` API.\r\n",
|
||||
"┠─ Learn more at: https://docs.deno.com/go/--allow-run\r\n",
|
||||
"┠─ Run again with --allow-run to bypass this prompt.\r\n",
|
||||
"┗ Allow? [y/n/A] (y = yes, allow; n = no, deny; A = allow all run permissions)",
|
||||
));
|
||||
console.human_delay();
|
||||
console.write_line_raw("n");
|
||||
|
@ -570,70 +574,77 @@ fn permissions_prompt_allow_all() {
|
|||
.with_pty(|mut console| {
|
||||
// "run" permissions
|
||||
console.expect(concat!(
|
||||
"┌ ⚠️ Deno requests run access to \"FOO\".\r\n",
|
||||
"├ Requested by `Deno.permissions.request()` API.\r\n",
|
||||
"├ Run again with --allow-run to bypass this prompt.\r\n",
|
||||
"└ Allow? [y/n/A] (y = yes, allow; n = no, deny; A = allow all run permissions)",
|
||||
"┏ ⚠️ Deno requests run access to \"FOO\".\r\n",
|
||||
"┠─ Requested by `Deno.permissions.request()` API.\r\n",
|
||||
"┠─ Learn more at: https://docs.deno.com/go/--allow-run\r\n",
|
||||
"┠─ Run again with --allow-run to bypass this prompt.\r\n",
|
||||
"┗ Allow? [y/n/A] (y = yes, allow; n = no, deny; A = allow all run permissions)",
|
||||
));
|
||||
console.human_delay();
|
||||
console.write_line_raw("A");
|
||||
console.expect("✅ Granted all run access.");
|
||||
// "read" permissions
|
||||
console.expect(concat!(
|
||||
"┌ ⚠️ Deno requests read access to \"FOO\".\r\n",
|
||||
"├ Requested by `Deno.permissions.request()` API.\r\n",
|
||||
"├ Run again with --allow-read to bypass this prompt.\r\n",
|
||||
"└ Allow? [y/n/A] (y = yes, allow; n = no, deny; A = allow all read permissions)",
|
||||
"┏ ⚠️ Deno requests read access to \"FOO\".\r\n",
|
||||
"┠─ Requested by `Deno.permissions.request()` API.\r\n",
|
||||
"┠─ Learn more at: https://docs.deno.com/go/--allow-read\r\n",
|
||||
"┠─ Run again with --allow-read to bypass this prompt.\r\n",
|
||||
"┗ Allow? [y/n/A] (y = yes, allow; n = no, deny; A = allow all read permissions)",
|
||||
));
|
||||
console.human_delay();
|
||||
console.write_line_raw("A");
|
||||
console.expect("✅ Granted all read access.");
|
||||
// "write" permissions
|
||||
console.expect(concat!(
|
||||
"┌ ⚠️ Deno requests write access to \"FOO\".\r\n",
|
||||
"├ Requested by `Deno.permissions.request()` API.\r\n",
|
||||
"├ Run again with --allow-write to bypass this prompt.\r\n",
|
||||
"└ Allow? [y/n/A] (y = yes, allow; n = no, deny; A = allow all write permissions)",
|
||||
"┏ ⚠️ Deno requests write access to \"FOO\".\r\n",
|
||||
"┠─ Requested by `Deno.permissions.request()` API.\r\n",
|
||||
"┠─ Learn more at: https://docs.deno.com/go/--allow-write\r\n",
|
||||
"┠─ Run again with --allow-write to bypass this prompt.\r\n",
|
||||
"┗ Allow? [y/n/A] (y = yes, allow; n = no, deny; A = allow all write permissions)",
|
||||
));
|
||||
console.human_delay();
|
||||
console.write_line_raw("A");
|
||||
console.expect("✅ Granted all write access.");
|
||||
// "net" permissions
|
||||
console.expect(concat!(
|
||||
"┌ ⚠️ Deno requests net access to \"foo\".\r\n",
|
||||
"├ Requested by `Deno.permissions.request()` API.\r\n",
|
||||
"├ Run again with --allow-net to bypass this prompt.\r\n",
|
||||
"└ Allow? [y/n/A] (y = yes, allow; n = no, deny; A = allow all net permissions)",
|
||||
"┏ ⚠️ Deno requests net access to \"foo\".\r\n",
|
||||
"┠─ Requested by `Deno.permissions.request()` API.\r\n",
|
||||
"┠─ Learn more at: https://docs.deno.com/go/--allow-net\r\n",
|
||||
"┠─ Run again with --allow-net to bypass this prompt.\r\n",
|
||||
"┗ Allow? [y/n/A] (y = yes, allow; n = no, deny; A = allow all net permissions)",
|
||||
));
|
||||
console.human_delay();
|
||||
console.write_line_raw("A");
|
||||
console.expect("✅ Granted all net access.");
|
||||
// "env" permissions
|
||||
console.expect(concat!(
|
||||
"┌ ⚠️ Deno requests env access to \"FOO\".\r\n",
|
||||
"├ Requested by `Deno.permissions.request()` API.\r\n",
|
||||
"├ Run again with --allow-env to bypass this prompt.\r\n",
|
||||
"└ Allow? [y/n/A] (y = yes, allow; n = no, deny; A = allow all env permissions)",
|
||||
"┏ ⚠️ Deno requests env access to \"FOO\".\r\n",
|
||||
"┠─ Requested by `Deno.permissions.request()` API.\r\n",
|
||||
"┠─ Learn more at: https://docs.deno.com/go/--allow-env\r\n",
|
||||
"┠─ Run again with --allow-env to bypass this prompt.\r\n",
|
||||
"┗ Allow? [y/n/A] (y = yes, allow; n = no, deny; A = allow all env permissions)",
|
||||
));
|
||||
console.human_delay();
|
||||
console.write_line_raw("A");
|
||||
console.expect("✅ Granted all env access.");
|
||||
// "sys" permissions
|
||||
console.expect(concat!(
|
||||
"┌ ⚠️ Deno requests sys access to \"loadavg\".\r\n",
|
||||
"├ Requested by `Deno.permissions.request()` API.\r\n",
|
||||
"├ Run again with --allow-sys to bypass this prompt.\r\n",
|
||||
"└ Allow? [y/n/A] (y = yes, allow; n = no, deny; A = allow all sys permissions)",
|
||||
"┏ ⚠️ Deno requests sys access to \"loadavg\".\r\n",
|
||||
"┠─ Requested by `Deno.permissions.request()` API.\r\n",
|
||||
"┠─ Learn more at: https://docs.deno.com/go/--allow-sys\r\n",
|
||||
"┠─ Run again with --allow-sys to bypass this prompt.\r\n",
|
||||
"┗ Allow? [y/n/A] (y = yes, allow; n = no, deny; A = allow all sys permissions)",
|
||||
));
|
||||
console.human_delay();
|
||||
console.write_line_raw("A");
|
||||
console.expect("✅ Granted all sys access.");
|
||||
// "ffi" permissions
|
||||
console.expect(concat!(
|
||||
"┌ ⚠️ Deno requests ffi access to \"FOO\".\r\n",
|
||||
"├ Requested by `Deno.permissions.request()` API.\r\n",
|
||||
"├ Run again with --allow-ffi to bypass this prompt.\r\n",
|
||||
"└ Allow? [y/n/A] (y = yes, allow; n = no, deny; A = allow all ffi permissions)",
|
||||
"┏ ⚠️ Deno requests ffi access to \"FOO\".\r\n",
|
||||
"┠─ Requested by `Deno.permissions.request()` API.\r\n",
|
||||
"┠─ Learn more at: https://docs.deno.com/go/--allow-ffi\r\n",
|
||||
"┠─ Run again with --allow-ffi to bypass this prompt.\r\n",
|
||||
"┗ Allow? [y/n/A] (y = yes, allow; n = no, deny; A = allow all ffi permissions)",
|
||||
));
|
||||
console.human_delay();
|
||||
console.write_line_raw("A");
|
||||
|
@ -650,9 +661,10 @@ fn permissions_prompt_allow_all_2() {
|
|||
.with_pty(|mut console| {
|
||||
// "env" permissions
|
||||
console.expect(concat!(
|
||||
"┌ ⚠️ Deno requests env access to \"FOO\".\r\n",
|
||||
"├ Run again with --allow-env to bypass this prompt.\r\n",
|
||||
"└ Allow? [y/n/A] (y = yes, allow; n = no, deny; A = allow all env permissions)",
|
||||
"┏ ⚠️ Deno requests env access to \"FOO\".\r\n",
|
||||
"┠─ Learn more at: https://docs.deno.com/go/--allow-env\r\n",
|
||||
"┠─ Run again with --allow-env to bypass this prompt.\r\n",
|
||||
"┗ Allow? [y/n/A] (y = yes, allow; n = no, deny; A = allow all env permissions)",
|
||||
));
|
||||
console.human_delay();
|
||||
console.write_line_raw("A");
|
||||
|
@ -660,10 +672,11 @@ fn permissions_prompt_allow_all_2() {
|
|||
|
||||
// "sys" permissions
|
||||
console.expect(concat!(
|
||||
"┌ ⚠️ Deno requests sys access to \"loadavg\".\r\n",
|
||||
"├ Requested by `Deno.loadavg()` API.\r\n",
|
||||
"├ Run again with --allow-sys to bypass this prompt.\r\n",
|
||||
"└ Allow? [y/n/A] (y = yes, allow; n = no, deny; A = allow all sys permissions)",
|
||||
"┏ ⚠️ Deno requests sys access to \"loadavg\".\r\n",
|
||||
"┠─ Requested by `Deno.loadavg()` API.\r\n",
|
||||
"┠─ Learn more at: https://docs.deno.com/go/--allow-sys\r\n",
|
||||
"┠─ Run again with --allow-sys to bypass this prompt.\r\n",
|
||||
"┗ Allow? [y/n/A] (y = yes, allow; n = no, deny; A = allow all sys permissions)",
|
||||
));
|
||||
console.human_delay();
|
||||
console.write_line_raw("A");
|
||||
|
@ -671,10 +684,11 @@ fn permissions_prompt_allow_all_2() {
|
|||
|
||||
// "read" permissions
|
||||
console.expect(concat!(
|
||||
"┌ ⚠️ Deno requests read access to <CWD>.\r\n",
|
||||
"├ Requested by `Deno.cwd()` API.\r\n",
|
||||
"├ Run again with --allow-read to bypass this prompt.\r\n",
|
||||
"└ Allow? [y/n/A] (y = yes, allow; n = no, deny; A = allow all read permissions)",
|
||||
"┏ ⚠️ Deno requests read access to <CWD>.\r\n",
|
||||
"┠─ Requested by `Deno.cwd()` API.\r\n",
|
||||
"┠─ Learn more at: https://docs.deno.com/go/--allow-read\r\n",
|
||||
"┠─ Run again with --allow-read to bypass this prompt.\r\n",
|
||||
"┗ Allow? [y/n/A] (y = yes, allow; n = no, deny; A = allow all read permissions)",
|
||||
));
|
||||
console.human_delay();
|
||||
console.write_line_raw("A");
|
||||
|
@ -690,10 +704,11 @@ fn permissions_prompt_allow_all_lowercase_a() {
|
|||
.with_pty(|mut console| {
|
||||
// "run" permissions
|
||||
console.expect(concat!(
|
||||
"┌ ⚠️ Deno requests run access to \"FOO\".\r\n",
|
||||
"├ Requested by `Deno.permissions.request()` API.\r\n",
|
||||
"├ Run again with --allow-run to bypass this prompt.\r\n",
|
||||
"└ Allow? [y/n/A] (y = yes, allow; n = no, deny; A = allow all run permissions)",
|
||||
"┏ ⚠️ Deno requests run access to \"FOO\".\r\n",
|
||||
"┠─ Requested by `Deno.permissions.request()` API.\r\n",
|
||||
"┠─ Learn more at: https://docs.deno.com/go/--allow-run\r\n",
|
||||
"┠─ Run again with --allow-run to bypass this prompt.\r\n",
|
||||
"┗ Allow? [y/n/A] (y = yes, allow; n = no, deny; A = allow all run permissions)",
|
||||
));
|
||||
console.human_delay();
|
||||
console.write_line_raw("a");
|
||||
|
@ -733,10 +748,11 @@ fn permissions_cache() {
|
|||
.with_pty(|mut console| {
|
||||
console.expect(concat!(
|
||||
"prompt\r\n",
|
||||
"┌ ⚠️ Deno requests read access to \"foo\".\r\n",
|
||||
"├ Requested by `Deno.permissions.request()` API.\r\n",
|
||||
"├ Run again with --allow-read to bypass this prompt.\r\n",
|
||||
"└ Allow? [y/n/A] (y = yes, allow; n = no, deny; A = allow all read permissions)",
|
||||
"┏ ⚠️ Deno requests read access to \"foo\".\r\n",
|
||||
"┠─ Requested by `Deno.permissions.request()` API.\r\n",
|
||||
"┠─ Learn more at: https://docs.deno.com/go/--allow-read\r\n",
|
||||
"┠─ Run again with --allow-read to bypass this prompt.\r\n",
|
||||
"┗ Allow? [y/n/A] (y = yes, allow; n = no, deny; A = allow all read permissions)",
|
||||
));
|
||||
console.human_delay();
|
||||
console.write_line_raw("y");
|
||||
|
@ -2965,18 +2981,20 @@ mod permissions {
|
|||
.args_vec(["run", "--quiet", "run/061_permissions_request.ts"])
|
||||
.with_pty(|mut console| {
|
||||
console.expect(concat!(
|
||||
"┌ ⚠️ Deno requests read access to \"foo\".\r\n",
|
||||
"├ Requested by `Deno.permissions.request()` API.\r\n",
|
||||
"├ Run again with --allow-read to bypass this prompt.\r\n",
|
||||
"└ Allow? [y/n/A] (y = yes, allow; n = no, deny; A = allow all read permissions)",
|
||||
"┏ ⚠️ Deno requests read access to \"foo\".\r\n",
|
||||
"┠─ Requested by `Deno.permissions.request()` API.\r\n",
|
||||
"┠─ Learn more at: https://docs.deno.com/go/--allow-read\r\n",
|
||||
"┠─ Run again with --allow-read to bypass this prompt.\r\n",
|
||||
"┗ Allow? [y/n/A] (y = yes, allow; n = no, deny; A = allow all read permissions)",
|
||||
));
|
||||
console.human_delay();
|
||||
console.write_line_raw("y");
|
||||
console.expect(concat!(
|
||||
"┌ ⚠️ Deno requests read access to \"bar\".\r\n",
|
||||
"├ Requested by `Deno.permissions.request()` API.\r\n",
|
||||
"├ Run again with --allow-read to bypass this prompt.\r\n",
|
||||
"└ Allow? [y/n/A] (y = yes, allow; n = no, deny; A = allow all read permissions)",
|
||||
"┏ ⚠️ Deno requests read access to \"bar\".\r\n",
|
||||
"┠─ Requested by `Deno.permissions.request()` API.\r\n",
|
||||
"┠─ Learn more at: https://docs.deno.com/go/--allow-read\r\n",
|
||||
"┠─ Run again with --allow-read to bypass this prompt.\r\n",
|
||||
"┗ Allow? [y/n/A] (y = yes, allow; n = no, deny; A = allow all read permissions)",
|
||||
));
|
||||
console.human_delay();
|
||||
console.write_line_raw("n");
|
||||
|
@ -2993,18 +3011,20 @@ mod permissions {
|
|||
.args_vec(["run", "--quiet", "run/061_permissions_request_sync.ts"])
|
||||
.with_pty(|mut console| {
|
||||
console.expect(concat!(
|
||||
"┌ ⚠️ Deno requests read access to \"foo\".\r\n",
|
||||
"├ Requested by `Deno.permissions.request()` API.\r\n",
|
||||
"├ Run again with --allow-read to bypass this prompt.\r\n",
|
||||
"└ Allow? [y/n/A] (y = yes, allow; n = no, deny; A = allow all read permissions)",
|
||||
"┏ ⚠️ Deno requests read access to \"foo\".\r\n",
|
||||
"┠─ Requested by `Deno.permissions.request()` API.\r\n",
|
||||
"┠─ Learn more at: https://docs.deno.com/go/--allow-read\r\n",
|
||||
"┠─ Run again with --allow-read to bypass this prompt.\r\n",
|
||||
"┗ Allow? [y/n/A] (y = yes, allow; n = no, deny; A = allow all read permissions)",
|
||||
));
|
||||
console.human_delay();
|
||||
console.write_line_raw("y");
|
||||
console.expect(concat!(
|
||||
"┌ ⚠️ Deno requests read access to \"bar\".\r\n",
|
||||
"├ Requested by `Deno.permissions.request()` API.\r\n",
|
||||
"├ Run again with --allow-read to bypass this prompt.\r\n",
|
||||
"└ Allow? [y/n/A] (y = yes, allow; n = no, deny; A = allow all read permissions)",
|
||||
"┏ ⚠️ Deno requests read access to \"bar\".\r\n",
|
||||
"┠─ Requested by `Deno.permissions.request()` API.\r\n",
|
||||
"┠─ Learn more at: https://docs.deno.com/go/--allow-read\r\n",
|
||||
"┠─ Run again with --allow-read to bypass this prompt.\r\n",
|
||||
"┗ Allow? [y/n/A] (y = yes, allow; n = no, deny; A = allow all read permissions)",
|
||||
));
|
||||
console.human_delay();
|
||||
console.write_line_raw("n");
|
||||
|
@ -3021,10 +3041,11 @@ mod permissions {
|
|||
.args_vec(["run", "--quiet", "run/062_permissions_request_global.ts"])
|
||||
.with_pty(|mut console| {
|
||||
console.expect(concat!(
|
||||
"┌ ⚠️ Deno requests read access.\r\n",
|
||||
"├ Requested by `Deno.permissions.request()` API.\r\n",
|
||||
"├ Run again with --allow-read to bypass this prompt.\r\n",
|
||||
"└ Allow? [y/n/A] (y = yes, allow; n = no, deny; A = allow all read permissions)",
|
||||
"┏ ⚠️ Deno requests read access.\r\n",
|
||||
"┠─ Requested by `Deno.permissions.request()` API.\r\n",
|
||||
"┠─ Learn more at: https://docs.deno.com/go/--allow-read\r\n",
|
||||
"┠─ Run again with --allow-read to bypass this prompt.\r\n",
|
||||
"┗ Allow? [y/n/A] (y = yes, allow; n = no, deny; A = allow all read permissions)",
|
||||
));
|
||||
console.human_delay();
|
||||
console.write_line_raw("y\n");
|
||||
|
@ -3044,10 +3065,11 @@ mod permissions {
|
|||
.args_vec(["run", "--quiet", "run/062_permissions_request_global_sync.ts"])
|
||||
.with_pty(|mut console| {
|
||||
console.expect(concat!(
|
||||
"┌ ⚠️ Deno requests read access.\r\n",
|
||||
"├ Requested by `Deno.permissions.request()` API.\r\n",
|
||||
"├ Run again with --allow-read to bypass this prompt.\r\n",
|
||||
"└ Allow? [y/n/A] (y = yes, allow; n = no, deny; A = allow all read permissions)",
|
||||
"┏ ⚠️ Deno requests read access.\r\n",
|
||||
"┠─ Requested by `Deno.permissions.request()` API.\r\n",
|
||||
"┠─ Learn more at: https://docs.deno.com/go/--allow-read\r\n",
|
||||
"┠─ Run again with --allow-read to bypass this prompt.\r\n",
|
||||
"┗ Allow? [y/n/A] (y = yes, allow; n = no, deny; A = allow all read permissions)",
|
||||
));
|
||||
console.human_delay();
|
||||
console.write_line_raw("y");
|
||||
|
@ -3200,18 +3222,20 @@ fn issue9750() {
|
|||
console.expect("Enter 'yy':");
|
||||
console.write_line_raw("yy");
|
||||
console.expect(concat!(
|
||||
"┌ ⚠️ Deno requests env access.\r\n",
|
||||
"├ Requested by `Deno.permissions.request()` API.\r\n",
|
||||
"├ Run again with --allow-env to bypass this prompt.\r\n",
|
||||
"└ Allow? [y/n/A] (y = yes, allow; n = no, deny; A = allow all env permissions)",
|
||||
"┏ ⚠️ Deno requests env access.\r\n",
|
||||
"┠─ Requested by `Deno.permissions.request()` API.\r\n",
|
||||
"┠─ Learn more at: https://docs.deno.com/go/--allow-env\r\n",
|
||||
"┠─ Run again with --allow-env to bypass this prompt.\r\n",
|
||||
"┗ Allow? [y/n/A] (y = yes, allow; n = no, deny; A = allow all env permissions)",
|
||||
));
|
||||
console.human_delay();
|
||||
console.write_line_raw("n");
|
||||
console.expect("Denied env access.");
|
||||
console.expect(concat!(
|
||||
"┌ ⚠️ Deno requests env access to \"SECRET\".\r\n",
|
||||
"├ Run again with --allow-env to bypass this prompt.\r\n",
|
||||
"└ Allow? [y/n/A] (y = yes, allow; n = no, deny; A = allow all env permissions)",
|
||||
"┏ ⚠️ Deno requests env access to \"SECRET\".\r\n",
|
||||
"┠─ Learn more at: https://docs.deno.com/go/--allow-env\r\n",
|
||||
"┠─ Run again with --allow-env to bypass this prompt.\r\n",
|
||||
"┗ Allow? [y/n/A] (y = yes, allow; n = no, deny; A = allow all env permissions)",
|
||||
));
|
||||
console.human_delay();
|
||||
console.write_line_raw("n");
|
||||
|
@ -4618,11 +4642,11 @@ fn stdio_streams_are_locked_in_permission_prompt() {
|
|||
} else {
|
||||
"\r\n"
|
||||
};
|
||||
console.expect_raw_next(format!("i{newline}\u{1b}[1A\u{1b}[0J└ Unrecognized option. Allow? [y/n/A] (y = yes, allow; n = no, deny; A = allow all read permissions) > "));
|
||||
console.expect_raw_next(format!("i{newline}\u{1b}[1A\u{1b}[0J┗ Unrecognized option. Allow? [y/n/A] (y = yes, allow; n = no, deny; A = allow all read permissions) > "));
|
||||
console.human_delay();
|
||||
console.write_line_raw("y");
|
||||
// We ensure that nothing gets written here between the permission prompt and this text, despire the delay
|
||||
console.expect_raw_next(format!("y{newline}\x1b[4A\x1b[0J✅ Granted read access to \""));
|
||||
console.expect_raw_next(format!("y{newline}\x1b[5A\x1b[0J✅ Granted read access to \""));
|
||||
|
||||
// Back to spamming!
|
||||
console.expect(malicious_output);
|
||||
|
@ -4642,7 +4666,7 @@ fn permission_prompt_escapes_ansi_codes_and_control_chars() {
|
|||
"\\rDo you like ice cream? y/n"
|
||||
};
|
||||
console.expect(format!(
|
||||
"\u{250c} \u{26a0}\u{fe0f} Deno requests env access to \"{}\".",
|
||||
"\u{250f} \u{26a0}\u{fe0f} Deno requests env access to \"{}\".",
|
||||
env_name
|
||||
))
|
||||
});
|
||||
|
@ -4655,7 +4679,7 @@ fn permission_prompt_escapes_ansi_codes_and_control_chars() {
|
|||
console.write_line_raw(
|
||||
r#"new Deno.Command(`${boldANSI}cat${unboldANSI}`).spawn();"#,
|
||||
);
|
||||
console.expect("\u{250c} \u{26a0}\u{fe0f} Deno requests run access to \"\\u{1b}[1mcat\\u{1b}[22m\".");
|
||||
console.expect("\u{250f} \u{26a0}\u{fe0f} Deno requests run access to \"\\u{1b}[1mcat\\u{1b}[22m\".");
|
||||
});
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue