diff options
author | David Sherret <dsherret@users.noreply.github.com> | 2024-10-04 20:55:41 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-10-04 20:55:41 +0100 |
commit | 2de4faa483982478e9a36ad4ab891a887b4779f1 (patch) | |
tree | 5ee8512e5dc380759054900943074d5b6ee8c65c /ext/node/lib.rs | |
parent | f288730c38bd4f13b464a9bd67eb901a8c790bc4 (diff) |
refactor: improve node permission checks (#26028)
Does less work when requesting permissions with `-A`
Diffstat (limited to 'ext/node/lib.rs')
-rw-r--r-- | ext/node/lib.rs | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/ext/node/lib.rs b/ext/node/lib.rs index d23c07204..03462f36f 100644 --- a/ext/node/lib.rs +++ b/ext/node/lib.rs @@ -66,6 +66,7 @@ pub trait NodePermissions { &mut self, path: &'a Path, ) -> Result<Cow<'a, Path>, AnyError>; + fn query_read_all(&mut self) -> bool; fn check_sys(&mut self, kind: &str, api_name: &str) -> Result<(), AnyError>; #[must_use = "the resolved return value to mitigate time-of-check to time-of-use issues"] fn check_write_with_api_name( @@ -103,6 +104,10 @@ impl NodePermissions for deno_permissions::PermissionsContainer { deno_permissions::PermissionsContainer::check_read_path(self, path, None) } + fn query_read_all(&mut self) -> bool { + deno_permissions::PermissionsContainer::query_read_all(self) + } + #[inline(always)] fn check_write_with_api_name( &mut self, @@ -124,11 +129,12 @@ pub type NodeRequireResolverRc = deno_fs::sync::MaybeArc<dyn NodeRequireResolver>; pub trait NodeRequireResolver: std::fmt::Debug + MaybeSend + MaybeSync { - fn ensure_read_permission( + #[must_use = "the resolved return value to mitigate time-of-check to time-of-use issues"] + fn ensure_read_permission<'a>( &self, permissions: &mut dyn NodePermissions, - path: &Path, - ) -> Result<(), AnyError>; + path: &'a Path, + ) -> Result<Cow<'a, Path>, AnyError>; } pub static NODE_ENV_VAR_ALLOWLIST: Lazy<HashSet<String>> = Lazy::new(|| { |