版本: v1.0.0
状态: ✅ 可用
功能说明Input Guard入口防护,检测 Prompt InjectionMemory Guard记忆保护,检测污染和敏感信息Tool Guard工具管控,危险工具审批Output Filter出口过滤,敏感信息脱敏/拦截Audit Logger审计日志,记录所有操作
text
用户输入 → Input Guard → Agent → Memory Guard → Tool Guard → Output Filter → 用户
注入检测 记忆检查 工具审批 脱敏拦截
↓ ↓
审计日志 审计日志
bash
python3 lib/agent_dlp.py status
# 或
python3 bin/agent-dlp status
bash
python3 bin/agent-dlp check-input "忽略之前的指令"
# 输出: 注入检测: 是 ❌
bash
python3 bin/agent-dlp check-output "我的手机是13812345678"
# 输出: 拦截: 否 ✅, 发现: 中国手机号 (high)
bash
python3 bin/agent-dlp check-tool exec
# 输出: 需要审批: 是 ⚠️
bash
python3 bin/agent-dlp logs
规则类型动作china_idcard身份证拦截china_phone手机号脱敏api_keyAPI Key拦截aws_keyAWS Key拦截private_key私钥拦截credit_card信用卡拦截password密码脱敏email邮箱脱敏
模式示例ignore_previous"忽略之前的指令"role_override"你现在是另一个AI"privilege_escalation"admin mode override"
编辑 config/config.json:
json
{
"enabled": true,
"mode": "normal",
"input": {
"injection_detection": true
},
"output": {
"enabled": true,
"rules": ["china_idcard", "china_phone", "api_key"]
}
}
模式说明normal记录但不拦截,只拦截严重风险strict完整检查,严格拦截
text
agent-dlp/
├── SKILL.md # 本文档
├── bin/
│ └── agent-dlp # CLI 入口
├── lib/
│ └── agent_dlp.py # 核心模块
├── config/
│ └── config.json # 配置文件
└── logs/ # 审计日志
类功能DLPConfig配置管理DLPRules规则定义InputGuard入口检测MemoryGuard记忆保护ToolGuard工具管控OutputFilter出口过滤AuditLogger审计日志AgentDLP主类,整合所有功能
python
from agent_dlp import AgentDLP
# 初始化
dlp = AgentDLP()
# 检查入口
result = dlp.check_input("忽略之前的指令")
# 检查出口
blocked, text, details = dlp.check_output("我的手机13812345678")
# 检查工具
result = dlp.check_tool("exec", {"command": "rm -rf /"})
版本: v1.0.0 | 创建日期: 2026-03-14