Repository navigation
feat(P2-1): SQL 控制台(仅外部 MySQL/PostgreSQL) - #550
Merged
Merged
Conversation
按 FastHub 移植清单落地 P2-1;**不含本地/内置数据库浏览**(按需求排除)。
后端(新模块 app/modules/dbconsole)
- model:dbconsole_connection(名称唯一、密码 Fernet 加密、出参只回 has_password)
- schema:连接 CRUD / 凭据测试 / 查询请求与结果(列、行、脱敏列、截断、耗时)
- sql_guard:只读校验(剥注释→首词→写关键字/into outfile/sleep/多语句)、敏感列脱敏、DB 值 JSON 化
- service:仅 mysql/postgres 驱动映射;查询 30s 超时、最多 200 行;只读路径不提交(写操作即使
绕过校验也会随连接回滚),写路径必须 confirmed=true 且单条语句;密码解密后只用于建 DSN
- controller:/dbconsole/connection/{list,detail,create,update,delete,test,test/{id},{id}/databases,
{id}/tables,{id}/query},走 OperationLogRoute(自动操作审计)
- 注册领域路由 /dbconsole
前端
- api/module_dbconsole/connection.ts + views/module_dbconsole/index.vue:连接列表/表单弹窗(测试连接)、
SQL 编辑、库/表选择自动填查询、结果表(敏感列/截断/耗时提示)、写操作开关
- router:/dbconsole 懒加载静态路由(隐藏菜单,直接访问)
测试:tests/test_dbconsole_sql_guard.py(22 项)+ tests/test_dbconsole_service.py(8 项)
验证:后端 pytest **200 passed**、ruff All checks passed、basedpyright 0 errors;
前端 vue-tsc 通过、eslint 无错、prettier 通过、vitest **41 passed**。
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.
P2-1 SQL 控制台(仅外部 MySQL / PostgreSQL)
按需求不包含本地/内置数据库浏览(FastHub 的
data/fasthub.db类能力不移植)。后端(新模块
app/modules/dbconsole)has_password(永不返回密码)sql_guard:剥注释 → 首词 → 写关键字 /into outfile/sleep()/ 多语句,四类绕过全部拦截confirmed=true且只允许单条OperationLogRoute自动审计前端
/dbconsole页面(懒加载静态路由,隐藏菜单直接访问):连接列表/表单(含测试连接)、SQL 编辑、库/表选择自动生成查询、结果表(脱敏/截断/耗时提示)、写操作开关
验证
pytest200 passed(新增 30 项 SQL 守卫/服务测试)、ruff通过、basedpyright0 errorsvue-tsc通过、eslint无错、prettier通过、vitest41 passed