← 返回
未分类 中文

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 "...
扫描 openclaw.json 中的明文密钥(令牌、API 密钥、密码),并使用 SecretRef 将其迁移到环境变量。在用户请求时使用。
maoisdamao maoisdamao 来源
未分类 clawhub v2.0.0 1 版本 100000 Key: 无需
★ 0
Stars
📥 463
下载
💾 0
安装
1
版本
#latest

概述

Token Safety Checker

Scan openclaw.json for plaintext secrets and migrate them to environment variables via SecretRef.

All operations run locally. Secret values are never passed as CLI arguments, never logged, and never appear in agent context.

Script

Single entry point: scripts/safeclaw.py

python3 safeclaw.py scan    [--config PATH]
python3 safeclaw.py migrate [--findings JSON] [--config PATH] [--profile PATH] [--dry-run] [--restore]

How secrets are protected

RiskMitigation
-----------------
Secret values in scan outputscan returns paths + lengths only — never values
Secret values in CLI argsmigrate reads values from disk internally — never via --values arg
Secret values in dry-run outputMasked as export VAR="*"
Secret values in agent contextfindings JSON only contains path, env_var, length — safe to pass through SKILL
Secret values in logsNo logging of values at any point

Workflow

1. Scan

python3 <skill_dir>/scripts/safeclaw.py scan [--config ~/.openclaw/openclaw.json]

Output (safe to use in agent context — no secret values):

{
  "findings": [
    { "path": "channels.discord.token", "env_var": "OPENCLAW_DISCORD_TOKEN", "length": 72 }
  ],
  "shell": { "name": "zsh", "profile": "~/.zshrc", "source_cmd": "source ~/.zshrc" }
}

Exit 0 = clean → report and stop. Exit 1 = findings → continue. Exit 2 = config not found.

2. Show findings to user and confirm

Present the findings table (path | env_var | length). Allow renaming env vars. Do not proceed without explicit confirmation.

3. Dry-run

python3 <skill_dir>/scripts/safeclaw.py migrate \
  --findings '<findings JSON from step 1>' \
  --dry-run

Show output to user. The script re-reads config from disk to verify findings are still current. Confirm before proceeding.

4. Migrate

python3 <skill_dir>/scripts/safeclaw.py migrate \
  --findings '<findings JSON from step 1>'

The script:

  1. Re-scans config from disk to confirm findings are still plaintext
  2. Backs up openclaw.jsonopenclaw.json.bak
  3. Reads secret values internally from disk (not from CLI args)
  4. Appends env exports to shell profile (skips duplicates, masks values in output)
  5. Replaces plaintext values with SecretRef in openclaw.json

5. Source profile + restart gateway

⚠️ Check how the gateway is managed:

Shell-launched (most local setups):

source <profile>
openclaw gateway restart

systemd: Add vars to EnvironmentFile= in the unit — sourcing a shell profile won't work.

Docker: Pass via -e or environment: in compose.

6. Verify

python3 <skill_dir>/scripts/safeclaw.py scan   # exit 0 = clean
openclaw gateway status

7. Rollback

python3 <skill_dir>/scripts/safeclaw.py migrate --restore

SecretRef format

{ "source": "env",  "provider": "default", "id": "MY_ENV_VAR" }
{ "source": "file", "provider": "default", "id": "/path/to/secret.txt" }
{ "source": "exec", "provider": "default", "id": "command --prints --secret" }

env is recommended for most setups. For higher-security environments, prefer file or exec.

版本历史

共 1 个版本

  • v2.0.0 当前
    2026-05-03 06:39 安全 安全

安全检测

腾讯云安全 (Keen)

安全,无风险
查看报告

腾讯云安全 (Sanbu)

安全,无风险
查看报告

🔗 相关推荐

it-ops-security

Free Ride - Unlimited free AI

shaivpidadi
管理OpenClaw的OpenRouter免费AI模型,自动按质量排名模型,配置速率限制备用方案,并更新opencla...
★ 470 📥 78,089
it-ops-security

MoltGuard - Security & Antivirus & Guardrails

thomas-security
MoltGuard — OpenClaw 安全守卫,由 OpenGuardrails 提供。安装后可防止您和您的用户受到提示注入、数据泄露及恶意行为的侵害。
★ 116 📥 30,948
it-ops-security

1password

steipete
设置和使用 1Password CLI (op)。适用于:安装 CLI、启用桌面应用集成、登录(单/多账户)、通过 op 读取/注入/运行密钥。
★ 53 📥 31,648