Scan openclaw.json for plaintext secrets (tokens, API keys, passwords) and migrate them to environment variables using SecretRef. Use when the user asks to "check token safety", "privatize secrets", "move tokens to env vars", "audit openclaw config for secrets", or after any openclaw.json edit that may have introduced plaintext credentials. Also use when setting up a new OpenClaw instance for the first time.
扫描 openclaw.json 中的明文密钥,并通过 SecretRef 将其迁移到环境变量中。
所有操作均在本地运行。密钥值不会作为 CLI 参数传递,不会被记录,也不会出现在代理上下文中。
单一入口点:scripts/safeclaw.py
python3 safeclaw.py scan [--config PATH]
python3 safeclaw.py migrate [--findings JSON] [--config PATH] [--profile PATH] [--dry-run] [--restore]
| 风险 | 缓解措施 |
|---|---|
| scan 输出中的密钥值 | scan 仅返回 路径 + 长度 — 绝不返回实际值 |
| CLI 参数中的密钥值 |
bash
python3
输出(可在代理上下文中安全使用 — 不含密钥值):
json
{
findings: [
{ path: channels.discord.token, envvar: OPENCLAWDISCORD_TOKEN, length: 72 }
],
shell: { name: zsh, profile: ~/.zshrc, source_cmd: source ~/.zshrc }
}
退出码 0 = 干净 → 报告并停止。退出码 1 = 发现结果 → 继续。退出码 2 = 未找到配置文件。
展示发现结果表格(path | env_var | length)。允许重命名环境变量。未经明确确认不得继续。
bash
python3
--findings <步骤 1 中的发现结果 JSON> \
--dry-run
向用户展示输出。脚本会从磁盘重新读取配置以确认发现结果仍然有效。继续前需确认。
bash
python3
--findings <步骤 1 中的发现结果 JSON>
脚本将:
⚠️ 检查网关的管理方式:
Shell 启动(大多数本地设置):
bash
source
openclaw gateway restart
systemd: 在单元中将变量添加到 EnvironmentFile= — 加载 shell 配置文件无效。
Docker: 通过 -e 或 compose 中的 environment: 传递。
bash
python3
openclaw gateway status
bash
python3
json
{ source: env, provider: default, id: MYENVVAR }
{ source: file, provider: default, id: /path/to/secret.txt }
{ source: exec, provider: default, id: command --prints --secret }
对于大多数设置,推荐使用 env。对于更高安全性的环境,建议使用 file 或 exec。
该技能支持在以下平台通过对话安装:
帮我安装 SkillHub 和 token-safety-checker-1775931522 技能
设置 SkillHub 为我的优先技能安装源,然后帮我安装 token-safety-checker-1775931522 技能
skillhub install token-safety-checker-1775931522
文件大小: 12.61 KB | 发布时间: 2026-4-12 11:42