From e5b5753dd329ec78ccef8c2a872d2856c37b4642 Mon Sep 17 00:00:00 2001 From: Ryan Dahl Date: Wed, 16 Feb 2022 18:17:24 -0500 Subject: [PATCH] feat: never prompt for hrtime permission (#13696) --- runtime/permissions.rs | 26 +++++++++++--------------- 1 file changed, 11 insertions(+), 15 deletions(-) diff --git a/runtime/permissions.rs b/runtime/permissions.rs index 88cd7b51b1..7d8a2bb259 100644 --- a/runtime/permissions.rs +++ b/runtime/permissions.rs @@ -1156,7 +1156,7 @@ impl Default for Permissions { env: Permissions::new_env(&None, false), run: Permissions::new_run(&None, false), ffi: Permissions::new_ffi(&None, false), - hrtime: Permissions::new_hrtime(false, false), + hrtime: Permissions::new_hrtime(false), } } } @@ -1263,12 +1263,12 @@ impl Permissions { } } - pub fn new_hrtime(state: bool, prompt: bool) -> UnitPermission { + pub fn new_hrtime(state: bool) -> UnitPermission { unit_permission_from_flag_bool( state, "hrtime", "high precision time", - prompt, + false, // never prompt for hrtime ) } @@ -1280,7 +1280,7 @@ impl Permissions { env: Permissions::new_env(&opts.allow_env, opts.prompt), run: Permissions::new_run(&opts.allow_run, opts.prompt), ffi: Permissions::new_ffi(&opts.allow_ffi, opts.prompt), - hrtime: Permissions::new_hrtime(opts.allow_hrtime, opts.prompt), + hrtime: Permissions::new_hrtime(opts.allow_hrtime), } } @@ -1292,7 +1292,7 @@ impl Permissions { env: Permissions::new_env(&Some(vec![]), false), run: Permissions::new_run(&Some(vec![]), false), ffi: Permissions::new_ffi(&Some(vec![]), false), - hrtime: Permissions::new_hrtime(true, false), + hrtime: Permissions::new_hrtime(true), } } @@ -2400,7 +2400,7 @@ mod tests { }, hrtime: UnitPermission { state: PermissionState::Prompt, - ..Permissions::new_hrtime(false, false) + ..Permissions::new_hrtime(false) }, }; #[rustfmt::skip] @@ -2516,7 +2516,7 @@ mod tests { }, hrtime: UnitPermission { state: PermissionState::Denied, - ..Permissions::new_hrtime(false, false) + ..Permissions::new_hrtime(false) }, }; #[rustfmt::skip] @@ -2546,7 +2546,7 @@ mod tests { env: Permissions::new_env(&None, true), run: Permissions::new_run(&None, true), ffi: Permissions::new_ffi(&None, true), - hrtime: Permissions::new_hrtime(false, true), + hrtime: Permissions::new_hrtime(false), }; let prompt_value = PERMISSION_PROMPT_STUB_VALUE_SETTER.lock(); @@ -2584,10 +2584,7 @@ mod tests { assert!(perms.env.check("HOME").is_ok()); assert!(perms.env.check("PATH").is_err()); - prompt_value.set(true); - assert!(perms.hrtime.check().is_ok()); - prompt_value.set(false); - assert!(perms.hrtime.check().is_ok()); + assert!(perms.hrtime.check().is_err()); } #[test] @@ -2599,7 +2596,7 @@ mod tests { env: Permissions::new_env(&None, true), run: Permissions::new_run(&None, true), ffi: Permissions::new_ffi(&None, true), - hrtime: Permissions::new_hrtime(false, true), + hrtime: Permissions::new_hrtime(false), }; let prompt_value = PERMISSION_PROMPT_STUB_VALUE_SETTER.lock(); @@ -2817,7 +2814,7 @@ mod tests { fn test_create_child_permissions() { let mut main_perms = Permissions { env: Permissions::new_env(&Some(vec![]), false), - hrtime: Permissions::new_hrtime(true, false), + hrtime: Permissions::new_hrtime(true), net: Permissions::new_net(&Some(svec!["foo", "bar"]), false), ..Default::default() }; @@ -2876,7 +2873,6 @@ mod tests { let worker_perms = create_child_permissions( &mut main_perms, ChildPermissionsArg { - hrtime: ChildUnitPermissionArg::Granted, read: ChildUnaryPermissionArg::Granted, run: ChildUnaryPermissionArg::GrantedList(svec!["foo", "bar"]), ..Default::default()