Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion rust/execution/counterfactual.rs
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,10 @@ pub async fn run(
if !(substance::is_test_file(file)? || file.ends_with(".rs"))
|| crate::planning::forbidden_read(file)
|| (file.ends_with(".rs")
&& !owner.root().join("Cargo.toml").is_file()
&& (!owner.root().join("Cargo.toml").is_file()
|| file
.split_once("/src/")
.is_some_and(|(sc, _)| owner.root().join(sc).join("Cargo.toml").is_file()))
&& !file.starts_with("tests/"))
{
continue;
Expand Down
9 changes: 9 additions & 0 deletions rust/execution/scratch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,15 @@ impl<'a> Scratch<'a> {
links.push((name.to_owned(), object.to_owned()));
continue;
}
if kind == "blob"
&& mode == "120000"
&& !policy::managed(name)
&& !crate::planning::forbidden_read(name)
&& fs::symlink_metadata(source.join(name)).is_ok_and(|m| secure::linked(&m))
{
skipped.push(name.to_owned());
continue;
}
if kind != "blob" || !["100644", "100755"].contains(&mode) {
return Err(unsupported(
"Symbolic/special entries in selected base revision",
Expand Down
52 changes: 35 additions & 17 deletions rust/execution/tools.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3612,31 +3612,49 @@ impl Boundary {
}
let is_roster_self = self.root.join("rust").join("shell.rs").is_file();
let has_root_cargo = self.root.join("Cargo.toml").is_file();
let sub_crate = if !has_root_cargo {
let workspace_sub_crate = if !is_roster_self {
requirements
.files
.iter()
.chain(self.written.iter())
.filter_map(|f| f.split('/').next())
.find(|c| self.root.join(c).join("Cargo.toml").is_file())
.map(str::to_owned)
.or_else(|| {
let Ok(rd) = fs::read_dir(&self.root) else {
return None;
};
let mut dirs = rd.flatten().map(|e| e.path()).collect::<Vec<_>>();
dirs.sort();
dirs.into_iter().find_map(|p| {
if p.is_dir() && p.join("Cargo.toml").is_file() {
p.file_name().and_then(|n| n.to_str()).map(str::to_owned)
} else {
None
}
})
.find_map(|f| {
let (prefix, _) = f.split_once("/src/")?;
self.root
.join(prefix)
.join("Cargo.toml")
.is_file()
.then(|| prefix.to_owned())
})
} else {
None
};
let sub_crate = workspace_sub_crate.or_else(|| {
if !has_root_cargo {
requirements
.files
.iter()
.chain(self.written.iter())
.filter_map(|f| f.split('/').next())
.find(|c| self.root.join(c).join("Cargo.toml").is_file())
.map(str::to_owned)
.or_else(|| {
let Ok(rd) = fs::read_dir(&self.root) else {
return None;
};
let mut dirs = rd.flatten().map(|e| e.path()).collect::<Vec<_>>();
dirs.sort();
dirs.into_iter().find_map(|p| {
if p.is_dir() && p.join("Cargo.toml").is_file() {
p.file_name().and_then(|n| n.to_str()).map(str::to_owned)
} else {
None
}
})
})
} else {
None
}
});
if is_roster_self && !environment.contains_key("CARGO_TARGET_DIR") {
let manifest_target = Path::new(env!("CARGO_MANIFEST_DIR")).join("target");
if manifest_target.is_dir() && !manifest_target.starts_with(&self.root) {
Expand Down
7 changes: 7 additions & 0 deletions rust/start.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2302,6 +2302,13 @@ async fn modules(
));
}
if parts.first() == Some(&"120000") {
if !policy::managed(path)
&& !crate::planning::forbidden_read(path)
&& std::fs::symlink_metadata(source.join(path))
.is_ok_and(|m| secure::linked(&m))
{
continue;
}
return Err(crate::execution::unsupported(
"Linked files in the selected local base",
));
Expand Down
Loading