Skip to content

Arrange/data masking v3 ce#612

Merged
BugsGuru merged 27 commits into
mainfrom
arrange/data-masking-v3-ce
May 19, 2026
Merged

Arrange/data masking v3 ce#612
BugsGuru merged 27 commits into
mainfrom
arrange/data-masking-v3-ce

Conversation

@LordofAvernus
Copy link
Copy Markdown
Collaborator

@LordofAvernus LordofAvernus commented May 12, 2026

User description

关联的 issue

link https://github.com/actiontech/dms-ee/issues/821

描述你的变更

确认项(pr提交后操作)

Tip

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


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


Description

  • 新增查看原文工单接口

  • 重构SQL脱敏处理逻辑

  • 调整数据结构与国际化消息

  • 增加构建校验脚本支持


Diagram Walkthrough

flowchart LR
  A["新增unmasking接口定义"] --> B["注册中间件处理"]
  B --> C["SQL结果脱敏及原文替换"]
  C --> D["数据导出关联查看原文"]
  D --> E["构建校验脚本执行"]
Loading

File Walkthrough

Relevant files
Enhancement
9 files
data_mask_controller.go
添加查看原文及脱敏工作流接口                                                                                     
+425/-31
unmasking_workflow.go
新增查看原文工单API数据模型                                                                                   
+316/-0 
sql_workbench_service.go
集成SQL结果脱敏与中间件                                                                                       
+45/-33 
unmasking_workflow.go
定义原文工单及数据脱敏领域模型                                                                                   
+288/-0 
router.go
新增数据导出及原文下载路由                                                                                       
+37/-0   
service.go
整合unmasking工作流用例                                                                                 
+7/-1     
data_export_workflow.go
关联查看原文工单摘要字段                                                                                         
+11/-3   
data_export_workflow.go
添加原文数据下载API定义                                                                                       
+48/-0   
unmasking_workflow_ce.go
企业版之外占位unmasking用例                                                                             
+54/-0   
Documentation
1 files
message_zh.go
更新中文国际化消息项                                                                                             
+61/-46 
Refactor
1 files
cloudbeaver.go
调整SQL结果屏蔽参数传递                                                                                       
+12/-9   
Tests
1 files
verify_build_editions.sh
新增多标签构建校验脚本                                                                                           
+102/-0 
Configuration
1 files
Makefile
增加验证构建组合任务                                                                                             
+4/-0     
Additional files
20 files
data_export_task.go +5/-0     
db_structure_columns.go +36/-0   
swagger.json +1188/-194
swagger.yaml +954/-109
dms_controller.go +26/-0   
service.go +7/-3     
unmasking_workflow_ce.go +84/-0   
types.go +14/-0   
data_export_workflow_ce.go +4/-0     
db_service.go +20/-0   
cloudbeaver.go +1/-1     
data_export_workflow.go +13/-0   
data_export_workflow_ce.go +16/-0   
db_structures_ce.go +14/-0   
sql_workbench_result_masker_ce.go +14/-0   
active.en.toml +9/-0     
active.zh.toml +9/-0     
data_masking_middleware.go +15/-0   
data_masking_middleware_ce.go +24/-0   
masker.go +18/-0   

@actiontech-bot
Copy link
Copy Markdown
Member

没有在复审记录中找到这个MR => https://github.com/actiontech/dms-ee/issues/821

1 similar comment
@actiontech-bot
Copy link
Copy Markdown
Member

没有在复审记录中找到这个MR => https://github.com/actiontech/dms-ee/issues/821

@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 12, 2026

PR Reviewer Guide 🔍

(Review updated until commit 7f93314)

⏱️ Estimated effort to review: 5 🔵🔵🔵🔵🔵
🧪 PR contains tests
🔒 No security concerns identified
⚡ Recommended focus areas for review

@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 12, 2026

PR Code Suggestions ✨

Latest suggestions up to 7f93314

Explore these optional code suggestions:

CategorySuggestion                                                                                                                                    Impact
Security
校验和处理文件名安全

建议对返回的 fileName 进行安全校验和默认值处理,防止空值或恶意输入引发安全问题或格式错误。确保 Content-Disposition
头部设置的文件名是合法且安全的字符串。

internal/apiserver/service/dms_controller.go [3991-3992]

+safeFileName := fileName
+if safeFileName == "" {
+    safeFileName = "export.zip"
+}
+// 如有需要,可进一步添加正则校验确保文件名安全
 c.Response().Header().Set(echo.HeaderContentDisposition,
-		mime.FormatMediaType("attachment", map[string]string{"filename": fileName}))
+    mime.FormatMediaType("attachment", map[string]string{"filename": safeFileName}))
Suggestion importance[1-10]: 6

__

Why: 此建议通过为 fileName 添加空值检查和设置默认文件名来确保 Content-Disposition 头部的安全性,改善了潜在的安全问题,因此评分为6。

Low
Possible issue
校验 projectUID 非空

建议在调用屏蔽函数之前先校验传入的 projectUID 是否为空,防止因空值导致意外错误或 panic。这有助于确保数据屏蔽逻辑能够正确执行。

internal/dms/biz/cloudbeaver.go [760]

+if maskingCtx.ProjectUID == "" {
+    return errors.New("projectUID is required for masking operations")
+}
 return cu.sqlResultMasker.MaskSQLResults(ctx, result, maskingCtx.DBServiceUID, maskingCtx.SchemaName, maskingCtx.ProjectUID)
Suggestion importance[1-10]: 5

__

Why: 该建议在调用 MaskSQLResults 前添加了对 maskingCtx.ProjectUID 的非空校验,有助于提前捕捉输入错误,增强代码健壮性,但改动影响较小,因此评分为5。

Low

Previous suggestions

Suggestions up to commit d6d303f
CategorySuggestion                                                                                                                                    Impact
Possible issue
增加 nil 检查

建议在构造响应拦截器时增加对 c.Response()c.Response().Writer 的非空检查,以防止在这些对象为 nil 时触发空指针解引用而导致
panic。这样可以提升代码的健壮性并方便定位配置异常。

internal/sql_workbench/service/sql_workbench_service.go [1-7]

 func NewStreamExecuteResponseWriter(c echo.Context) *StreamExecuteResponseWriter {
+	if c.Response() == nil || c.Response().Writer == nil {
+		// 根据实际需求可以选择返回 nil 或采取其他错误处理措施
+		return nil
+	}
 	buf := new(bytes.Buffer)
 	return &StreamExecuteResponseWriter{
 		Response: *c.Response(),
 		Buffer:   buf,
 		Original: c.Response().Writer,
 	}
 }
Suggestion importance[1-10]: 6

__

Why: 该建议在创建 StreamExecuteResponseWriter 时增加了对 c.Response()c.Response().Writer 的 nil 检查,有助于防止潜在的 panic,从而提升代码健壮性,但改动属于防御性编程的改进,影响相对较小。

Low
General
增加日志记录

建议在返回默认值之前增加日志记录,当 d.maskingTaskRepo 为 nil 或 dbServiceUID
为空时记录警告日志,有助于排查配置或数据缺失的问题。此举可以帮助运维人员及早发现潜在异常。

internal/dms/biz/db_service.go [1-6]

 func (d *DBServiceUsecase) CheckSensitiveDataMaskingTask(ctx context.Context, dbServiceUID string) (bool, error) {
 	if d == nil || d.maskingTaskRepo == nil || dbServiceUID == "" {
+		if d != nil && d.log != nil {
+			d.log.Warnf("CheckSensitiveDataMaskingTask: missing maskingTaskRepo or empty dbServiceUID")
+		}
 		return false, nil
 	}
 	return d.maskingTaskRepo.CheckMaskingTaskExist(ctx, dbServiceUID)
 }
Suggestion importance[1-10]: 5

__

Why: 该建议通过在返回默认值前记录警告日志来帮助排查配置或数据问题,提升了问题诊断能力,但改动较为轻微,不会显著改变业务流程。

Low
Suggestions up to commit d7a70a6
CategorySuggestion                                                                                                                                    Impact
Possible issue
分离空返回判断

建议分别处理 err 非 nil 和返回空数组的情况,避免在 err 为 nil 时使用 %w 包裹 nil。这样可以确保错误信息更明确,降低后续调试风险。

internal/dms/service/data_export_workflow.go [342-345]

 tasks, err := d.DataExportWorkflowUsecase.BatchGetDataExportTask(ctx, []string{req.DataExportTaskUid})
-if err != nil || len(tasks) == 0 {
+if err != nil {
 	return nil, fmt.Errorf("failed to get data export task: %w", err)
 }
+if len(tasks) == 0 {
+	return nil, errors.New("failed to get data export task: no task found")
+}
Suggestion importance[1-10]: 6

__

Why: 该建议正确地将 err 非 nil 和返回空数组的情况分开处理,避免了在 err 为 nil 时调用 %w,从而提高了错误信息的明确性和后续调试的可靠性。

Low

@LordofAvernus LordofAvernus force-pushed the arrange/data-masking-v3-ce branch from d7a70a6 to d6d303f Compare May 12, 2026 06:47
@actiontech-bot
Copy link
Copy Markdown
Member

没有在复审记录中找到这个MR => https://github.com/actiontech/dms-ee/issues/821

@github-actions
Copy link
Copy Markdown

Persistent review updated to latest commit d6d303f

@actiontech-bot
Copy link
Copy Markdown
Member

没有在复审记录中找到这个MR => https://github.com/actiontech/dms-ee/issues/821

@github-actions
Copy link
Copy Markdown

Persistent review updated to latest commit 162dc22

@github-actions
Copy link
Copy Markdown

Failed to generate code suggestions for PR

Seechi-Yolo and others added 20 commits May 14, 2026 13:28
Added new files for unmasking workflow functionality, including use cases for creating, retrieving, and managing unmasking workflows. Introduced data structures for unmasking workflows, SQL content, and related operations, ensuring compatibility with both DMS and non-DMS builds. This implementation lays the groundwork for enhanced data masking capabilities.
…ter organization

Refactored the Confidence type and its associated constants by moving them from types_ee.go to a newly created types.go file. This change improves code organization and clarity, making it easier to manage and understand the confidence levels used in sensitive data detection.
数据导出集成查看原文工单功能

Added the DownloadOriginalDataExportWorkflow method to the DataExportWorkflowUsecase, enabling the download of unmasked data export workflows as a zip file. This includes validation checks for project UID, workflow status, and user permissions. Updated related service files to support this functionality, ensuring compatibility with both enterprise and community editions. Enhanced error handling and logging for better traceability.
…iginal (CE)

Owns the service struct wiring previously marked ee; pairs with biz/data_export EE implementation.
Updated the SQLResultMasker interface to include projectUID as a parameter for masking SQL results. Modified the CloudbeaverUsecase to pass projectUID during data masking operations. Introduced a new SQLResultMasker implementation for SQL workbench results, allowing for improved context and handling of masking operations. Refactored response writer to ensure consistent handling of response statuses and headers.
Added new endpoints for managing unmasking workflows, including creation, retrieval, approval, rejection, and cancellation. Introduced middleware for handling data masking and unmasking operations in SQL Workbench, ensuring proper permission checks and response handling. Enhanced the API structure to support these functionalities, improving overall data management capabilities.
…ing workflow functionality

Updated the newExportMaskingTransfer method to include projectUID as a parameter, improving the masking transfer capabilities. Added markUnmaskingWorkflowUsage method to track unmasking workflow usage. Initialized unmaskingWorkflowUsecase in DMSService, enabling unmasking workflow management in the enterprise edition. Introduced new SQL workbench result masker implementations for both community and enterprise editions, ensuring proper handling based on build tags.
Owns the service struct type alignment previously marked ee; pairs with storage/model EE implementation.
Introduced the ListTableColumns method in the DMSService to handle requests for listing table columns. This method currently returns an error indicating unsupported data masking, laying the groundwork for future enhancements in data management capabilities.
Updated the locale files to include new messages related to unmasking workflows, enhancing user feedback for operations such as submission, approval, cancellation, and viewing details. This addition supports the recently implemented unmasking workflow features in the DMS service.
Introduced a new script to verify that the application can be built successfully under four different GO_BUILD_TAGS combinations: Community, Trial, Enterprise, and DMS Enterprise. This addition enhances the build process by ensuring compatibility across editions before submission.
Modified the ListMaskingRulesReq struct in masking.go to enhance documentation for the projectUid parameter. The comment now specifies that projectUid is injected via path for specific requests and is optional for global requests, improving clarity for API users.
…g_workflow optional

Modified the ApproveUnmaskingWorkflowReq struct to change the approve_unmasking_workflow field from required to optional. Updated related documentation to reflect this change, clarifying that the field now carries an optional approve_reason. This adjustment improves API flexibility and aligns with user needs.
…sing

Updated the AuditMiddleware function to enhance error handling by logging warnings instead of errors when parsing SQL requests fails or when SQL and datasource ID are empty. This change ensures that audit processing does not block user SQL execution. Additionally, modified the base64 decoding to use URL-safe encoding, improving compatibility with session IDs generated by the ODC server.
…emoving maskingTaskRepo

Removed the maskingTaskRepo from the CloudbeaverUsecase and DataExportWorkflowUsecase, replacing its functionality with the new HasSensitiveDataMaskingTask method in the DBServiceUsecase. This change simplifies the usecases and enhances the handling of sensitive data masking tasks, improving overall code clarity and maintainability.
…e initialization

Added data masking middleware for SQL Workbench, including components for data masking and unmasking workflows. Initialized storage for the SQL result masker, ensuring it shares configuration with DMS. This enhances data protection capabilities within the API server.
…for data export and unmasking workflows

Modified swagger comments to improve clarity and consistency in API documentation. Adjusted parameter references and response schemas across multiple functions in the DMSController and related files, ensuring accurate representation of request and response structures.
Refactored error handling in the APIServer to dynamically set the HTTP status code and response code based on the type of error encountered. This change enhances the clarity of error responses by ensuring the correct status code is returned, improving the overall API error communication.
@LordofAvernus LordofAvernus force-pushed the arrange/data-masking-v3-ce branch from 162dc22 to 7f93314 Compare May 19, 2026 06:15
@actiontech-bot
Copy link
Copy Markdown
Member

没有在复审记录中找到这个MR => https://github.com/actiontech/dms-ee/issues/821

@github-actions
Copy link
Copy Markdown

Persistent review updated to latest commit 7f93314

@BugsGuru BugsGuru merged commit 4d337df into main May 19, 2026
1 check passed
@BugsGuru BugsGuru deleted the arrange/data-masking-v3-ce branch May 19, 2026 09:37
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.

4 participants