MAYA-DATA-PRIVACY/Veil

GitHub: MAYA-DATA-PRIVACY/Veil

一款浏览器扩展,在使用 AI 聊天服务时实时检测并脱敏个人身份信息,所有分析完全在本地完成。

Stars: 2 | Forks: 1


Veil

**面向 AI 聊天界面的实时 PII 检测与脱敏。**
您的数据永远不会离开您的设备。绝不。
[![CI](https://static.pigsec.cn/wp-content/uploads/repos/2026/04/679a20c0a4212144.svg)](https://github.com/Maya-Data-Privacy/Veil/actions/workflows/ci.yml) [![License: MIT](https://img.shields.io/badge/License-MIT-yellow?style=flat-square)](LICENSE) [![Chrome Extension](https://img.shields.io/badge/Chrome-Extension-4285F4?style=flat-square&logo=googlechrome&logoColor=white)](https://chrome.google.com/webstore) [![Powered by GLiNER2](https://img.shields.io/badge/Powered%20by-GLiNER2-8B5CF6?style=flat-square)](https://github.com/fastino-ai/GLiNER2) [![Release](https://img.shields.io/github/v/release/Maya-Data-Privacy/Veil?style=flat-square&color=22C55E)](https://github.com/Maya-Data-Privacy/Veil/releases) [![PRs Welcome](https://img.shields.io/badge/PRs-welcome-orange?style=flat-square)](docs/CONTRIBUTING.md) [![Stars](https://img.shields.io/github/stars/Maya-Data-Privacy/Veil?style=flat-square&color=yellow)](https://github.com/Maya-Data-Privacy/Veil/stargazers)
[网站](https://maya-data-privacy.github.io/Veil/) · [安装指南](https://maya-data-privacy.github.io/Veil/install) · [更新日志](CHANGELOG.md) · [报告 Bug](https://github.com/Maya-Data-Privacy/Veil/issues/new?template=bug_report.md) · [请求新功能](https://github.com/Maya-Data-Privacy/Veil/issues/new?template=feature_request.md)

## 问题所在 每次您在 ChatGPT、Claude、Gemini 或任何其他 AI 助手中输入姓名、电子邮件、电话号码或信用卡时,这些数据都会离开您的浏览器并存储在别人的服务器上。它会被记录下来。它可能会被用于训练。您无法将其撤回。 大多数人甚至直到为时已晚才会想到这一点。 ## Veil 能做什么 Veil 位于您和 AI 之间。它监视您输入的内容,实时识别敏感信息,并让您有机会在发送之前对其进行遮盖。姓名变成 `[PERSON]`。电子邮件变成 `[EMAIL REDACTED]`。信用卡号码永远不会离开您的键盘。 检测完全在您自己的机器上使用名为 [GLiNER2](https://github.com/fastino-ai/GLiNER2) 的本地 NLP 模型运行。没有任何内容上传到云端进行分析。没有任何内容被存储。没有任何内容被共享。
``` You type: "Hey, my name is John Smith and my SSN is 123-45-6789" | Veil intercepts | AI receives: "Hey, my name is [PERSON] and my SSN is [SSN REDACTED]" ```

## 核心功能 - **完全本地化检测** - GLiNER2 ONNX 模型在 localhost 上运行。零云端调用,零数据外泄,初始设置后可离线工作。 - **行内高亮** - Grammarly 风格的下划线准确显示 Veil 发现的内容。单击即可脱敏,单击即可忽略。 - **全平台兼容** - 适用于 ChatGPT、Claude、Gemini、Perplexity、Notion 以及任何其他具有文本输入或 contentEditable 字段的网站。 - **正则表达式后备** - 内置模式可捕获 API 密钥、JWT、AWS 凭证、SSN 等。即使没有本地模型也能即时工作。 - **自定义模式** - 为内部 ID、项目代码或任何特定于您工作流程的内容添加您自己的正则表达式规则。 - **可调节灵敏度** - 低、中或高检测阈值,取决于您希望扫描的激进程度。 - **一键安装** - 单个 curl/PowerShell 命令即可设置本地服务器、下载模型、注册自启动,一切就绪。 - **跨平台** - Linux (systemd)、macOS (launchd) 和 Windows (Task Scheduler) 开箱即支持自启动。 ## 检测内容 **通过 GLiNER2 模型:** 人名、电子邮件地址、电话号码、物理地址、社会安全号码、信用卡号码、出生日期、地点和组织。 **通过正则表达式模式:** OpenAI/AWS/GitHub/Stripe/Twilio API 密钥、JWT、IPv4/IPv6 地址、MAC 地址、印度 PAN/Aadhaar/IFSC 号码、护照号码、连接字符串、私钥以及您定义的任何自定义模式。 ## 开始使用 ### 1. 安装扩展 从 [Releases](https://github.com/Maya-Data-Privacy/Veil/releases) 下载最新的 `veil-extension-*.zip`,解压后: 1. 打开 Chrome 并访问 `chrome://extensions` 2. 打开右上角的 **开发者模式** (Developer mode) 3. 点击 **加载已解压的扩展程序** (Load unpacked) 并选择解压后的文件夹 4. 记下卡片上显示的 **扩展 ID** - 接下来您会用到它 ### 2. 安装本地服务器 该服务器使用 GLiNER2 模型处理 PII 检测。一个命令即可完成所有操作:下载服务器、设置 Python runtime、下载模型、注册自启动并启动服务器。 **Linux / macOS:** ``` curl -fsSL https://github.com/Maya-Data-Privacy/Veil/releases/latest/download/install.sh \ | bash -s -- --extension-id YOUR_EXTENSION_ID ``` **Windows** (以管理员身份运行 PowerShell): ``` $env:VEIL_EXTENSION_ID='YOUR_EXTENSION_ID' irm https://github.com/Maya-Data-Privacy/Veil/releases/latest/download/install.ps1 | iex ``` 就是这样。服务器会立即启动,并会在每次登录时自动启动。打开任何 AI 聊天机器人并开始输入 - Veil 正在监视。 ### 3. 验证是否工作 点击浏览器工具栏中的 Veil 图标。您应该会看到: - 一个绿色的状态点,指示本地服务器已在线 - 状态区域显示 "Local GLiNER2 is online" 在任何 AI 聊天中输入类似 "My name is John Smith and my email is john@example.com" 的内容。Veil 应该在一两秒内高亮显示姓名和电子邮件。 ## 底层工作原理 ``` Browser Tab (chatgpt.com, claude.ai, etc.) | v content.js ---- monitors input fields ----> background.js (service worker) | | | highlights + redaction UI v |<----------------------------- GLiNER2 ONNX server (127.0.0.1:8765) | via native_host.py (Chrome native messaging) v User sees inline highlights. One-click redaction replaces PII before submission. ``` 1. **content.js** 监视页面上每个文本输入和 contentEditable 字段。当您输入时,它会防抖处理并将文本发送到后台 service worker。 2. **background.js** 通过 `localhost:8765` 将文本转发到本地 GLiNER2 服务器(通过 Chrome 的 native messaging 桥接以确保可靠性)。 3. **GLiNER2 服务器** 运行 ONNX 模型,查找实体,并返回带有位置和置信度分数的检测结果。 4. **content.js** 在检测到的文本范围上渲染行内高亮。您可以单击消除误报或接受脱敏。 所有这些都发生在本地。扩展的 manifest 包含严格的 Content Security Policy (`script-src 'self'; object-src 'none'`),并且从不加载或执行远程代码。 ## 配置 ### 灵敏度级别 | 级别 | 阈值 | 使用场景 | |--------|-----------|-------------| | Low (低) | 0.75 | 检测较少,精度较高。如果您遇到误报,这很好用。 | | Medium (中) | 0.62 | 均衡。这是默认设置。 | | High (高) | 0.52 | 捕获更多,但预期会有一些干扰。在处理高度敏感数据时使用。 | ### 自定义正则表达式模式 前往扩展的设置页面,滚动到 **Advanced** (高级),并添加如下模式: ``` { "id": "internal_employee_id", "label": "employee_id", "pattern": "\\bEMP-[0-9]{6}\\b", "flags": "g", "score": 0.99, "replacement": "[EMPLOYEE ID]", "enabled": true } ``` ### 匿名化服务(可选) Veil 可以选择连接到 [Maya Data Privacy](https://mayadataprivacy.in) 匿名化 API 以进行更智能的替换 - 将 `John Smith` 转换为一致的综合别名(如 `Alex Johnson`),而不是通用的 `[PERSON]` 标签。这完全是可选的,并且需要您自己的 API 密钥。默认禁用。 ## 卸载 **Linux / macOS:** ``` curl -fsSL https://github.com/Maya-Data-Privacy/Veil/releases/latest/download/uninstall.sh | bash ``` **Windows:** ``` irm https://github.com/Maya-Data-Privacy/Veil/releases/latest/download/uninstall.ps1 | iex ``` 这将删除服务器、Python 虚拟环境、下载的模型、自启动注册和 native messaging host 配置。Chrome 扩展本身需在 `chrome://extensions` 中单独移除。 ## 开发 ### 前置条件 - Node.js 18+ - Python 3.11 (由 `uv` 自动管理) - Chrome 或任何基于 Chromium 的浏览器 ### 设置 ``` git clone https://github.com/Maya-Data-Privacy/Veil.git cd Veil npm run setup # provisions Python 3.11 + dependencies via uv npm run download-gliner2 # downloads the ONNX model (~2 GB) npm run run-gliner2 # starts the local server on port 8765 ``` 在 Chrome 中将 `extension/` 作为已解压的扩展程序加载,即可开始开发。 ### 运行测试 ``` npm run test:unit # JavaScript unit tests npm run test:unit:python # Python unit tests (pytest) npm run test:e2e # Playwright end-to-end tests (headless Chromium) npm run test:e2e:headed # same, but with a visible browser ``` ### 版本管理 版本在 `package.json` 中定义一次。编辑后,运行: ``` npm run version:sync # propagates to manifest.json + pyproject.toml npm run version:check # CI uses this to catch drift ``` ### 构建发布版 ``` npm run build:zip # extension zip for Chrome Web Store npm run build:backend-bundle # server tarball for GitHub Release npm run build:model-bundle # ONNX model tarball for GitHub Release ``` 发布由推送 `v*` 标签触发。CI pipeline 会验证所有文件中的版本一致性,运行完整的测试套件,并自动上传 release 资产。 ## 项目结构 ``` Veil/ ├── extension/ # Chrome extension (load this folder directly) │ ├── manifest.json # MV3 manifest with CSP │ ├── background.js # Service worker: detection routing, server health │ ├── content.js # In-page PII detection, highlights, redaction UI │ ├── popup.html / popup.js # Toolbar popup │ ├── options.html / options.js # Full settings page │ ├── pattern_catalog.js # Built-in + custom regex pattern engine │ └── styles.css │ ├── server/ # Local Python backend │ ├── gliner2_server.py # GLiNER2 ONNX inference server (localhost:8765) │ ├── native_host.py # Chrome native messaging bridge (stdio) │ ├── native-host/ # Platform install/uninstall for the messaging host │ └── autostart/ # Platform service registration (systemd/launchd/schtasks) │ ├── scripts/ │ ├── installers/ # User-facing install.sh, install.ps1, uninstall.* │ ├── build_backend_bundle.py # Packages server + runtime for GitHub Release │ ├── build_model_bundle.py # Packages fp16 ONNX model for GitHub Release │ ├── build_crx.sh # Zips extension/ for Chrome Web Store │ └── sync_version.py # Single-source version propagation │ ├── tests/ │ ├── e2e/ # Playwright browser tests │ ├── js/ # Node.js unit tests │ └── server/ # Python unit tests (pytest) │ ├── assets/icons/ # Logos, wordmarks, social preview ├── docs/ # Contributing, security policy, architecture └── .github/workflows/ # CI, CodeQL, release automation ``` ## 安全 ### Veil 防护的内容 防止个人数据意外泄露给 AI 服务。如果您不假思索地将 SSN 粘贴到 ChatGPT 中,Veil 会捕获它并让您有机会先对其进行脱敏。 ### Veil 不防护的内容 受损的浏览器、具有更高权限的恶意扩展、OS 级键盘记录器或网络拦截。Veil 是隐私护栏,而非安全边界。 ### 扩展权限 | 权限 | 原因 | |---|---| | `storage` | 在本地保存您的设置(灵敏度、自定义模式、启用状态) | | `activeTab` | 在弹出窗口中显示每个标签页的检测统计信息 | | `scripting` | 用于动态 iframe 的后备 content script 注入 | | `nativeMessaging` | 通过 Chrome 的 native messaging 桥接连接到本地 GLiNER2 服务器 | | `` | 监视您可能输入敏感数据的任何网站上的文本输入 | ### 报告漏洞 请勿针对安全漏洞公开 issues。有关负责任的披露说明,请参阅 [docs/SECURITY.md](docs/SECURITY.md)。 ## 路线图 - [x] GLiNER2 本地 NER 检测 - [x] 具有 20 多种内置模式的正则表达式后备引擎 - [x] 用于纯文本和 contentEditable 字段的行内脱敏 UI - [x] 自定义正则表达式模式支持 - [x] 跨平台自启动 (Linux, macOS, Windows) - [x] GitHub Release 中捆绑的 ONNX 模型(无需从 HuggingFace 下载) - [x] 单一来源版本管理 - [ ] Chrome Web Store 上架 - [ ] Firefox 支持 - [ ] 设备端 ONNX 模型(无需 Python 服务器) - [ ] 脱敏会话的审计日志 / 导出 - [ ] 团队策略模式(通过共享配置强制执行脱敏规则) ## 贡献 我们欢迎做出贡献,特别是在 PII 检测准确性、新浏览器支持、性能改进和文档方面。 有关指南,请参阅 [docs/CONTRIBUTING.md](docs/CONTRIBUTING.md),有关本地开发设置,请参阅 [docs/DEVELOPMENT.md](docs/DEVELOPMENT.md)。 **我们需要帮助的领域:** Firefox/Safari 移植、Windows 和 macOS native host 改进、ONNX 模型打包、UI 优化、演示 GIF 和文档。 ## 致谢

Fastino Labs

GLiNER2 — the local zero-shot NER model that powers PII detection

Maya Data Privacy

Anonymisation API for format-preserving entity replacement

Hugging Face

Model hosting and the transformers ecosystem
## 许可证 [MIT](LICENSE) © 2025 [Maya Data Privacy](https://mayadataprivacy.in)
标签:AI安全, Chat Copilot, ChatGPT隐私, Chrome Extension, CISA项目, CNCF毕业项目, DLP, GLiNER, MITM代理, NER, PII检测, Redis利用, 个人身份信息, 命名实体识别, 大模型隐私, 实时检测, 客户端加密, 提示词注入防护, 敏感数据过滤, 数据可视化, 数据脱敏, 数据防泄露, 本地处理, 浏览器扩展, 特征检测, 网络安全, 网络应用安全, 逆向工具, 隐私保护, 零知识证明