-
Notifications
You must be signed in to change notification settings - Fork 922
Disallow mounting folders on the guest's root for WASIX modules #5475
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5,7 +5,7 @@ use std::{ | |
| sync::Arc, | ||
| }; | ||
|
|
||
| use anyhow::{Context, Error}; | ||
| use anyhow::{bail, Context, Error}; | ||
| use futures::{future::BoxFuture, StreamExt, TryStreamExt}; | ||
| use once_cell::sync::OnceCell; | ||
| use petgraph::visit::EdgeRef; | ||
|
|
@@ -399,9 +399,6 @@ fn filesystem_v3( | |
| ) -> Result<Box<dyn FileSystem + Send + Sync>, Error> { | ||
| let mut volumes: HashMap<&PackageId, BTreeMap<String, Volume>> = HashMap::new(); | ||
|
|
||
| let mut mountings: Vec<_> = pkg.filesystem.iter().collect(); | ||
| mountings.sort_by_key(|m| std::cmp::Reverse(m.mount_path.as_path())); | ||
|
|
||
| let union_fs = UnionFileSystem::new(); | ||
|
|
||
| for ResolvedFileSystemMapping { | ||
|
|
@@ -415,6 +412,12 @@ fn filesystem_v3( | |
| continue; | ||
| } | ||
|
|
||
| if mount_path.as_path() == Path::new("/") { | ||
| bail!( | ||
| "The \"{package}\" package wants to mount a volume at \"/\", but that's not allowed", | ||
| ); | ||
| } | ||
|
|
||
| // Note: We want to reuse existing Volume instances if we can. That way | ||
| // we can keep the memory usage down. A webc::compat::Volume is | ||
| // reference-counted, anyway. | ||
|
|
@@ -474,9 +477,6 @@ fn filesystem_v2( | |
| let mut filesystems = Vec::new(); | ||
| let mut volumes: HashMap<&PackageId, BTreeMap<String, Volume>> = HashMap::new(); | ||
|
|
||
| let mut mountings: Vec<_> = pkg.filesystem.iter().collect(); | ||
| mountings.sort_by_key(|m| std::cmp::Reverse(m.mount_path.as_path())); | ||
|
|
||
| for ResolvedFileSystemMapping { | ||
| mount_path, | ||
| volume_name, | ||
|
|
@@ -488,6 +488,12 @@ fn filesystem_v2( | |
| continue; | ||
| } | ||
|
|
||
| if mount_path.as_path() == Path::new("/") { | ||
| bail!( | ||
| "The \"{package}\" package wants to mount a volume at \"/\", but that's not allowed", | ||
| ); | ||
| } | ||
|
Comment on lines
+491
to
+495
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe a helper function for this? It is used in fs v2 and v3. Something like (not tested),
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. if only the code was that clean to begin with... it has been my experience that attempting to make clean implementations in code that's not clean by design usually leads to more complexity down the line, so when I see duplicate code, I also duplicate mine, to at least keep the code consistently unclean. |
||
|
|
||
| // Note: We want to reuse existing Volume instances if we can. That way | ||
| // we can keep the memory usage down. A webc::compat::Volume is | ||
| // reference-counted, anyway. | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd love a const about
"/",const ROOT_PATH: &str = "/";or similar. What do you think?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd happily approve of someone else doing that XD
/is well-known enough to warrant not giving it a const of its own though.