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

Function reject_parent_traversal

atomic-agent/src/integrations/install.rs:704–712  ·  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

702
703/// Reject `src` paths that would escape the package directory.
704fn reject_parent_traversal(agent: &str, src: &str) -> AgentResult<()> {
705 if src.split('/').any(|c| c == "..") || src.starts_with('/') {
706 return Err(AgentError::Integration {
707 agent: agent.to_string(),
708 reason: format!("invalid file src '{src}': must be a relative path inside the package"),
709 });
710 }
711 Ok(())
712}
713
714#[cfg(test)]
715mod tests {

Callers 1

install_from_dirFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected