diff options
author | Bartek IwaĆczuk <biwanczuk@gmail.com> | 2020-05-11 13:13:27 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-05-11 13:13:27 +0200 |
commit | 32aeec9630dc91162f0408b95dd86e1c26e4c1d3 (patch) | |
tree | f93d8e6b665df0c3054dba56973712412916493e /cli/global_state.rs | |
parent | 0d148c6e80583dfe029d5362f61b92334a22341a (diff) |
refactor: check permissions in SourceFileFetcher (#5011)
This PR hot-fixes permission escapes in dynamic imports, workers
and runtime compiler APIs.
"permissions" parameter was added to public APIs of SourceFileFetcher
and appropriate permission checks are performed during loading of
local and remote files.
Diffstat (limited to 'cli/global_state.rs')
-rw-r--r-- | cli/global_state.rs | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/cli/global_state.rs b/cli/global_state.rs index b91ba5b10..4e9bdbb99 100644 --- a/cli/global_state.rs +++ b/cli/global_state.rs @@ -86,7 +86,6 @@ impl GlobalState { compiler_starts: AtomicUsize::new(0), compile_lock: AsyncMutex::new(()), }; - Ok(GlobalState(Arc::new(inner))) } @@ -95,6 +94,7 @@ impl GlobalState { module_specifier: ModuleSpecifier, maybe_referrer: Option<ModuleSpecifier>, target_lib: TargetLib, + permissions: Permissions, ) -> Result<CompiledModule, ErrBox> { let state1 = self.clone(); let state2 = self.clone(); @@ -102,7 +102,7 @@ impl GlobalState { let out = self .file_fetcher - .fetch_source_file(&module_specifier, maybe_referrer) + .fetch_source_file(&module_specifier, maybe_referrer, permissions.clone()) .await?; // TODO(ry) Try to lift compile_lock as high up in the call stack for @@ -115,14 +115,14 @@ impl GlobalState { | msg::MediaType::JSX => { state1 .ts_compiler - .compile(state1.clone(), &out, target_lib) + .compile(state1.clone(), &out, target_lib, permissions.clone()) .await } msg::MediaType::JavaScript => { if state1.ts_compiler.compile_js { state2 .ts_compiler - .compile(state1.clone(), &out, target_lib) + .compile(state1.clone(), &out, target_lib, permissions.clone()) .await } else { if let Some(types_url) = out.types_url.clone() { @@ -132,6 +132,7 @@ impl GlobalState { .fetch_source_file( &types_specifier, Some(module_specifier.clone()), + permissions.clone(), ) .await .ok(); |