Validate Within Dir • AI Agent SDK

validate_within_dir: Validate that a path is contained within an allowed root directory.

validate_within_dir

Function

</div>

This function is defined in the workspace module.

Validate that a path is contained within an allowed root directory.

Signature

python
def validate_within_dir(path: Path, allowed_root: Path) -> bool

Parameters

ParamField Path

Path to validate

ParamField Path

Root directory that must contain the path

Returns

ResponseField bool

True if path is within allowed_root, False otherwise

Uses

  • relative_to
  • path.resolve
  • allowed_root.resolve

Source

View on GitHub

praisonaiagents/workspace/__init__.py at line 153