返回顶部
t

token-safety-checker令牌安全检查

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.

作者: admin | 来源: ClawHub
源自
ClawHub
版本
V 2.0.0
安全检测
已通过
168
下载量
免费
免费
0
收藏
概述
安装方式
版本历史

token-safety-checker

Token 安全检查器

扫描 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 参数中的密钥值
migrate 从磁盘内部读取值 — 绝不通过 --values 参数传递 | | 试运行输出中的密钥值 | 掩码显示为 export VAR=* | | 代理上下文中的密钥值 | findings JSON 仅包含 path、env_var、length — 可安全通过 SKILL 传递 | | 日志中的密钥值 | 任何情况下均不记录密钥值 |

工作流程

1. 扫描

bash
python3 /scripts/safeclaw.py scan [--config ~/.openclaw/openclaw.json]

输出(可在代理上下文中安全使用 — 不含密钥值):
json
{
findings: [
{ path: channels.discord.token, envvar: OPENCLAWDISCORD_TOKEN, length: 72 }
],
shell: { name: zsh, profile: ~/.zshrc, source_cmd: source ~/.zshrc }
}

退出码 0 = 干净 → 报告并停止。退出码 1 = 发现结果 → 继续。退出码 2 = 未找到配置文件。

2. 向用户展示发现结果并确认

展示发现结果表格(path | env_var | length)。允许重命名环境变量。未经明确确认不得继续。

3. 试运行

bash
python3 /scripts/safeclaw.py migrate \
--findings <步骤 1 中的发现结果 JSON> \
--dry-run

向用户展示输出。脚本会从磁盘重新读取配置以确认发现结果仍然有效。继续前需确认。

4. 迁移

bash
python3 /scripts/safeclaw.py migrate \
--findings <步骤 1 中的发现结果 JSON>

脚本将:

  1. 1. 重新扫描磁盘上的配置,确认发现结果仍为明文
  2. 备份 openclaw.json → openclaw.json.bak
  3. 从磁盘内部读取密钥值(而非从 CLI 参数)
  4. 追加环境变量导出到 shell 配置文件(跳过重复项,输出中掩码显示值)
  5. 替换 openclaw.json 中的明文值为 SecretRef

5. 加载配置文件 + 重启网关

⚠️ 检查网关的管理方式:

Shell 启动(大多数本地设置):
bash
source
openclaw gateway restart

systemd: 在单元中将变量添加到 EnvironmentFile= — 加载 shell 配置文件无效。

Docker: 通过 -e 或 compose 中的 environment: 传递。

6. 验证

bash
python3 /scripts/safeclaw.py scan # 退出码 0 = 干净
openclaw gateway status

7. 回滚

bash
python3 /scripts/safeclaw.py migrate --restore

SecretRef 格式

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。

标签

skill ai

通过对话安装

该技能支持在以下平台通过对话安装:

OpenClaw WorkBuddy QClaw Kimi Claude

方式一:安装 SkillHub 和技能

帮我安装 SkillHub 和 token-safety-checker-1775931522 技能

方式二:设置 SkillHub 为优先技能安装源

设置 SkillHub 为我的优先技能安装源,然后帮我安装 token-safety-checker-1775931522 技能

通过命令行安装

skillhub install token-safety-checker-1775931522

下载

⬇ 下载 token-safety-checker v2.0.0(免费)

文件大小: 12.61 KB | 发布时间: 2026-4-12 11:42

v2.0.0 最新 2026-4-12 11:42
Release 2.0.0

Archiver·手机版·闲社网·闲社论坛·羊毛社区· 多链控股集团有限公司 · 苏ICP备2025199260号-1

Powered by Discuz! X5.0   © 2024-2025 闲社网·线报更新论坛·羊毛分享社区·http://xianshe.com

p2p_official_large
返回顶部