Agentic.Workspace.PathValidator
(agentic v0.2.2)
Copy Markdown
Validates workspace paths are within the allowed base directory.
All workspace directories must be direct children of the configured
:workspace_base_dir. This prevents path traversal attacks and ensures
workspaces cannot write to arbitrary filesystem locations.
Summary
Functions
Returns the expanded base directory for all workspaces.
Generates a safe workspace path from a slug.
Validates that a workspace path is safe and within the base directory.
Functions
Returns the expanded base directory for all workspaces.
Generates a safe workspace path from a slug.
The slug must match ^[a-z0-9][a-z0-9-]*$. Returns {:ok, path} or
{:error, reason}.
Validates that a workspace path is safe and within the base directory.
Rules:
- Expanded path must be a direct child of base_dir
- Must not escape via
..traversal (checked after expansion) - Must not be the base_dir itself
- Directory name must match
^[a-z0-9][a-z0-9-]*$
Returns {:ok, expanded_path} or {:error, reason}.