mask

package
v1.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 4, 2022 License: MIT Imports: 9 Imported by: 0

README

mask模块 实现说明

mask模块负责脱敏打码的实现,任何脱敏的实现都需要实现MaskAPI接口,其中包括如下三个函数。

MaskAPI接口

  1. GetRuleName() string
  • GetRuleName return RuleName of a MaskWorker
  • 返回RuleName
  1. Mask(string) (string, error)
  • Mask will return masked string
  • 返回打码后的文本
  1. MaskResult(*dlpheader.DetectResult) error
  • MaskResult will modify DetectResult.MaskText
  • 修改DetectResult.MaskText

MaskWoker类型

有两种MaskWorker:

  1. MaskWorker

通过读取配置文件中MaskRule实现

  1. DIYMaskWorker

调用方通过EngineAPI.RegisterMasker 传入自定义打码函数进行实现。

Documentation

Overview

Package mask implements Mask API

Index

Constants

View Source
const (
	MASKTYPE_CHAR    = "CHAR"    // 用字符替换敏感信息,需要用到后面更详细的配置项。
	MASKTYPE_TAG     = "TAG"     // 用识别和处理规则中的InfoType, 以`<InfoType>`的形式替换敏感信息。
	MASKTYPE_REPLACE = "REPLACE" //用Value定义的字符串,替换敏感信息,可以设定为空串,用于直接抹除。
	MASKTYPE_ALGO    = "ALGO"    //用Value定义的算法函数,处理敏感信息,用算法返回值替换原文,目前支持的算法有 [BASE64, MD5, CRC32]

	MASK_ALGO_BASE64 = "BASE64"
	MASK_ALGO_MD5    = "MD5"
	MASK_ALGO_CRC32  = "CRC32"

	MASK_UNKNOWN_TAG = "UNKNOWN"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type MaskAPI

type MaskAPI interface {
	// GetRuleName return RuleName of a MaskWorker
	// 返回RuleName
	GetRuleName() string
	// Mask will return masked string
	// 返回打码后的文本
	Mask(string) (string, error)
	// MaskResult will modify DetectResult.MaskText
	// 修改DetectResult.MaskText
	MaskResult(*dlpheader.DetectResult) error
}

func NewMaskWorker

func NewMaskWorker(rule conf.MaskRuleItem, p dlpheader.EngineAPI) (MaskAPI, error)

NewMaskWorker create MaskWorker based on MaskRule

type MaskWorker

type MaskWorker struct {
	// contains filtered or unexported fields
}

func (*MaskWorker) GetRuleName

func (I *MaskWorker) GetRuleName() string

GetRuleName return RuleName of a MaskWorker 返回RuleName

func (*MaskWorker) Mask

func (I *MaskWorker) Mask(in string) (string, error)

Mask will return masked string 返回打码后的文本

func (*MaskWorker) MaskResult

func (I *MaskWorker) MaskResult(res *dlpheader.DetectResult) error

MaskResult will modify DetectResult.MaskText 修改DetectResult.MaskText

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL