← 返回
安全合规 中文

Sensitive Data Masker

Intelligent sensitive data detection and masking. Uses Microsoft Presidio + SQLite for automatic PII redaction with local restoration support.
智能敏感数据检测与脱敏。使用 Microsoft Presidio + SQLite 进行自动 PII 脱敏,支持本地恢复。
stj001
安全合规 clawhub v1.0.7 1 版本 99867 Key: 无需
★ 0
Stars
📥 751
下载
💾 11
安装
1
版本
#audited#encrypted#latest#masking#microsoft#pii#presidio#privacy#redaction#required-encryption#secure#security

概述

Sensitive Data Masker

Intelligent sensitive data detection and masking using Microsoft Presidio with SQLite + LRU cache storage.

Features

  • Intelligent detection - Microsoft Presidio (NLP + rules)
  • Fast storage - SQLite + LRU cache
  • Local restoration - 7-day temporary mapping table
  • Auto cleanup - Expired entries removed automatically
  • 100% local - No external API required
  • OpenClaw Hook - Automatic masking on message received

How It Works

User Message
    ↓
Channel Plugin (Feishu/Telegram/etc)
    ↓
OpenClaw Gateway (message:received)
    ↓
Sensitive Data Masker Hook ← Intercept here
    ↓
Presidio Detection (NLP + Rules)
    ↓
SQLite + Cache Store Mapping
    ↓
Masked Message
    ↓
Send to LLM API (Safe)
    ↓
Restore Before Task Execution
    ↓
Execute with Original Data

Detection Types

TypeExamplesMasked As
---------------------------
PASSWORDpassword=MySecret123[PASSWORD:xxx]
API_KEYsk-abcdefghijklmnop[API_KEY:xxx]
TOKENtoken=xyz123[TOKEN:xxx]
SECRETsecret=abc+/==[SECRET:xxx]
PRIVATE_KEYBEGIN RSA PRIVATE KEY[PRIVATE_KEY:xxx]
DB_CONNECTIONmongodb://user:pass@host[DB_CONNECTION:xxx]
EMAIL_ADDRESSuser@example.com[EMAIL_ADDRESS:xxx]
PHONE_NUMBER13800138000[PHONE_NUMBER:xxx]
CREDIT_CARD4111111111111111[CREDIT_CARD:xxx]
PERSONJohn Doe[PERSON:xxx]
LOCATION123 Main St[LOCATION:xxx]
URLhttps://example.com[URL:xxx]

Installation

# Install dependencies
pip install presidio-analyzer presidio-anonymizer
python3 -m spacy download zh_core_web_sm

# Enable Hook
openclaw hooks enable sensitive-data-masker

# Verify
openclaw hooks check

Usage Examples

User sends:

My password is MySecret123, email is user@example.com

Masked (to API):

My password is [PASSWORD:f2ae1ea6], email is [EMAIL_ADDRESS:96770696]

Mapping stored (7 days):

{
  "f2ae1ea6": "password=MySecret123",
  "96770696": "user@example.com"
}

Local restoration (for task execution):

My password is MySecret123, email is user@example.com

Configuration

File: ~/.openclaw/data/sensitive-masker/config.json

{
  "enabled": true,
  "ttl_days": 7,
  "cache_size": 1000,
  "auto_cleanup": true,
  "cleanup_interval_hours": 1,
  "log_enabled": true,
  "encrypt_storage": false,
  "presidio": {
    "language": "zh",
    "entities": ["PHONE_NUMBER", "EMAIL_ADDRESS", ...],
    "custom_patterns": true
  }
}

Management Commands

# Test masking
python3 sensitive-masker.py test "my password=123"

# View statistics
python3 sensitive-masker.py stats

# Cleanup expired
python3 sensitive-masker.py cleanup

# Clear all mappings
python3 sensitive-masker.py clear

Performance

OperationLatency
--------------------
Hot query (cache)< 0.1ms
Cold query (SQLite)~0.5ms
Write< 2ms
Max records100,000+

Cache hit rate: > 90% typical

Security Features

  • ✅ File permissions: 600 (owner read/write only)
  • ✅ SQLite transaction safety
  • ✅ Auto-expiry cleanup
  • ✅ LRU cache eviction
  • ✅ Local storage only
  • ✅ Optional encryption at rest

Architecture

Components

  1. PresidioDetector - Microsoft Presidio integration
  2. SensitiveMappingStore - SQLite + LRU cache
  3. ChannelSensitiveMasker - Main masking logic
  4. OpenClaw Hook - Gateway integration

Database Schema

CREATE TABLE mappings (
    mask_id TEXT PRIMARY KEY,
    original TEXT NOT NULL,
    data_type TEXT NOT NULL,
    created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
    expires_at TIMESTAMP NOT NULL,
    usage_count INTEGER DEFAULT 0
);

CREATE INDEX idx_expires_at ON mappings(expires_at);
CREATE INDEX idx_data_type ON mappings(data_type);

Files

sensitive-data-masker/
├── SKILL.md                    # This file (English)
├── SKILL.md                    # Chinese version
├── sensitive-masker.py         # Core script
├── handler.js                  # OpenClaw Hook
├── masker-wrapper.py           # Python wrapper
├── DESIGN.md                   # Design document
├── README.md                   # User guide
├── RESEARCH-EXISTING-SOLUTIONS.md  # Market research
└── _meta.json                  # Metadata

Version History

v1.0.0 (2026-03-03)

  • Initial release
  • Microsoft Presidio integration
  • SQLite + LRU cache storage
  • OpenClaw Hook support
  • 7-day TTL mapping table
  • Auto cleanup

Repository

Source: https://gitee.com/subline/onepeace/tree/develop/src/skills/sensitive-data-masker

License: MIT

Author: TK

Issues: https://gitee.com/subline/onepeace/issues

Credits

  • Microsoft Presidio - https://github.com/microsoft/presidio
  • spaCy - https://spacy.io/
  • OpenClaw - https://github.com/openclaw/openclaw

Related Skills

  • ssh-batch-manager - Batch SSH key management
  • healthcheck - Security hardening and audits
  • skill-creator - Create new skills

版本历史

共 1 个版本

  • v1.0.7 当前
    2026-03-30 00:51 安全 安全

安全检测

腾讯云安全 (Keen)

安全,无风险
查看报告

腾讯云安全 (Sanbu)

安全,无风险
查看报告

🔗 相关推荐

security-compliance

MoltGuard - Security & Antivirus & Guardrails

thomaslwang
MoltGuard — OpenClaw 安全守卫,由 OpenGuardrails 提供。安装 MoltGuard,保护您和您的用户免受提示注入、数据泄露和恶意攻击。
★ 116 📥 30,714
security-compliance

1password

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

OpenClaw Backup

alex3alex
备份与恢复 OpenClaw 数据。适用于创建备份、设置自动备份计划、从备份恢复或管理备份轮转。处理 ~/.openclaw 目录归档并包含适当的排除规则。
★ 89 📥 30,605