domestique-labs/domestique-oss
GitHub: domestique-labs/domestique-oss
一款面向开发者的本地 AI 防火墙,在提示词发送到 LLM 之前自动脱敏其中的机密信息和 PII,无需系统代理或管理员权限即可接入。
Stars: 2 | Forks: 0
专为开发者打造的本地 AI 防火墙。
将你的 agent 或应用指向 Domestique,它会在你的提示词到达 OpenAI、Anthropic 或任何 LLM 之前,自动脱敏其中的机密信息和 PII。
无需安装 CA,无需系统代理,无需管理员权限——只需将工具指向本地 endpoint。跨平台支持。
**目录** · [快速开始](#quick-start) · [工作原理](#how-it-works) · [浏览器模式与企业版](#browser-mode-optional--enterprise) · [许可证](#license)
[](https://github.com/domestique-labs/domestique-oss/actions/workflows/ci.yml)
[](./LICENSE)
[](https://www.python.org/downloads/)
[](https://github.com/astral-sh/ruff)
[](https://github.com/domestique-labs/domestique-oss/stargazers)
System Proxy (PAC) --> Domestique (mitmproxy) --> LLM API
Routes only LLM Inspect + Decide OpenAI,
domains through (<5ms p99 regex) Claude, etc.
the firewall
```
1. PAC 文件将 LLM 域名(chatgpt.com、api.openai.com 等)路由到本地代理。
2. mitmproxy 使用本地受信任的 CA 证书终止 TLS。
3. 防火墙并行扫描请求内容(正则表达式 + GLiNER + LLM 分类器)。
4. 合规请求立即转发;违规请求将被拦截或脱敏。
CA 证书会在首次启动时自动生成并授予信任。浏览器模式属于可选功能,需要安装 `[browser-proxy]` 扩展。
如果证书门槛未能自动通过(在 Windows 和 Linux 上的全新安装中,系统证书库的信任需要手动操作),请在项目根目录下运行适用于你操作系统的辅助工具:
```
./infra/certs/fix-cert.sh # Linux — generates + trusts the CA (uses sudo)
.\infra\certs\fix-cert.ps1 # Windows — generates + trusts the CA (click Yes on the prompt)
```
#### 禁用 QUIC (HTTP/3) 以防流量绕过代理
Chromium 浏览器倾向于使用 **QUIC**,该协议运行在 UDP/443 之上,会完全绕过 TCP 代理——这是一个隐蔽的 DLP 盲区。为了获得可靠的浏览器模式测试或部署体验,请关闭 QUIC。我们为 Chromium 浏览器提供了一个辅助工具:
```
# Chrome / Brave / Edge — 写入标准的 QuicAllowed enterprise policy
# (与 MDM 进行全局拉取的 lever 相同)。通过 UAC 自动提权。-Enable 以恢复。
scripts/toggle-quic.ps1 -Browser chrome # or: brave | edge
```
对于 **Opera** 和 **Firefox**,脚本会打印出正确的手动操作步骤(它们使用的是不同的机制)。企业版会通过浏览器策略以及在防火墙处拦截出站的 UDP/443 流量,在整个设备集群中自动强制执行此操作。
### 检测预设(Tier 3 LLM 分类器)
| 预设 | 技术栈 | VRAM | 延迟 | F1 | 备注 |
|---|---|---|---|---|---|
| `minimal` | 仅 Regex | 0 | <1ms | 14% | 模式匹配,不使用 LLM |
| `balanced` | Regex + Qwen3 1.7B | 1.8 GB | ~164ms | 92% | 推荐 - 适用于 16GB 内存的笔记本电脑 |
| `maximum` | Regex + GLiNER + Qwen3 | 1.8 GB | ~209ms | 91% 召回率 | 召回率最高,误报较多 |
### 项目布局
```
domestique/
cli.py # CLI entry point: `domestique start` / `domestique demo`
gateway.py # Transparent redacting reverse proxy (the CLI wedge)
extract.py # Provider-aware prompt-text extraction (OpenAI + Anthropic)
redact.py # Dot-path body redaction helpers
detectors/ # Pluggable detection modules
secrets.py # Regex patterns (API keys, SSNs, emails)
pii.py # Presidio PII detector
registry.py # Detector registry + pipeline
local_llm.py # Ollama LLM classifier (Gemma / Qwen3)
policy/
rules.yaml # Default (enterprise) block-first rules
wedge_rules.yaml # CLI-wedge redact-first policy
config.py # Settings model (env-driven)
app/ # Browser mode + native desktop app + dashboard
```
## 许可证
**[Apache License 2.0](./LICENSE)** —— 开源。你可以使用它、修改它、发布它并回馈社区。详见 [`NOTICE`](./NOTICE)。
这是**社区版**:完整且免费开源的单设备 LLM 防火墙。商业版 Domestique 产品——包括集群管理、不可绕过的 MDM 强制执行、合规自动化、分析及技术支持——是独立的专有商业产品。“Domestique”是 Domestique Labs 的商标;本许可证仅针对代码,不涵盖名称。
标签:AI安全, AI风险缓解, Chat Copilot, DLL 劫持, Python, 大语言模型, 数据脱敏, 无后门, 本地代理, 网络安全, 逆向工具, 隐私保护