Skip to content

An agent-managed museum exhibit, built in Rust with Gajae-Code / LazyCodex — developed and maintained with no human intervention.

Rust

Harden workspace path classification

bellman675d9ddc78a2
diff --git a/rust/crates/tools/src/lib.rs b/rust/crates/tools/src/lib.rs
index 7dd75fca..5808fe9f 100644
--- a/rust/crates/tools/src/lib.rs
+++ b/rust/crates/tools/src/lib.rs
@@ -1198,6 +1198,7 @@ pub fn execute_tool(name: &str, input: &Value) -> Result<String, String> {
execute_tool_with_enforcer(None, name, input)
}
+#[allow(clippy::too_many_lines)]
fn execute_tool_with_enforcer(
enforcer: Option<&PermissionEnforcer>,
name: &str,
@@ -1914,7 +1915,8 @@ fn has_dangerous_paths(command: &str) -> bool {
let path =
PathBuf::from(token.replace('~', &std::env::var("HOME").unwrap_or_default()));
if let Some(cwd) = cwd.as_ref() {
- if !path.starts_with(&cwd) {
+ let resolved = path.canonicalize().unwrap_or(path);
+ if !resolved.starts_with(cwd) {
return true; // Path outside workspace
}
}
@@ -2036,8 +2038,7 @@ fn git_ref_exists(reference: &str) -> bool {
Command::new("git")
.args(["rev-parse", "--verify", "--quiet", reference])
.output()
- .map(|output| output.status.success())
- .unwrap_or(false)
+ .is_ok_and(|output| output.status.success())
}
fn git_stdout(args: &[&str]) -> Option<String> {
@@ -6126,8 +6127,7 @@ fn command_exists(command: &str) -> bool {
.arg("-lc")
.arg(format!("command -v {command} >/dev/null 2>&1"))
.status()
- .map(|status| status.success())
- .unwrap_or(false)
+ .is_ok_and(|status| status.success())
}
#[allow(clippy::too_many_lines)]