merge: SQL平台代码v1 优化包合并 — 193条审核规则 + 16页面UI优化

后端新增 (Step 1):
- mysql_audit_rules.py: 63条 MySQL审核规则 (DDL 36 + DML 9 + 命名 5 + 性能 5 + 安全 5)
- redis_audit_rules.py: 43条 Redis审核规则 (KEY管理 10 + 命令安全 12 + 数据结构 8 + 性能 8 + 安全 5)
- mongodb_audit_rules.py: 42条 MongoDB审核规则 (集合管理 + 查询安全 + 聚合管道 + 写入安全 + 性能)
- postgres_audit_rules.py: 45条 PostgreSQL审核规则 (DDL 18 + DML 8 + DQL 6 + 安全 6 + 性能 7)

后端合并 (Step 2):
- audit_engine_v2.py: 新增4个DB规则模块import (100+→200+规则)
- audit_rule_seeds.py: 新增30条MongoDB种子规则 + 别名映射
- audit_rule.py: 新增数据库类型别名 (postgresql→postgres, pg→postgres, mongo→mongodb)

前端优化 (Step 4) — 16页面全覆盖:
- InstancePage, WorkflowPage, TicketsPage, TicketCreatePage, TicketDetailPage
- UsersPage, SlowQueryPage, DataDictionaryPage, Dashboard
- InstanceGroupPage, AuditLogsPage, QueriesPage, AuditRulesPage, RolesPage
- useAuth.tsx, SqlEditor.tsx

后端测试 895/895 通过, 前端 tsc --noEmit 通过
This commit is contained in:
logan committed 2026-05-23 16:46:13 +08:00
1 parent e1ba8b3327
commit 58eb78c987
24 files changed
+16333 -2225

No files matched your search

+17 -1
View File
@@ -1,4 +1,4 @@
"""SQL 审核引擎 V2 — 可配置规则引擎,支持 100+ 审核规则。
"""SQL 审核引擎 V2 — 可配置规则引擎,支持 200+ 审核规则。
对标 Yearning/Archery/Bytebase 的审核能力,支持:
- DDL 规则 (建表规范、索引规范、字段规范)
@@ -7,6 +7,10 @@
- 命名规范 (表名/字段名/索引名规范)
- 性能规则 (全表扫描、索引使用、大 IN 子句)
- 安全规则 (敏感字段、SQL 注入风险、密码硬编码)
- MySQL 专用规则 (62+ 条,覆盖 MySQL 特有语法)
- PostgreSQL 专用规则 (45+ 条,覆盖 PG 特有语法)
- Redis 专用规则 (43+ 条,覆盖 Redis 命令和数据结构)
- MongoDB 专用规则 (42+ 条,覆盖 MongoDB 查询和聚合)
使用方式:
engine = SQLAuditEngineV2(db_session)
@@ -1681,3 +1685,15 @@ class SQLAuditEngineV2:
def invalidate_cache(self) -> None:
"""清除规则缓存,下次审核重新加载。"""
self._rules_cache = None
# ── 延迟导入各数据库专用规则(副作用:注册到 _RULE_REGISTRY)────
# 放在文件末尾以避免循环导入(规则模块需要 import register_rule 等)
# MySQL 规则 (62+ 条)
from app.services.mysql_audit_rules import * # noqa: F401,F403
# PostgreSQL 规则 (45+ 条)
from app.services.postgres_audit_rules import * # noqa: F401,F403
# Redis 规则 (43+ 条)
from app.services.redis_audit_rules import * # noqa: F401,F403
# MongoDB 规则 (42+ 条)
from app.services.mongodb_audit_rules import * # noqa: F401,F403