Documentation
¶
Overview ¶
Package dlp provides dlp sdk api implementaion
Package dlp sdkconfig.go implement config related API ¶
Package dlp sdkdeidentify.go implements deidentify related APIs ¶
Package dlp sdkdetect.go implements DLP detect APIs ¶
Package dlp sdkinternal.go implements internal API for DLP ¶
Package dlp sdkmask.go implements Mask API
Index ¶
- Constants
- Variables
- func B2S(b []byte) string
- func DlpInit(name ...string) (*dlp, error)
- func NewEngine(callerID string) (dlpheader.EngineAPI, error)
- func S2B(s string) (b []byte)
- type DIYMaskWorker
- type DescribeRulesResponse
- type Engine
- func (I *Engine) ApplyConfig(confString []byte) error
- func (I *Engine) ApplyConfigDefault() error
- func (I *Engine) ApplyConfigFile(filePath string) error
- func (I *Engine) Close()
- func (I *Engine) Deidentify(inputText string) (outputText string, retResults []*dlpheader.DetectResult, retErr error)
- func (I *Engine) DeidentifyJSON(jsonText string) (outStr string, retResults []*dlpheader.DetectResult, retErr error)
- func (I *Engine) DeidentifyJSONByResult(jsonText string, detectResults []*dlpheader.DetectResult) (outStr string, retErr error)
- func (I *Engine) DeidentifyMap(inputMap map[string]string) (outMap map[string]string, retResults []*dlpheader.DetectResult, retErr error)
- func (I *Engine) Detect(inputText string) (retResults []*dlpheader.DetectResult, retErr error)
- func (I *Engine) DetectJSON(jsonText string) (retResults []*dlpheader.DetectResult, retErr error)
- func (I *Engine) DetectMap(inputMap map[string]string) (retResults []*dlpheader.DetectResult, retErr error)
- func (I *Engine) DisableAllRules() error
- func (I *Engine) GetDefaultConf() []byte
- func (I *Engine) GetVersion() string
- func (I *Engine) Mask(inputText string, methodName string) (outputText string, err error)
- func (I *Engine) MaskStruct(inPtr interface{}) (outPtr interface{}, retErr error)
- func (I *Engine) NewDIYMaskWorker(maskName string, maskFunc func(string) (string, error)) (mask.MaskAPI, error)
- func (I *Engine) NewEmptyLogProcessor() dlpheader.Processor
- func (I *Engine) NewLogProcessor() dlpheader.Processor
- func (I *Engine) RegisterMasker(maskName string, maskFunc func(string) (string, error)) error
- func (I *Engine) ShowDlpConf() error
- func (I *Engine) ShowResults(results []*dlpheader.DetectResult)
- type HttpResponseBase
- type ResultList
Constants ¶
const ( Version = "v1.2.15" DefLimitErr = "<--[DLP] Log Limit Exceeded-->" // 如果超过限制,则追加到日志 DefMaxLogItem = 16 // 日志的最大输入项 DefResultSize = 4 // 数组分配的默认结果大小 DefLinebackerSize = 1024 // 默认行块 DefMaxCallDeep = 5 // MaskStruct的最大调用深度 DefMaxItem = 1024 * 4 // MAP API的最大输入项 DefMaxInput = 1024 * 1024 // 1MB,最大输入字符串长度 DefCutter = " /\r\n\\[](){}:=\"'," // 用于在字符串中查找KV对象的默认切割器 )
Variables ¶
var ( DefMaxLogInput int32 = 1024 // 默认1KB,日志的最大输入长度,在conf中更改 DefMaxRegexRuleId int32 = 0 // 默认0,没有正则表达式规则将用于日志默认,在conf中更改它 )
var DefCfg []byte
Functions ¶
Types ¶
type DIYMaskWorker ¶
type DIYMaskWorker struct {
// contains filtered or unexported fields
}
DIYMaskWorker stores maskFuc and maskName
func (*DIYMaskWorker) GetRuleName ¶
func (I *DIYMaskWorker) GetRuleName() string
GetRuleName is required by mask.MaskAPI
func (*DIYMaskWorker) Mask ¶
func (I *DIYMaskWorker) Mask(in string) (string, error)
Mask is required by mask.MaskAPI
func (*DIYMaskWorker) MaskResult ¶
func (I *DIYMaskWorker) MaskResult(res *dlpheader.DetectResult) error
MaskResult is required by mask.MaskAPI
type DescribeRulesResponse ¶
type DescribeRulesResponse struct { HttpResponseBase Rule []byte `json:"rule,omitempty"` Crc uint32 `json:"crc,omitempty"` // rule 的crc }
type Engine ¶
type Engine struct { Version string // contains filtered or unexported fields }
Engine Object implements all DLP API functions
func (*Engine) ApplyConfig ¶
ApplyConfig by configuration content 传入conf string 进行配置
func (*Engine) ApplyConfigDefault ¶
func (*Engine) ApplyConfigFile ¶
ApplyConfigFile by config file path 传入filePath 进行配置
func (*Engine) Close ¶
func (I *Engine) Close()
Close release inner object, such as detector and masker
func (*Engine) Deidentify ¶
func (I *Engine) Deidentify(inputText string) (outputText string, retResults []*dlpheader.DetectResult, retErr error)
Deidentify detects string firstly, then return masked string and results 对string先识别,然后按规则进行打码
func (*Engine) DeidentifyJSON ¶
func (I *Engine) DeidentifyJSON(jsonText string) (outStr string, retResults []*dlpheader.DetectResult, retErr error)
DeidentifyJSON detects JSON firstly, then return masked json object in string format and results 对jsonText先识别,然后按规则进行打码,返回打码后的JSON string
func (*Engine) DeidentifyJSONByResult ¶
func (I *Engine) DeidentifyJSONByResult(jsonText string, detectResults []*dlpheader.DetectResult) (outStr string, retErr error)
DeidentifyJSONByResult returns masked json object in string format from the passed-in []*dlpheader.DetectResult. You may want to call DetectJSON first to obtain the []*dlpheader.DetectResult. 根据传入的 []*dlpheader.DetectResult 对 Json 进行打码,返回打码后的JSON string
func (*Engine) DeidentifyMap ¶
func (I *Engine) DeidentifyMap(inputMap map[string]string) (outMap map[string]string, retResults []*dlpheader.DetectResult, retErr error)
DeidentifyMap detects KV map firstly,then return masked map 对map[string]string先识别,然后按规则进行打码
func (*Engine) Detect ¶
func (I *Engine) Detect(inputText string) (retResults []*dlpheader.DetectResult, retErr error)
Detect find sensitive information for input string 对string进行敏感信息识别
func (*Engine) DetectJSON ¶
func (I *Engine) DetectJSON(jsonText string) (retResults []*dlpheader.DetectResult, retErr error)
DetectJSON detects json string 对json string 进行敏感信息识别
func (*Engine) DetectMap ¶
func (I *Engine) DetectMap(inputMap map[string]string) (retResults []*dlpheader.DetectResult, retErr error)
DetectMap detects KV map 对map[string]string进行敏感信息识别
func (*Engine) DisableAllRules ¶
ApplyConfigDefault will use embeded local config, only used for DLP team 业务禁止使用
func (*Engine) GetDefaultConf ¶
GetDefaultConf will return default config string 返回默认的conf string
func (*Engine) MaskStruct ¶
MaskStruct will mask a strcut object by tag mask info 根据tag mask里定义的脱敏规则对struct object直接脱敏, 会修改obj本身,传入指针,返回指针
func (*Engine) NewDIYMaskWorker ¶
func (I *Engine) NewDIYMaskWorker(maskName string, maskFunc func(string) (string, error)) (mask.MaskAPI, error)
NewDIYMaskWorker creates mask.MaskAPI object
func (*Engine) NewEmptyLogProcessor ¶
NewEmptyLogProcesser will new a log processer which will do nothing 业务禁止使用
func (*Engine) NewLogProcessor ¶
NewLogProcessor create a log processer for the package logs 调用过之后,eng只能用于log处理,因为规则会做专门的优化,不适合其他API使用
func (*Engine) RegisterMasker ¶
Register DIY Masker 注册自定义打码函数
func (*Engine) ShowResults ¶
func (I *Engine) ShowResults(results []*dlpheader.DetectResult)
ShowResults print results in console 打印识别结果
type HttpResponseBase ¶
type ResultList ¶
type ResultList []*dlpheader.DetectResult
Result type define is uesd for sort in mergeResults
func (ResultList) Contain ¶
func (a ResultList) Contain(i, j int) bool
Contain checks whether a[i] contains a[j]
func (ResultList) Equal ¶
func (a ResultList) Equal(i, j int) bool
Equal checks whether positions are equal
func (ResultList) Less ¶
func (a ResultList) Less(i, j int) bool
Less function is used for sort in mergeResults
func (ResultList) Swap ¶
func (a ResultList) Swap(i, j int)
Swap function is used for sort in mergeResults
Source Files
¶
Directories
¶
Path | Synopsis |
---|---|
Package conf provides configuration handler for dlp
|
Package conf provides configuration handler for dlp |
Package detector implements detector functions
|
Package detector implements detector functions |
Package dlpheader defines API information about DLP SDK, including DetectResult, mask methods and API functions.
|
Package dlpheader defines API information about DLP SDK, including DetectResult, mask methods and API functions. |
Package mask implements Mask API
|
Package mask implements Mask API |