diff options
author | Bartek IwaĆczuk <biwanczuk@gmail.com> | 2023-01-10 14:35:44 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-01-10 14:35:44 +0100 |
commit | 636352e0ca1e611c7673f2ab68538e1ddb2dc5b7 (patch) | |
tree | c250c7a74917cef683999e06283ea9f7182f372c /ext/node/package_json.rs | |
parent | 45768f0e832e54d61ddb5a62d62239aef0e597b5 (diff) |
fix(npm): allow to read package.json if permissions are granted (#17209)
This commit changes signature of "deno_core::ModuleLoader::resolve" to pass
an enum indicating whether or not we're resolving a specifier for dynamic import.
Additionally "CliModuleLoader" was changes to store both "parent permissions" (or
"root permissions") as well as "dynamic permissions" that allow to check for permissions
in top-level module load an dynamic imports.
Then all code paths that have anything to do with Node/npm compat are now checking
for permissions which are passed from module loader instance associated with given
worker.
Diffstat (limited to 'ext/node/package_json.rs')
-rw-r--r-- | ext/node/package_json.rs | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/ext/node/package_json.rs b/ext/node/package_json.rs index f0a2b4f4d..5894b8831 100644 --- a/ext/node/package_json.rs +++ b/ext/node/package_json.rs @@ -1,6 +1,7 @@ // Copyright 2018-2023 the Deno authors. All rights reserved. MIT license. use crate::NodeModuleKind; +use crate::NodePermissions; use super::RequireNpmResolver; use deno_core::anyhow; @@ -47,9 +48,10 @@ impl PackageJson { pub fn load( resolver: &dyn RequireNpmResolver, + permissions: &mut dyn NodePermissions, path: PathBuf, ) -> Result<PackageJson, AnyError> { - resolver.ensure_read_permission(&path)?; + resolver.ensure_read_permission(permissions, &path)?; Self::load_skip_read_permission(path) } |