Privacy Mask
Detect and mask sensitive information in images locally before they leave your machine.
Prerequisites
This skill requires the privacy-mask CLI to be pre-installed on the system.
If it is not available, inform the user that they need to install it first:
- 1. Install via pip: INLINECODE1
- Ensure Tesseract OCR is installed:
brew install tesseract (macOS) or apt install tesseract-ocr (Linux) - Verify installation: INLINECODE4
- (Optional) Install NER support: INLINECODE5
When to use
- - User sends a screenshot or image file (
.png, .jpg, .jpeg, .bmp, .tiff) that may contain private data - User mentions privacy, masking, redacting, or anonymizing
- You need to analyze an image but want to redact sensitive info first
- IF the user shares a screenshot for debugging, THEN run
privacy-mask mask <path> --dry-run first to check for PII - IF detections are found, THEN mask the image before proceeding with analysis
Usage
Mask an image:
CODEBLOCK0
Output is JSON:
CODEBLOCK1
Example workflow
- 1. User provides a screenshot: INLINECODE12
- Run detection: INLINECODE13
- IF detections found, mask the image: INLINECODE14
- The masked output is saved as INLINECODE15
- Use the masked image for further analysis
What it detects
- - IDs: Chinese ID card, passport, HK/TW ID, US SSN, UK NINO, Canadian SIN, Indian Aadhaar/PAN, Korean RRN, Singapore NRIC, Malaysian IC
- Phone: Chinese mobile/landline, US phone, international (+prefix)
- Financial: Bank card, Amex, IBAN, SWIFT/BIC
- Developer keys: AWS, GitHub, Slack, Google, Stripe tokens, JWT, connection strings, API keys, SSH/PEM keys
- Crypto: Bitcoin, Ethereum wallet addresses
- Other: Email, birthday, IP/IPv6, MAC, UUID, license plate, MRZ, URL auth tokens
- NER (optional): Person names, street addresses, organizations, dates of birth, medical conditions
Constraints
- - Do NOT send unmasked images to any external API or cloud service
- Do NOT skip masking when detections are found — always mask before sharing
- Do NOT modify the original image unless
--in-place is explicitly requested - Avoid running on very large images (>10MB) without warning the user about processing time
Anti-patterns
- - Don't assume images are safe — always run detection even if the image "looks clean"
- Don't use
--in-place by default — preserve the original unless the user asks otherwise - Don't ignore dry-run results — if
--dry-run finds PII, the image must be masked before use - Don't hardcode config paths — use the bundled default or let the user specify INLINECODE19
Important
- - All processing is local and offline — no data leaves the machine
- Configure rules in the bundled
config.json or pass --config for custom rules
隐私遮罩
在图像离开您的机器之前,在本地检测并遮蔽其中的敏感信息。
前置条件
此技能要求系统中预先安装 privacy-mask 命令行工具。
如果该工具不可用,请告知用户需要先进行安装:
- 1. 通过 pip 安装:pip install privacy-mask
- 确保已安装 Tesseract OCR:brew install tesseract(macOS)或 apt install tesseract-ocr(Linux)
- 验证安装:privacy-mask --version
- (可选)安装 NER 支持:pip install privacy-mask[ner]
使用场景
- - 用户发送可能包含隐私数据的截图或图像文件(.png、.jpg、.jpeg、.bmp、.tiff)
- 用户提及隐私、遮罩、编辑或匿名化
- 您需要分析图像,但希望先编辑敏感信息
- 如果用户分享用于调试的截图,则先运行 privacy-mask mask <路径> --dry-run 检查 PII
- 如果检测到内容,则在进行分析前先对图像进行遮罩处理
使用方法
遮罩图像:
bash
privacy-mask mask /path/to/screenshot.png
privacy-mask mask /path/to/screenshot.png --in-place
privacy-mask mask /path/to/screenshot.png --dry-run # 仅检测,不进行遮罩
privacy-mask mask /path/to/screenshot.png --detection-engine regex # 仅使用正则,跳过 NER
privacy-mask mask /path/to/screenshot.png --config /path/to/custom-config.json
输出为 JSON 格式:
json
{
status: success,
detections: [{label: PHONE_CN, text: *, bbox: [10, 20, 100, 30]}],
summary: 已遮罩 1 个区域:1 个 PHONE_CN
}
示例工作流程
- 1. 用户提供截图:~/Desktop/error-screenshot.png
- 运行检测:privacy-mask mask ~/Desktop/error-screenshot.png --dry-run
- 如果检测到内容,遮罩图像:privacy-mask mask ~/Desktop/error-screenshot.png
- 遮罩后的输出保存为 ~/Desktop/error-screenshot_masked.png
- 使用遮罩后的图像进行进一步分析
检测内容
- - 身份证件:中国身份证、护照、香港/台湾身份证、美国社保号、英国国民保险号、加拿大社会保险号、印度 Aadhaar/PAN、韩国居民登记号、新加坡 NRIC、马来西亚身份证
- 电话:中国手机/座机、美国电话、国际电话(+前缀)
- 金融:银行卡、美国运通卡、IBAN、SWIFT/BIC
- 开发者密钥:AWS、GitHub、Slack、Google、Stripe 令牌、JWT、连接字符串、API 密钥、SSH/PEM 密钥
- 加密货币:比特币、以太坊钱包地址
- 其他:电子邮件、生日、IP/IPv6、MAC 地址、UUID、车牌号、MRZ、URL 认证令牌
- NER(可选):人名、街道地址、组织名称、出生日期、医疗状况
约束条件
- - 不得将未遮罩的图像发送到任何外部 API 或云服务
- 检测到内容时不得跳过遮罩——分享前务必进行遮罩处理
- 除非明确要求使用 --in-place,否则不得修改原始图像
- 避免对超大图像(>10MB)运行,除非已警告用户处理时间
反模式
- - 不要假设图像是安全的——即使图像看起来干净,也要始终运行检测
- 默认不要使用 --in-place——除非用户另有要求,否则保留原始图像
- 不要忽略干运行结果——如果 --dry-run 发现 PII,图像在使用前必须进行遮罩处理
- 不要硬编码配置路径——使用捆绑的默认配置或让用户指定 --config
重要说明
- - 所有处理均在本地和离线进行——数据不会离开机器
- 在捆绑的 config.json 中配置规则,或通过 --config 传入自定义规则