Skip to content

Conversation

@BugsGuru
Copy link
Collaborator

@BugsGuru BugsGuru commented Nov 28, 2025

User description

关联的 issue

https://github.com/actiontech/sqle-ee/issues/2583

描述你的变更

  • 记录odc操作日志
  • 支持cb和odc共存

确认项(pr提交后操作)

Tip

请在指定复审人之前,确认并完成以下事项,完成后✅


  • 我已完成自测
  • 我已记录完整日志方便进行诊断
  • 我已在关联的issue里补充了实现方案
  • 我已在关联的issue里补充了测试影响面
  • 我已确认了变更的兼容性,如果不兼容则在issue里标记 not_compatible
  • 我已确认了是否要更新文档,如果要更新则在issue里标记 need_update_doc


Description

  • 新增支持 ODC 查询配置

  • 添加操作日志记录中间件

  • 重构 Gzip 处理逻辑到工具库

  • 更新 Swagger 接口文档


Diagram Walkthrough

flowchart LR
  A["SQL Query 配置更新"] --> B["新增 ODC 配置字段"]
  B --> C["添加操作日志中间件"]
  C --> D["Gzip 处理重构"]
Loading

File Walkthrough

Relevant files
Enhancement
6 files
cloudbeaver.go
新增 ODC 查询配置字段                                                                                       
+2/-0     
router.go
配置中间件、Gzip 重构及 JWT 跳过调整                                                                   
+21/-17 
sql_workbench_controller.go
更新 SQL 查询配置返回结构                                                                                   
+15/-12 
gzip.go
新增 Gzip 工具函数                                                                                         
+28/-0   
operation_log_middleware.go
新增操作日志中间件配置结构体                                                                                     
+12/-0   
operation_log_middleware_ce.go
新增操作日志中间件实现(社区版)                                                                                 
+15/-0   
Other
2 files
cloudbeaver.go
移除重复的 Cloudbeaver 配置函数                                                                     
+0/-19   
sql_workbench_service.go
移除重复的 SQL Workbench 配置函数                                                                 
+0/-17   
Documentation
2 files
swagger.json
更新 Swagger JSON 定义,新增 ODC 字段                                                         
+9/-12   
swagger.yaml
更新 Swagger YAML 定义,新增 ODC 字段                                                         
+7/-9     

@github-actions
Copy link

github-actions bot commented Nov 28, 2025

PR Reviewer Guide 🔍

(Review updated until commit 98342ff)

⏱️ Estimated effort to review: 3 🔵🔵🔵⚪⚪
🧪 No relevant tests
🔒 No security concerns identified
⚡ Recommended focus areas for review

中间件空实现

在CE版本中,操作日志中间件目前仅作为空实现返回next(c),请确认这种空实现是预期行为,并确保未来若需要记录操作日志时能够顺利扩展。

//go:build !enterprise
// +build !enterprise

package sql_workbench

import "github.com/labstack/echo/v4"

// GetOperationLogBodyDumpMiddleware 返回用于记录操作日志的 BodyDump 中间件
func GetOperationLogBodyDumpMiddleware(config OperationLogMiddlewareConfig) echo.MiddlewareFunc {
	return func(next echo.HandlerFunc) echo.HandlerFunc {
		return func(c echo.Context) error {
			return next(c)
		}
	}
}
JWT跳过规则

新增的notSkipJWTPaths配置用于确保特定路径不跳过JWT校验,请确认该配置能覆盖所有预期的安全边界,并且不会误放权限或导致安全漏洞。

var notSkipJWTPaths = []string{
	sqlWorkbenchService.SQL_WORKBENCH_URL,
}
s.echo.Use(dmsMiddleware.JWTTokenAdapter(), echojwt.WithConfig(echojwt.Config{

@github-actions
Copy link

github-actions bot commented Nov 28, 2025

PR Code Suggestions ✨

Latest suggestions up to 98342ff

Explore these optional code suggestions:

CategorySuggestion                                                                                                                                    Impact
General
调整JWT路径检查顺序

建议调整JWT路径检查的顺序,先检查 notSkipJWTPaths 再检查
skipJWTPaths,以确保不跳过的路径能够正确生效。当前顺序可能导致冲突的规则无法按预期执行。

internal/apiserver/service/router.go [372-381]

+for _, notSkipPath := range notSkipJWTPaths {
+	if strings.HasSuffix(uri, notSkipPath) || strings.HasPrefix(uri, notSkipPath) {
+		return false
+	}
+}
 for _, skipPath := range skipJWTPaths {
 	if strings.HasSuffix(uri, skipPath) || strings.HasPrefix(uri, skipPath) {
 		return true
 	}
 }
-for _, notSkipPath := range notSkipJWTPaths {
-	if strings.HasSuffix(uri, notSkipPath) || strings.HasPrefix(uri, notSkipPath) {
-		return false
-	}
-}
Suggestion importance[1-10]: 7

__

Why: The suggestion reorders the JWT path checks to prioritize notSkipJWTPaths over skipJWTPaths, which can resolve potential conflicting rules. The improvement is contextually sound but only offers a moderate impact.

Medium

Previous suggestions

Suggestions up to commit 5444fdb
CategorySuggestion                                                                                                                                    Impact
General
统一URL结尾格式


建议对OdcQueryRootURI也进行一致性处理,确保URL格式统一。如果业务需要保持路径以斜杠结尾,则为cc.SqlWorkbenchService.GetRootUri()追加斜杠。这样能避免由于路径格式不一导致的访问问题。

internal/apiserver/service/sql_workbench_controller.go [63-65]

 SQLQueryRootURI: cc.CloudbeaverService.CloudbeaverUsecase.GetRootUri() + "/", // 确保URL以斜杠结尾,防止DMS开启HTTPS时,Web服务器重定向到HTTP根路径导致访问错误
 EnableOdcQuery:  cc.SqlWorkbenchService.IsConfigured(),
-OdcQueryRootURI: cc.SqlWorkbenchService.GetRootUri(),
+OdcQueryRootURI: cc.SqlWorkbenchService.GetRootUri() + "/",
Suggestion importance[1-10]: 6

__

Why: The suggestion accurately identifies the inconsistency between SQLQueryRootURI and OdcQueryRootURI by recommending an appended slash for uniform format. This is a minor yet useful improvement, warranting a moderate score.

Low
Suggestions up to commit 64c129c
CategorySuggestion                                                                                                                                    Impact
General
完善日志记录逻辑

目前中间件仅调用 next(c) 而没有实现任何操作日志记录逻辑。建议在此处添加必要的日志记录操作或明确标识为占位实现,防止后续误认为已完成日志功能实现。

internal/sql_workbench/service/operation_log_middleware_ce.go [9-15]

 func GetOperationLogBodyDumpMiddleware(config OperationLogMiddlewareConfig) echo.MiddlewareFunc {
 	return func(next echo.HandlerFunc) echo.HandlerFunc {
 		return func(c echo.Context) error {
+			// TODO: 实现操作日志记录逻辑,如记录请求体、用户信息等日志内容
 			return next(c)
 		}
 	}
 }
Suggestion importance[1-10]: 6

__

Why: This suggestion correctly identifies that the middleware currently only calls next(c) and advises adding a TODO for future log implementation, thereby improving code clarity.

Low
Possible issue
检查JWT路径匹配

建议仔细检查 notSkipJWTPaths 的逻辑,确保 URL 匹配行为符合预期,以免导致安全验证失效。请验证路径匹配方式,避免因前缀或后缀匹配产生意外绕过 JWT
校验的问题。

internal/apiserver/service/router.go [379-381]

 var notSkipJWTPaths = []string{
-		sqlWorkbenchService.SQL_WORKBENCH_URL,
+		sqlWorkbenchService.SQL_WORKBENCH_URL, // 确保此URL配置正确且特定于需要严格验证的路径
 }
Suggestion importance[1-10]: 4

__

Why: The suggestion only adds a comment to the notSkipJWTPaths declaration without changing its logic. It serves as a reminder to check URL matching but doesn't alter functionality.

Low

@github-actions
Copy link

Persistent review updated to latest commit 5444fdb

@github-actions
Copy link

Persistent review updated to latest commit 98342ff

@LordofAvernus LordofAvernus merged commit d5287fa into main Nov 28, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants