feat: 审核规则持久化到DB + 全面配置去硬编码化

- AuditRule模型: 新增code/config_json字段,支持规则编码和阈值参数持久化
- audit_engine_v2: _load_rules从DB读config_json覆盖默认config
- audit_rule_sync: 启动时自动从_RULE_REGISTRY同步规则到DB(239条)
- settings API: update后刷新query_service配置缓存
- query_service: MAX_ROWS/QUERY_TIMEOUT/MAX_QUERY_LENGTH/MAX_RESULT_MEMORY改为动态读取system_settings
- ticket_executor: SQL_TIMEOUT/REDIS_TIMEOUT/MONGO_TIMEOUT改为动态获取
- settings_seeds: 新增executor分组(sql/redis/mongo超时) + query_result_max_memory_mb
- audit_rule endpoint: 移除无效的AuditEngine缓存清理(每次audit是新实例)
- 测试: 1057 passed(修复所有新引入失败,17个历史遗留)
This commit is contained in:
logan committed 2026-05-25 02:29:52 +08:00
1 parent ddf4856a85
commit a9e214ef1a
11 files changed
+342 -62

No files matched your search

+43
View File
@@ -188,6 +188,48 @@ SEED_SETTINGS = [
"default_value": "30",
"sort_order": 35,
},
# ── 执行器 ──
{
"key": "executor_sql_timeout",
"value": "60",
"value_type": "integer",
"group": "executor",
"label": "SQL 执行超时(秒)",
"description": "MySQL/PostgreSQL 工单执行单条 SQL 最大时间。范围: 10~600",
"default_value": "60",
"sort_order": 40,
},
{
"key": "executor_redis_timeout",
"value": "30",
"value_type": "integer",
"group": "executor",
"label": "Redis 执行超时(秒)",
"description": "Redis 工单执行单条命令最大时间。范围: 5~120",
"default_value": "30",
"sort_order": 41,
},
{
"key": "executor_mongo_timeout",
"value": "60",
"value_type": "integer",
"group": "executor",
"label": "MongoDB 执行超时(秒)",
"description": "MongoDB 工单执行单条命令最大时间。范围: 10~600",
"default_value": "60",
"sort_order": 42,
},
{
"key": "query_result_max_memory_mb",
"value": "50",
"value_type": "integer",
"group": "query",
"label": "查询结果内存上限(MB)",
"description": "单次查询结果集最大内存占用,超限自动截断。范围: 10~500",
"default_value": "50",
"sort_order": 8,
},
]
# 分组元信息
@@ -196,4 +238,5 @@ SETTING_GROUPS = {
"security": {"label": "安全设置", "icon": "🔒", "description": "登录安全、密码策略、审计日志"},
"ticket": {"label": "工单设置", "icon": "📋", "description": "审批流程、回滚策略"},
"cleanup": {"label": "日志清理", "icon": "🧹", "description": "数据变更工单、审计日志、查询历史的自动清理策略"},
"executor": {"label": "执行器", "icon": "⚙️", "description": "SQL/Redis 执行超时、批量限制、连接参数"},
}