跳转至

创建

启用插件并编写策略工件。属于 openclaw policy 参考的一部分。

快速开始

openclaw plugins enable policy

即使 policy.jsonc 缺失,插件也会保持启用,因此 doctor 可以报告缺失的工件,而不是静默跳过检查。

请手动编写 policy.jsonc;它不会从当前设置生成。每个顶层部分都是一个规则命名空间:只有在其下存在具体规则时,检查才会运行(不支持的部分或键会作为 policy/policy-jsonc-invalid 失败,而不是被静默忽略)。覆盖所有支持部分的极简示例:

jsonc validate=false { "channels": { "denyRules": [ { "id": "no-telegram", "when": { "provider": "telegram" }, "reason": "Telegram is not approved for this workspace.", }, ], }, "mcp": { "servers": { "allow": ["docs"], "deny": ["untrusted"], }, }, "models": { "providers": { "allow": ["openai", "anthropic"], "deny": ["openrouter"], }, }, "network": { "privateNetwork": { "allow": false, }, }, "routing": { "requireBindings": true, "requireConfiguredChannels": true, "probes": [ { "id": "family-dm", "route": { "channel": "imessage", "peer": { "kind": "direct", "id": "+15555550123" }, }, "expect": { "agentId": "family", "matchedBy": ["binding.peer"], }, }, ], }, "ingress": { "session": { "requireDmScope": "per-channel-peer", }, "channels": { "allowDmPolicies": ["pairing", "allowlist", "disabled"], "denyOpenGroups": true, "requireMentionInGroups": true, }, }, "gateway": { "exposure": { "allowNonLoopbackBind": false, "allowTailscaleFunnel": false, }, "auth": { "requireAuth": true, "requireExplicitRateLimit": true, }, "controlUi": { "allowInsecure": false, }, "remote": { "allow": false, }, "http": { "denyEndpoints": ["chatCompletions", "responses"], "requireUrlAllowlists": true, }, "nodes": { "denyCommands": ["system.run"], }, }, "agents": { "workspace": { "allowedAccess": ["none", "ro"], "denyTools": ["exec", "process", "write", "edit", "apply_patch"], }, }, "dataHandling": { "sensitiveLogging": { "requireRedaction": true, }, "telemetry": { "denyContentCapture": true, }, "retention": { "requireSessionMaintenance": true, }, "memory": { "denySessionTranscriptIndexing": true, }, }, "secrets": { "requireManagedProviders": true, "denySources": ["exec"], "allowInsecureProviders": false, }, "auth": { "profiles": { "requireMetadata": ["provider", "mode"], "allowModes": ["api_key", "token"], }, }, "execApprovals": { "requireFile": true, "defaults": { "allowSecurity": ["deny"] }, "agents": { "allowSecurity": ["deny", "allowlist"], "allowAutoAllowSkills": false, "allowlist": { "expected": ["deploy", "status"] }, }, }, "tools": { "requireMetadata": ["risk", "sensitivity", "owner"], "profiles": { "allow": ["messaging", "minimal"], }, "fs": { "requireWorkspaceOnly": true, }, "exec": { "allowSecurity": ["deny", "allowlist"], "requireAsk": ["always"], "allowHosts": ["sandbox"], }, "elevated": { "allow": false, }, "denyTools": ["group:runtime", "group:fs"], }, }

以下是 规则表 中不明显的一些横向注意事项:

  • 在拒绝非回环绑定的同时省略 gateway.bind,意味着你接受运行时默认值;若要严格符合,请设置 gateway.bind: "loopback"。
  • 对于只读代理,请在适用的 defaults/agent 上将沙箱 mode 设置为 all 或 non-main,并将 workspaceAccess 设置为 none 或 ro。缺失或为 off 的沙箱模式不满足只读策略。
  • agents.workspace.denyTools 接受 exec、process、write、edit、apply_patch。配置中的工具拒绝组 group:fs(文件修改)和 group:runtime(shell/进程)可满足等效态势。
  • Exec-approvals 检查仅在存在 execApprovals 规则时读取实时 SQLite 审批文档;缺失或无效的工件是不可观察的证据,而不是合成通过。
  • Secret 和 auth-profile 证据仅记录 provider/source 态势和 SecretRef 元数据,绝不记录原始值。策略不会读取或证明每个代理的凭据存储,例如 openclaw-agent.sqlite。
  • 数据处理证据是配置层面的态势(遥测捕获开关、会话维护模式、转录索引设置)加上始终启用的日志脱敏不变量。它不会检查日志、遥测导出、转录或记忆文件,无异常结果也不能证明其中不存在个人数据或机密。
  • 路由检查复用 OpenClaw 的运行时绑定解析器。路由证据仅记录检查 id、解析后的代理、匹配类型以及脱敏后的绑定元数据。它绝不记录 peer、account、guild、team 或 role 标识符。有意添加 routing 部分会改变策略和证明哈希;没有 routing 的策略保留其现有证据形状。

本页原文 Markdown:在 AtomGit 查看·内容源自开源项目 cl/openclaw