新增一系列安全相关功能: 1. 新增二维码生成工具,支持自定义参数导出图片/Base64/字节流 2. 新增HTML内容安全处理工具,包括标签剥离、转义、URL校验 3. 新增日志敏感信息脱敏工具,支持配置、字典、日志记录脱敏 4. 新增密钥管理运行时,支持从环境变量/文件加载密钥 5. 新增身份链接管理,支持多渠道身份绑定与解析 6. 新增SSRF防护工具,支持域名/IP校验与固定主机 7. 新增安全权限修复工具,修复文件目录权限与配置项 8. 新增外部内容安全处理,支持LLM特殊令牌剥离与注入检测 9. 新增认证限流工具,支持多维度限流与本地回环豁免 10. 新增配对管理工具,支持安全配对码生成与校验 11. 新增白名单管理工具,支持DM/群组/来源白名单校验
93 lines
2.3 KiB
Python
93 lines
2.3 KiB
Python
from yuxi.channel.security.allowlist import (
|
|
AllowlistChecker,
|
|
AllowlistCheckResult,
|
|
AllowlistHitReason,
|
|
AllowlistStore,
|
|
DmPolicyMode,
|
|
GroupPolicyMode,
|
|
InMemoryAllowlistStore,
|
|
PostgresAllowlistStore,
|
|
get_allowlist_checker,
|
|
reset_allowlist_checker,
|
|
)
|
|
from yuxi.channel.security.external_content import (
|
|
InjectionDetectionResult,
|
|
detect_injection_patterns,
|
|
generate_boundary_id,
|
|
sanitize_external_content,
|
|
strip_llm_tokens,
|
|
wrap_external_content,
|
|
)
|
|
from yuxi.channel.security.identity_link import (
|
|
IdentityLinkResolver,
|
|
IdentityLinkStore,
|
|
InMemoryIdentityLinkStore,
|
|
PostgresIdentityLinkStore,
|
|
)
|
|
from yuxi.channel.security.pairing import (
|
|
InMemoryPairingStore,
|
|
PairingManager,
|
|
PairingStore,
|
|
PostgresPairingStore,
|
|
)
|
|
from yuxi.channel.security.qr_image import (
|
|
generate_qr_base64,
|
|
generate_qr_bytes,
|
|
generate_qr_image,
|
|
)
|
|
from yuxi.channel.security.html_guard import (
|
|
escape_html,
|
|
sanitize_text_content,
|
|
sanitize_url,
|
|
strip_html_tags,
|
|
)
|
|
from yuxi.channel.security.log_sanitizer import (
|
|
sanitize_config_object,
|
|
sanitize_dict,
|
|
sanitize_for_json_dump,
|
|
sanitize_log_record,
|
|
sanitize_text,
|
|
)
|
|
from yuxi.channel.security.ssrf_guard import SsrfGuard, ssrf_guard
|
|
|
|
__all__ = [
|
|
"escape_html",
|
|
"sanitize_config_object",
|
|
"sanitize_dict",
|
|
"sanitize_for_json_dump",
|
|
"sanitize_log_record",
|
|
"sanitize_text",
|
|
"sanitize_text_content",
|
|
"sanitize_url",
|
|
"strip_html_tags",
|
|
"AllowlistChecker",
|
|
"AllowlistCheckResult",
|
|
"AllowlistHitReason",
|
|
"AllowlistStore",
|
|
"DmPolicyMode",
|
|
"GroupPolicyMode",
|
|
"IdentityLinkResolver",
|
|
"IdentityLinkStore",
|
|
"InMemoryAllowlistStore",
|
|
"InMemoryIdentityLinkStore",
|
|
"InMemoryPairingStore",
|
|
"InjectionDetectionResult",
|
|
"PairingManager",
|
|
"PairingStore",
|
|
"PostgresAllowlistStore",
|
|
"PostgresIdentityLinkStore",
|
|
"PostgresPairingStore",
|
|
"SsrfGuard",
|
|
"detect_injection_patterns",
|
|
"generate_boundary_id",
|
|
"generate_qr_base64",
|
|
"generate_qr_bytes",
|
|
"generate_qr_image",
|
|
"get_allowlist_checker",
|
|
"reset_allowlist_checker",
|
|
"sanitize_external_content",
|
|
"ssrf_guard",
|
|
"strip_llm_tokens",
|
|
"wrap_external_content",
|
|
]
|