feat(security): 添加输入输出安全过滤模块 - #111
Open
zjm11902 wants to merge 1 commit into
Open
Conversation
- 新增安全过滤器接口 SafetyFilter 和规则接口 SafetyRule - 实现基于责任链的 DefaultSafetyFilter(PASS/BLOCK/WARN 三态) - 4 条默认规则:输入长度/敏感词/Prompt注入检测/正则模式匹配 - 输出安全:流式脱敏(手机号/身份证/邮箱/API Key)+ Prompt泄露检测 - MCP 工具权限控制(@McpToolPermission 注解 + McpPermissionEnforcer) - SLF4J 审计日志(SAFETY_AUDIT marker) - 通过 rag.security.* 配置开关,默认启用 - 关闭后对现有行为零影响
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
概述
为 Ragent 添加完整的输入输出安全过滤模块,填补当前版本在安全防护方面的空白。
改动内容
SafetyFilter/SafetyRule接口,基于责任链模式DefaultSafetyFilter:Spring 自动发现所有SafetyRuleBean,按 @order 排序执行@McpToolPermission注解 +McpPermissionEnforcerSAFETY_AUDITmarker),方便对接 ELK/Splunkrag.security.*配置总开关,默认启用rag.security.enabled=false)对现有行为零影响设计理念
@Component+@Order,无需手动注册