← 返回列表

GoDLP: 敏感信息保护系统

聚合站 SecWiki技术 入库 2026-11-18T15:43:48

为了保障企业的数据安全和隐私安全,godlp 提供了一系列针对敏感数据的识别和处置方案, 其中包括敏感数据识别算法,数据脱敏处理方式,业务自定义的配置选项和海量数据处理能力。 godlp 能够应用多种隐私合规标准,对原始数据进行分级打标、判断敏感级别和实施相应的脱敏处理。

In order to achieve data security and privacy security requirements for enterprises, godlp provides a serial of sensitive information finding and handling methods, including sensitive detection algorithm, de-identification APIs, business DIY configuration and the big data handling ability. Also, godlp is able to apply a variety of privacy compliance standers, do classification based on sensitive levels, and mask data based on rules.

godlp 能够广泛支持结构化(JSON数据、KV数据、golang map)和非结构化数据(多语言字符串)。

DLP 内置多种敏感数据识别规则,能对原始数据进行敏感类型识别,确保敏感信息能被妥善处理。

DLP 支持多种脱敏算法,业务可以根据需求对敏感数据进行不同的脱敏处理。

除默认的敏感信息识别和处理规则外,业务可以根据实际情况,配置自定义的YAML规则,DLP 能够根据传入的配置选项,完成相应的数据处理任务。

go get github.com/bytedance/godlp@latest
示例代码在 mainrun/mainrun.go 文件中

在godlp代码根目录下输入以下命令可以进行编译和运行

make
make run
make test
make bench

dlpheader定义了 godlp SDK需要的数据结构,常量定义等。godlp SDK主要提供了以下API进行敏感信息识别和脱敏。

  1. ApplyConfig(conf string) error
  1. ApplyConfigFile(filePath string) error
  1. Detect(inputText string) ([]*DetectResult, error)
  1. DetectMap(inputMap map[string]string) ([]*DetectResult, error)
  1. DetectJSON(jsonText string) ([]*DetectResult, error)
  1. Deidentify(inputText string) (string, []*DetectResult, error)
  1. DeidentifyMap(inputMap map[string]string) (map[string]string, []*DetectResult, error)
  1. ShowResults(resultArray []*DetectResult)
  1. Mask(inputText string, methodName string) (string, error)
  1. Close()
  1. GetVersion() string
  1. RegisterMasker(maskName string, maskFunc func(string) (string, error)) error
  1. NewLogProcesser() logs.Processor
  1. MaskStruct(inObj interface{}) (interface{}, error)

规则文件请见 conf.yml

config 文件以yaml格式为准,整体分为: Global,MaskRules,Rules 三个部分。其中:

  1. Global 包含影响DLP全局的一些配置项,例如API版本、禁用的规则ID、是否启用后端服务辅助判断。
  2. MaskRules 包含脱敏操作的配置,例如打码、替换等方式。
  3. Rules 包含识别和处理规则,其中一个识别过程包括 Detect, Filter 和 Verify 三个依次的过程, 处理需要引用上面定义的脱敏规则。

godlp 以 Engine 结构为主,通过Engine对象来实现 EngineAPI 接口,直接实现的接口以sdk.go,sdkdeidentify.go,sdkdetect.go和sdkmask.go为主。对于deidentify和mask操作,会继续调用子目录下的detector,mask子模块。

  1. sdk.go: 实现EngineAPI接口中业务无关的API,例如Close()
  2. sdk_test.go: 单元测试用例。
  3. sdkconfig.go: 实现配置相关的接口,例如ApplyConfig()
  4. sdkdeidentify.go: 实现脱敏相关的接口。
  5. sdkdetect.go: 实现敏感信息检测接口。
  6. sdkinternal.go: 实现 Engine 对象的内部函数。
  7. sdkmask.go: 实现直接打码的接口。
  8. conf.yml: 内置的默认配置文件,含DLP维护的规则。
  9. bindata.go: go generate生成的数据文件,包含conf.yml

  10. conf: 实现DlpConf结构,处理配置文件。

  11. detector: 敏感信息检测逻辑的内部实现。
  12. errlist: 报错信息列表。
  13. mask: 直接脱敏的内部实现。
  14. util: 辅助功能实现。
  15. dlpheader: dlp sdk 定义的接口头文件。

DLP项目从立项开始,一路走来,离不开其中辛苦付出的开发同学们,这里向为DLP写下代码的同学,致以最诚挚的感谢,以下同学排名不分先后。

原文链接:https://github.com/bytedance/godlp