CMDCGateway.WorkingDirPolicy (cmdc_gateway v0.6.0)

Copy Markdown View Source

Gateway 侧 working_dir 安全策略。

cmdc 0.6Sandbox.Local 默认启用 virtual_mode,可以限制工具操作不 跳出 working_dir。Gateway 还需要在创建 session 前限制 working_dir 本身, 防止外部客户端把根目录、用户 home 或其它租户目录设置成 sandbox root。

默认 root 是当前应用启动目录。生产环境建议显式配置:

config :cmdc_gateway, CMDCGateway.WorkingDirPolicy,
  root: "/srv/cmdc/workspaces",
  tenant_roots: %{"tenant-a" => "/srv/cmdc/workspaces/tenant-a"}

Summary

Functions

将客户端传入的 workingDir 解析为服务端允许的绝对路径。

Types

error_info()

@type error_info() :: %{code: String.t(), message: String.t()}

Functions

resolve(requested, opts \\ [])

@spec resolve(
  term(),
  keyword()
) :: {:ok, String.t()} | {:error, error_info()}

将客户端传入的 workingDir 解析为服务端允许的绝对路径。