From 64a7187238c4f291f254bd6eb58138a3a6534898 Mon Sep 17 00:00:00 2001 From: Luca Casonato Date: Mon, 4 Oct 2021 22:56:24 +0200 Subject: chore: remove No*Permissions structs (#12316) These are confusing. They say they are "for users that don't care about permissions", but that isn't correct. `NoTimersPermissions` disables permissions instead of enabling them. I would argue that implementors should decide what permissions they want themselves, and not take our opinionated permissions struct. --- runtime/build.rs | 84 ++++++++++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 75 insertions(+), 9 deletions(-) (limited to 'runtime') diff --git a/runtime/build.rs b/runtime/build.rs index 52933f19b..920aafc9f 100644 --- a/runtime/build.rs +++ b/runtime/build.rs @@ -41,6 +41,76 @@ mod not_docs { println!("Snapshot written to: {} ", snapshot_path.display()); } + struct Permissions; + + impl deno_fetch::FetchPermissions for Permissions { + fn check_net_url( + &mut self, + _url: &deno_core::url::Url, + ) -> Result<(), deno_core::error::AnyError> { + unreachable!("snapshotting!") + } + + fn check_read( + &mut self, + _p: &Path, + ) -> Result<(), deno_core::error::AnyError> { + unreachable!("snapshotting!") + } + } + + impl deno_websocket::WebSocketPermissions for Permissions { + fn check_net_url( + &mut self, + _url: &deno_core::url::Url, + ) -> Result<(), deno_core::error::AnyError> { + unreachable!("snapshotting!") + } + } + + impl deno_timers::TimersPermission for Permissions { + fn allow_hrtime(&mut self) -> bool { + unreachable!("snapshotting!") + } + + fn check_unstable( + &self, + _state: &deno_core::OpState, + _api_name: &'static str, + ) { + unreachable!("snapshotting!") + } + } + + impl deno_ffi::FfiPermissions for Permissions { + fn check(&mut self, _path: &str) -> Result<(), deno_core::error::AnyError> { + unreachable!("snapshotting!") + } + } + + impl deno_net::NetPermissions for Permissions { + fn check_net>( + &mut self, + _host: &(T, Option), + ) -> Result<(), deno_core::error::AnyError> { + unreachable!("snapshotting!") + } + + fn check_read( + &mut self, + _p: &Path, + ) -> Result<(), deno_core::error::AnyError> { + unreachable!("snapshotting!") + } + + fn check_write( + &mut self, + _p: &Path, + ) -> Result<(), deno_core::error::AnyError> { + unreachable!("snapshotting!") + } + } + fn create_runtime_snapshot(snapshot_path: &Path, files: Vec) { let extensions: Vec = vec![ deno_webidl::init(), @@ -48,7 +118,7 @@ mod not_docs { deno_url::init(), deno_tls::init(), deno_web::init(deno_web::BlobStore::default(), Default::default()), - deno_fetch::init::( + deno_fetch::init::( "".to_owned(), None, None, @@ -56,21 +126,17 @@ mod not_docs { None, None, ), - deno_websocket::init::( - "".to_owned(), - None, - None, - ), + deno_websocket::init::("".to_owned(), None, None), deno_webstorage::init(None), deno_crypto::init(None), deno_webgpu::init(false), - deno_timers::init::(), + deno_timers::init::(), deno_broadcast_channel::init( deno_broadcast_channel::InMemoryBroadcastChannel::default(), false, // No --unstable. ), - deno_ffi::init::(false), - deno_net::init::( + deno_ffi::init::(false), + deno_net::init::( None, false, // No --unstable. None, ), -- cgit v1.2.3