MCPcopy Create free account
hub / github.com/atomicdotdev/atomic / reject_parent_traversal

Function reject_parent_traversal

atomic-agent/src/integrations/install.rs:309–317  ·  view source on GitHub ↗

Reject `src` paths that would escape the package directory.

(agent: &str, src: &str)

Source from the content-addressed store, hash-verified

307
308/// Reject `src` paths that would escape the package directory.
309fn reject_parent_traversal(agent: &str, src: &str) -> AgentResult<()> {
310 if src.split('/').any(|c| c == "..") || src.starts_with('/') {
311 return Err(AgentError::Integration {
312 agent: agent.to_string(),
313 reason: format!("invalid file src '{src}': must be a relative path inside the package"),
314 });
315 }
316 Ok(())
317}
318
319#[cfg(test)]
320mod tests {

Callers 1

install_from_dirFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected