返回顶部
o

openclaw-security 多区域PII检测

Multi-region async PII detection for OpenClaw sessions. Scans user input, prompts, context, and knowledge base content for sensitive personal data across CN, US, AU, UK, DE, FR, SG, MY, TH, ID regions. Detects phone numbers, emails, names, addresses, passports, bank cards, national IDs, social accounts. Use when: (1) user asks to audit or scan for PII / sensitive data, (2) 'security scan', (3) 'check for personal information', (4) 'PII detection', (5) background audit on session content, (6) 'se

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

openclaw-security

技能名称: openclaw-security

OpenClaw Security - PII 审计技能

面向 OpenClaw 会话的多区域异步 PII 检测引擎。可检测 10 个国家/地区司法管辖区内的 8 类敏感个人数据,并以 NDJSON 格式在本地记录审计事件。

中文速览(PII 审计)

基本信息

  • - 技能名称:openclaw-security
  • 能力:多区域异步 PII 检测,支持后台审计与本地合规留痕

检测范围

  • - 8 类标签:PHONE / EMAIL / PERSONNAME / ADDRESS / PASSPORT / BANKCARD / NATIONALID / SOCIALACCOUNT
  • 10 区域:CN / US / AU / SG / MY / TH / ID / DE / UK / FR(支持 +CC 国际手机号)
  • 来源类型:input / prompt / context / knowledge_base

关键规则

  • - 风险分级:high(证件/银行卡或组合信息),low(单一弱标识)
  • 智能采样:input 100%(5分钟),prompt 20%(24小时),context 20%(1小时),knowledge_base 100%(24小时)
  • 调用方无需自行判断是否跳过扫描;如需强制扫描,使用 --no-cache
  • 后台扫描禁止使用 --text,请使用 --file + --delete-after-read
  • 输入上限 32,768 字符,超限截断并记录 truncated: true
  • 审计结果本地 NDJSON 落盘,默认保留 7 天,可 cleanup.py --dry-run 先演练

快速开始

通过文件扫描(推荐用于后台/自动化扫描):
powershell
python scripts/auditworker.py --session-id SESSION001 --source-type input --file content.txt

通过文件扫描 + 自动删除(安全的临时文件工作流):
powershell
python scripts/auditworker.py --session-id SESSION001 --source-type input --file tmp_scan.txt --delete-after-read

通过标准输入扫描:
powershell
echo 张三的手机号是13812345678 | python scripts/auditworker.py --session-id SESSION001 --source-type input

快速手动测试(警告:内容在进程列表中可见):
powershell
python scripts/audit_worker.py --session-id S001 --source-type input --text short test --json

来源类型

  • - input — 用户输入文本
  • prompt — 系统或用户提示
  • context — 对话上下文
  • knowledge_base — 知识库内容

检测标签

PHONE, EMAIL, PERSONNAME, ADDRESS, PASSPORT, BANKCARD, NATIONALID, SOCIALACCOUNT

支持的区域

CN, US, AU, SG, MY, TH, ID, DE, UK, FR (+ 通过 +CC 手机前缀的国际号码)

风险等级

  • - high: 检测到 NATIONALID / PASSPORT / BANKCARD,或 PERSONNAME + 联系信息 + ADDRESS 的组合
  • low: 单一弱标识符(单独的 EMAIL, SOCIALACCOUNT, PHONE)

智能采样

审计工作器包含内置的智能采样功能,以高效处理大型上下文:

  • - 用户输入 (input): 100% 扫描率,5分钟缓存 TTL — 每条用户消息都会被扫描,但 5 分钟内的相同重复内容会被跳过。
  • 系统提示 (prompt): 20% 扫描率,24小时缓存 TTL — 提示很少更改;首次扫描会缓存 24 小时。
  • 对话上下文 (context): 20% 扫描率,1小时缓存 TTL — 上下文高度重叠;仅采样每 5 次提交中的 1 次。
  • 知识库 (knowledge_base): 100% 首次扫描率,24小时缓存 TTL — 静态内容会被完整扫描一次,然后在 24 小时内去重。

手动/强制扫描时绕过采样:
powershell
python scripts/audit_worker.py --session-id S001 --source-type context --text text --no-cache

异步审计工作流

当作为后台任务审计会话内容时:

  1. 1. 先响应用户 — 切勿因审计而阻塞主响应。
  2. 提供所有内容类型 — 脚本会根据采样配置和缓存内部决定是否实际扫描。Agent 无需决定何时跳过。
  3. 使用临时文件 + --delete-after-read — 在后台扫描中切勿通过 --text 传递内容。将内容写入临时文件,传递 --file,让脚本自动删除它。
  4. 在后台运行审计:
powershell

步骤 1:将内容写入临时文件(命令行参数中无 PII)

$tmpFile = [System.IO.Path]::GetTempFileName() [System.IO.File]::WriteAllText($tmpFile, $userInput, [System.Text.Encoding]::UTF8)

步骤 2:后台扫描 — 脚本读取并删除临时文件

Start-Process -NoNewWindow -FilePath python -ArgumentList scripts/audit_worker.py --session-id $sid --source-type input --file $tmpFile --delete-after-read

其他来源类型的相同模式:

$tmpPrompt = [System.IO.Path]::GetTempFileName() [System.IO.File]::WriteAllText($tmpPrompt, $systemPrompt, [System.Text.Encoding]::UTF8) Start-Process -NoNewWindow -FilePath python -ArgumentList scripts/audit_worker.py --session-id $sid --source-type prompt --file $tmpPrompt --delete-after-read
  1. 5. 查看结果:openclaw-security-audit/YYYY-MM-DD/events.ndjson
  2. 所有结果(检测到、干净、跳过)都会被记录,以形成完整的审计追踪。

保留策略

默认:7 天。清理:
powershell
python scripts/cleanup.py --days 7

先进行演练:
powershell
python scripts/cleanup.py --days 7 --dry-run

输入大小限制

最大输入:32,768 字符(32K)。超过此限制的内容将被截断为前 32K 字符。审计记录会携带 truncated: true 和原始 input_chars 计数。

审计记录模式

每次扫描调用都会写入一条 NDJSON 记录 — 包括 clean 和 skipped 结果。

每条 NDJSON 行包含:

  • - eventid — UUID
  • sessionid — 调用方提供的会话 ID(必需)
  • sourcetype — 其中之一:input, prompt, context, knowledgebase
  • status — detected, clean, 或 skipped
  • labels — 检测到的 PII 类型数组(仅检测到时)
  • regions — 匹配的区域/国家代码数组(仅检测到时)
  • risklevel — high 或 low(仅检测到时)
  • matchedcount — PII 匹配数量
  • matches — {label, confidence, maskedpreview, region} 数组(仅检测到时)
  • contenthash — 用于去重的 SHA256 前缀(不存储原始内容)
  • inputchars — 原始输入的字符数
  • truncated — 输入是否被截断为 32K
  • createdat — ISO 8601 UTC 时间戳

安全规则

  • - 切勿存储原始敏感值 — 仅存储掩码预览 + 内容哈希
  • 在后台扫描中切勿通过 --text 传递内容 — 使用 --file + --delete-after-read
  • 审计日志仅限本地,绝不对外传输
  • 所有文件 I/O 明确使用 UTF-8 编码,并采用文件锁定以确保并发安全
  • 无外部依赖 — 仅使用标准库
  • 输入上限为 32K 字符,以防止资源耗尽

配置

审计输出目录的环境变量覆盖:
powershell
$env:OPENCLAWAUDITDIR = C:\path\to\custom\audit\dir

检测模式详情请参见 references/patterns.md。

标签

skill ai

通过对话安装

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

OpenClaw WorkBuddy QClaw Kimi Claude

方式一:安装 SkillHub 和技能

帮我安装 SkillHub 和 openclaw-security-pii-audit-1776032136 技能

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

设置 SkillHub 为我的优先技能安装源,然后帮我安装 openclaw-security-pii-audit-1776032136 技能

通过命令行安装

skillhub install openclaw-security-pii-audit-1776032136

下载

⬇ 下载 openclaw-security v1.0.0(免费)

文件大小: 42.25 KB | 发布时间: 2026-4-13 11:20

v1.0.0 最新 2026-4-13 11:20
Initial release: Multi-region async PII detection engine. 8 PII categories, 10 regions, smart sampling, zero dependencies.

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

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

p2p_official_large
返回顶部