Skip to content

feat(masking): add API structs and CE stubs for custom masking rules #787#600

Open
LordofAvernus wants to merge 4 commits intomainfrom
dms/feat-787
Open

feat(masking): add API structs and CE stubs for custom masking rules #787#600
LordofAvernus wants to merge 4 commits intomainfrom
dms/feat-787

Conversation

@LordofAvernus
Copy link
Copy Markdown
Collaborator

@LordofAvernus LordofAvernus commented Apr 22, 2026

User description

Summary

  • Add API request/response structs for custom masking rule CRUD endpoints (ListV2, Add, Update, Delete)
  • Add API structs for sensitive type listing and masking effect preview
  • Add rule_source field to existing masking API structs (MaskingRuleConfig, SensitiveFieldScanResult, etc.)
  • Add CE stub methods in data_masking_ce.go returning errNotSupportDataMasking
  • Add controller handler implementations for all new endpoints

Related: https://github.com/actiontech/dms-ee/issues/787


Description

  • 新增自定义脱敏规则 API 结构体定义

  • 优化字段及 RuleRefs 支持定制规则

  • 添加自定义规则控制器接口方法

  • 增加 CE 版本存根函数防构建失败


Diagram Walkthrough

flowchart LR
  A["API结构体定义"] -- "新增字段及规则定义" --> B["控制器接口新增"]
  B -- "调用 CE 存根" --> C["CE存根函数添加"]
Loading

File Walkthrough

Relevant files
Enhancement
masking.go
更新 API 接口结构体定义                                                                                     

api/dms/service/v1/masking.go

  • 添加自定义脱敏规则相关 API 结构体和字段
  • 新增结构体 MaskingRuleRef 及 rule_refs 字段
  • 调整 Add/Update MaskingTemplate 接口定义
+328/-11
data_mask_controller.go
添加自定义规则控制器接口                                                                                         

internal/apiserver/service/data_mask_controller.go

  • 新增 ListMaskingRulesV2 接口方法
  • 添加自定义规则的 Add/Update/Delete 接口
  • 启用 ListSensitiveTypes 与 PreviewMaskingEffect 接口
+254/-0 
Bug fix
data_masking_ce.go
添加 CE 版本存根函数                                                                                         

internal/dms/service/data_masking_ce.go

  • 增加 CE
    存根函数:ListMaskingRulesV2、Add/Update/DeleteCustomMaskingRule、ListSensitiveTypes、PreviewMaskingEffect
  • 确保非 DMS 构建返回 errNotSupportDataMasking
+24/-0   

…king rules #787

Add request/response structs for custom masking rules CRUD, sensitive
types list, and masking effect preview. Add 6 controller handler methods
following existing code style.
The new V2 API controller calls ListMaskingRulesV2, AddCustomMaskingRule,
UpdateCustomMaskingRule, DeleteCustomMaskingRule, ListSensitiveTypes, and
PreviewMaskingEffect which only had EE implementations (dms build tag).
Without CE stubs the non-dms build fails. Add stub methods returning
errNotSupportDataMasking to data_masking_ce.go.
@actiontech-bot actiontech-bot requested a review from iwanghc April 22, 2026 10:32
@github-actions
Copy link
Copy Markdown

PR Reviewer Guide 🔍

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

默认值缺失

在 MaskingRuleConfig 结构体中新添加的字段 MaskingRuleSource 注释提到默认值为 "builtin",但代码中并没有为此字段设置默认值或进行默认值校验,可能导致调用方未传值时出现不一致的问题。

// masking rule source: "builtin" or "custom", default is "builtin"
// Example: "builtin"
MaskingRuleSource string `json:"masking_rule_source"`
默认值缺失

在 TableColumnMaskingDetail 结构体中新添加的字段 MaskingRuleSource 同样缺少默认值处理,如果调用方未传递该字段可能会引起预期外的行为。

// current masking rule source: "builtin" or "custom"
//
// Example: "builtin"
MaskingRuleSource string `json:"masking_rule_source,omitempty"`

@github-actions
Copy link
Copy Markdown

PR Code Suggestions ✨

No code suggestions found for the 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.

1 participant