Skip to content

Arrange/data masking v3 ce#612

Open
LordofAvernus wants to merge 16 commits into
mainfrom
arrange/data-masking-v3-ce
Open

Arrange/data masking v3 ce#612
LordofAvernus wants to merge 16 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

  • 增加查看原文/脱敏工单新接口

  • 添加 unmasking workflow 数据结构与业务逻辑

  • 调整 SQL 脱敏及数据导出流程支持项目 UID

  • 添加 CE 版占位实现与构建校验脚本


Diagram Walkthrough

flowchart LR
  A["新增 unmasking_workflow API"] --> B["新增业务数据结构与逻辑"]
  B --> C["调整数据导出与 SQL 脱敏接口"]
  C --> D["新增 CE 版占位实现"]
  D --> E["更新构建校验脚本与构建目标"]
Loading

File Walkthrough

Relevant files
Enhancement
26 files
data_export_task.go
增加血缘分析与脱敏配置快照字段                                                                                   
+5/-0     
data_export_workflow.go
增加下载原文工单参数及接口文档                                                                                   
+15/-0   
db_structure_columns.go
新增列结构 API 定义                                                                                         
+36/-0   
masking.go
调整 ProjectUid 查询参数说明                                                                         
+2/-3     
unmasking_workflow.go
新增完整 unmasking workflow API 定义                                                     
+261/-0 
data_mask_controller.go
添加内部接口 ListTableColumns 与 unmasking 接口                                     
+310/-36
unmasking_workflow.go
新增 unmasking workflow 业务逻辑及数据结构                                                   
+271/-0 
unmasking_workflow_ce.go
CE 版 unmasking workflow 占位实现                                                         
+84/-0   
types.go
新增 Confidence 类型定义                                                                             
+14/-0   
cloudbeaver.go
调整 SQLResultMasker 接口支持 ProjectUID 参数                                       
+12/-9   
data_export_workflow.go
集成 unmasking workflow 与 masking 快照逻辑                                         
+7/-3     
data_export_workflow_ce.go
添加 DownloadOriginalDataExportWorkflow 占位方法                             
+4/-0     
db_service.go
新增查询及判断敏感数据脱敏任务的方法                                                                             
+20/-0   
cloudbeaver.go
修改 CloudbeaverUsecase 初始化参数                                                           
+1/-1     
data_export_workflow.go
调用填充 unmasking workflow 汇总信息                                                         
+13/-0   
data_export_workflow_ce.go
添加 CE 版下载原文工单接口占位                                                                               
+16/-0   
db_structures_ce.go
添加 DBStructures CE 版占位实现                                                                 
+14/-0   
service.go
更新 DMSService 初始化 unmasking workflow usecase                         
+7/-1     
sql_workbench_result_masker_ce.go
添加 CE 版 SQLResultMasker 占位实现                                                         
+14/-0   
unmasking_workflow_ce.go
添加 CE 版 unmasking workflow 占位接口实现                                               
+46/-0   
data_masking_middleware.go
添加配置项支持 UnmaskingWorkflowUsecase                                                 
+15/-0   
data_masking_middleware_ce.go
添加 CE 版 data masking middleware 占位                                             
+24/-0   
sql_workbench_service.go
更新 SQLWorkbenchService 逻辑与 Base64 解码方式                                     
+45/-33 
masker.go
新增 SQLResultMasker 接口与参数定义                                                             
+18/-0   
verify_build_editions.sh
新增多版本构建校验脚本                                                                                           
+102/-0 
Makefile
添加 verify_edition_builds 构建目标                                                       
+4/-0     
Documentation
3 files
message_zh.go
新增 unmasking workflow 国际化消息                                                           
+60/-45 
active.en.toml
增加 unmasking workflow 对应英文消息                                                         
+9/-0     
active.zh.toml
增加 unmasking workflow 对应中文消息                                                         
+9/-0     

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.
@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 162dc22)

⏱️ Estimated effort to review: 5 🔵🔵🔵🔵🔵
🧪 No relevant tests
🔒 No security concerns identified
⚡ No major issues detected

@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 12, 2026

PR Code Suggestions ✨

Latest suggestions up to d6d303f
Explore these optional code suggestions:

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

Previous suggestions

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 and others added 12 commits May 12, 2026 06:47
…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.
@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

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