summaryrefslogtreecommitdiff
path: root/cli/ops/compiler.rs
diff options
context:
space:
mode:
authorBartek IwaƄczuk <biwanczuk@gmail.com>2020-05-02 15:51:08 +0200
committerGitHub <noreply@github.com>2020-05-02 15:51:08 +0200
commit2872b362ff76273d897d75bb8a3ddd5510c182f4 (patch)
tree7b1061aacca70eec34be3e307719f5113d932b57 /cli/ops/compiler.rs
parentde2c042482741dc23f7d975458a1fba95863de53 (diff)
BREAKING: disallow static import of local modules from remote modules (#5050)
This commit changes module loading logic to disallow statically import local module (file:// scheme) from remote modules (http://, https:// schemes).
Diffstat (limited to 'cli/ops/compiler.rs')
-rw-r--r--cli/ops/compiler.rs18
1 files changed, 18 insertions, 0 deletions
diff --git a/cli/ops/compiler.rs b/cli/ops/compiler.rs
index 1029070a8..c66b56d43 100644
--- a/cli/ops/compiler.rs
+++ b/cli/ops/compiler.rs
@@ -112,6 +112,24 @@ fn op_fetch_source_files(
async move {
let resolved_specifier = ModuleSpecifier::resolve_url(&specifier)
.expect("Invalid specifier");
+ // TODO(bartlomieju): duplicated from `state.rs::ModuleLoader::load` - deduplicate
+ // Verify that remote file doesn't try to statically import local file.
+ if let Some(referrer) = ref_specifier_.as_ref() {
+ let referrer_url = referrer.as_url();
+ match referrer_url.scheme() {
+ "http" | "https" => {
+ let specifier_url = resolved_specifier.as_url();
+ match specifier_url.scheme() {
+ "http" | "https" => {},
+ _ => {
+ let e = OpError::permission_denied("Remote module are not allowed to statically import local modules. Use dynamic import instead.".to_string());
+ return Err(e.into());
+ }
+ }
+ },
+ _ => {}
+ }
+ }
file_fetcher_
.fetch_source_file(&resolved_specifier, ref_specifier_)
.await