karant-dev/AutoRedact
GitHub: karant-dev/AutoRedact
基于浏览器端 OCR 的隐私优先图像自动脱敏工具,本地识别并模糊处理图片中的邮箱、IP、信用卡和密钥等敏感信息。
Stars: 75 | Forks: 1
# 🛡️ AutoRedact
**安全、基于客户端并由 OCR 驱动的图像脱敏工具。**
[](https://github.com/karant-dev/AutoRedact/actions/workflows/ci.yml)
[](https://github.com/karant-dev/AutoRedact/actions/workflows/release.yml)
[](https://www.gnu.org/licenses/gpl-3.0)
[部署到 Cloudflare](https://deploy.workers.cloudflare.com/?url=https://github.com/karant-dev/AutoRedact)
所有处理 100% 在您的浏览器中进行。您的图像绝不会触及服务器。
## ✨ 功能
- **🔍 自动检测** - 查找电子邮件、IP 地址、信用卡和 API 密钥
- **🎯 精准脱敏** - 使用 OCR 单词级别的边界框进行准确脱敏
- **🔒 隐私优先** - 所有操作均通过 Tesseract.js 在本地运行
- **📦 批量处理** - 一次处理无限量的图像
- **⚡ ZIP 下载** - 一键下载所有脱敏文件
## 🚀 快速开始
```
# 选项 1:NPM(本地开发)
npm install
npm run dev
# 选项 2:Docker(最简单)
docker run -p 8080:8080 karantdev/autoredact:latest
# 选项 3:Docker Compose
docker compose up -d
```
打开 [http://localhost:5173](http://localhost:5173) 并拖放您的图像。
### 命令行界面 (CLI)
AutoRedact 现在支持使用相同强大引擎的完全离线 CLI 模式。(目前仅支持 jpg 和 png,PDF 支持即将推出)
```
# 处理单张图像
npm run cli -- input.jpg
# 禁用特定 redactors
npm run cli -- input.jpg --no-emails --no-ips
# 使用自定义规则
npm run cli -- input.jpg --block-words "Confidential" --custom-regex "Project-\d+"
```
## 🎯 脱敏内容
| 类型 | 模式 |
|------|---------|
| 📧 电子邮件 | `user@example.com` |
| 🌐 IP 地址 | `192.168.1.1` |
| 💳 信用卡 | `4242-4242-4242-4242` |
| 🔑 API 密钥 | Stripe, GitHub, AWS |
## 🛠️ 技术栈
- React + Vite + TypeScript
- Tesseract.js v6 (OCR)
- JSZip (批量导出)
- Tailwind CSS
## 📁 结构
```
src/
├── adapters/ # Interface implementations (Browser/Node)
├── components/ # UI Components
├── core/ # Pure Logic (Regex, Math, Image Proc)
├── hooks/ # Custom Hooks
├── utils/ # Helpers
├── types/ # TS Interfaces
├── cli.ts # CLI Entry Point
└── App.tsx # Main Entry
```
## 📄 许可证
GNU General Public License v3.0
## 📖 实用指南
### 🛠️ CLI 高级用法
#### 1. 批量处理目录
CLI 一次处理一个文件。使用 shell 循环处理整个文件夹:
```
# 处理 'input' 目录中的所有 JPG 并保存到 'output' 目录
mkdir -p output
for f in input/*.jpg; do
npm run cli -- "$f" -o "output/$(basename "$f")"
done
```
#### 2. 针对金融/发票的严格脱敏
为敏感文档启用严格阻止模式:
```
npm run cli -- invoice.jpg \
--block-words "Confidential,SSN,Account" \
--custom-regex "(?i)account\s*#?\s*\d+" \
--no-ips # Disable IP scanner if irrelevant to boost speed
```
#### 3. 内部文档白名单
防止对已知的内部术语或标题进行脱敏:
```
npm run cli -- internal-doc.jpg \
--allowlist "CorpCorp,192.168.1.1,ProjectX"
```
Docker API 通过 nginx 代理,并在 `/api/` 路径下的 `8080` 端口可用。默认情况下,它使用标准检测设置(电子邮件、IP、密钥、PII),但可以通过 `settings` 参数进行**完全配置**。
👉 **[查看完整 API 文档](docs/API.md)** 了解详细用法、schema 以及 Python/Node.js 示例。
#### 快速测试 (Curl)
```
curl -X POST http://localhost:8080/api/redact \
-F "image=@/path/to/doc.jpg" \
-o redacted.png
```
标签:API密钥隐藏, DLP, GPLv3, IP 地址批量处理, PII检测, Python 3.9+, Tesseract.js, 前端工具, 图像打码, 开源, 批量图像处理, 敏感信息过滤, 无需服务器, 本地OCR, 网络安全, 脱敏工具, 自动化攻击, 请求拦截, 隐私保护