diff --git a/rust/execution/counterfactual.rs b/rust/execution/counterfactual.rs index e69d566..12cee2f 100644 --- a/rust/execution/counterfactual.rs +++ b/rust/execution/counterfactual.rs @@ -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; diff --git a/rust/execution/scratch.rs b/rust/execution/scratch.rs index 7e5ac22..1ce7b5d 100644 --- a/rust/execution/scratch.rs +++ b/rust/execution/scratch.rs @@ -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", diff --git a/rust/execution/tools.rs b/rust/execution/tools.rs index df6cba2..f29b724 100644 --- a/rust/execution/tools.rs +++ b/rust/execution/tools.rs @@ -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::>(); - 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::>(); + 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) { diff --git a/rust/start.rs b/rust/start.rs index aefe75f..c13db97 100644 --- a/rust/start.rs +++ b/rust/start.rs @@ -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", ));