dlp

package
v0.0.22 Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2024 License: MIT Imports: 24 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ChineseName    = "chinese_name"    // 中文姓名
	IDCard         = "id_card"         // 中国居民身份证号码
	Passport       = "passport"        // 护照号码
	SocialSecurity = "social_security" // 社会保障号码
	DriversLicense = "license_number"  // 驾驶证号码
	MobilePhone    = "mobile_phone"    // 手机号码
	FixedPhone     = "landline"        // 固定电话号码
	Email          = "email"           // 电子邮箱地址
	Address        = "address"         // 详细地址信息
	PostalCode     = "postal_code"     // 邮政编码
	BankCard       = "bank_card"       // 银行卡号
	CreditCard     = "credit_card"     // 信用卡号
	IPv4           = "ipv4"            // IPv4地址
	IPv6           = "ipv6"            // IPv6地址
	MAC            = "mac"             // MAC物理地址
	IMEI           = "imei"            // 手机设备识别码
	LicensePlate   = "plate"           // 车牌号码
	VIN            = "vin"             // 车辆识别代号
	APIKey         = "api_key"         // API访问密钥
	JWT            = "jwt"             // JSON Web Token
	AccessToken    = "access_token"    // 访问令牌
	DeviceID       = "device_id"       // 设备唯一标识
	UUID           = "uuid"            // 通用唯一识别码
	MD5            = "md5"             // MD5哈希值
	SHA1           = "sha1"            // SHA1哈希值
	SHA256         = "sha256"          // SHA256哈希值
	LatLng         = "lat_lng"         // 地理坐标(经纬度)
	URL            = "url"             // 统一资源定位符
	Domain         = "domain"          // 域名
	Password       = "password"        // 密码
	Username       = "username"        // 用户名
	MedicalID      = "medical_id"      // 医疗保险号
	CompanyID      = "company_id"      // 统一社会信用代码
	IBAN           = "iban"            // 国际银行账号
	Swift          = "swift"           // SWIFT银行代码
	GitRepo        = "git_repo"        // Git代码仓库地址
)
View Source
const (
	// 个人身份信息
	// 百家姓列表(按拼音排序)
	ChineseSurnames = "(?:" +
		"艾|安|敖|巴|白|班|包|暴|鲍|贝|贲|毕|边|卞|别|邴|伯|薄|卜|蔡|曹|岑|柴|昌|常|晁|车|陈|成|程|池|充|仇|储|楚|褚|淳|从|崔|戴|党|邓|狄|刁|丁|董|窦|杜|端|段|鄂|樊|范|方|房|费|丰|封|冯|凤|伏|扶|符|福|傅|甘|高|郜|戈|盖|葛|耿|龚|宫|勾|苟|辜|古|谷|顾|关|管|桂|郭|国|韩|杭|郝|何|和|贺|赫|衡|洪|侯|胡|扈|花|华|滑|怀|宦|黄|惠|霍|姬|嵇|吉|汲|籍|计|纪|季|贾|简|姜|江|蒋|焦|金|靳|荆|井|景|居|鞠|阚|康|柯|空|孔|寇|蒯|匡|邝|况|赖|蓝|郎|劳|雷|冷|黎|李|利|连|廉|练|梁|廖|林|蔺|凌|令|刘|柳|龙|隆|娄|卢|鲁|陆|路|逯|禄|吕|栾|罗|骆|麻|马|满|毛|茅|梅|蒙|孟|米|宓|闵|明|莫|牟|穆|倪|聂|年|宁|牛|钮|农|潘|庞|裴|彭|皮|平|蒲|濮|浦|戚|祁|齐|钱|强|乔|谯|秦|邱|裘|曲|屈|瞿|全|阙|冉|饶|任|荣|容|阮|芮|桑|沙|山|单|商|上|邵|佘|申|沈|盛|师|施|时|石|史|寿|殳|舒|束|双|水|司|松|宋|苏|宿|孙|索|邰|太|谈|谭|汤|唐|陶|滕|田|通|童|涂|屠|万|汪|王|危|韦|卫|魏|温|文|闻|翁|巫|邬|伍|武|务|西|席|夏|咸|向|项|萧|谢|辛|邢|幸|熊|徐|许|轩|宣|薛|荀|闫|严|言|阎|颜|晏|燕|杨|姚|叶|伊|易|殷|尹|应|庸|雍|尤|游|于|余|俞|虞|元|袁|岳|云|臧|曾|翟|詹|湛|张|章|赵|甄|郑|支|钟|仲|周|朱|诸|祝|庄|卓|子|宗|邹|祖|左" +
		")"
	ChineseNamePattern    = "(?:" + ChineseSurnames + ")[\u4e00-\u9fa5]{1,5}"                                     // 中文姓名:百家姓+名字
	ChineseIDCardPattern  = "[1-9]\\d{5}(?:18|19|20)\\d{2}(?:0[1-9]|1[0-2])(?:0[1-9]|[12]\\d|3[01])\\d{3}[\\dXx]" // 身份证
	PassportPattern       = "[a-zA-Z][0-9]{9}"                                                                    // 护照号
	SocialSecurityPattern = "[1-9]\\d{17}[\\dXx]"                                                                 // 社会保障号
	DriversLicensePattern = "[1-9]\\d{5}[a-zA-Z]\\d{6}"                                                           // 驾驶证号

	// 联系方式
	MobilePhonePattern = "(?:(?:\\+|00)86)?1(?:(?:3[\\d])|(?:4[5-79])|(?:5[0-35-9])|(?:6[5-7])|(?:7[0-8])|(?:8[\\d])|(?:9[189]))\\d{8}" // 手机号
	FixedPhonePattern  = "(?:[\\d]{3,4}-)?[\\d]{7,8}(?:-[\\d]{1,4})?"                                                                   // 固定电话
	EmailPattern       = `[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}`                                                               // 电子邮箱

	// 地址信息
	AddressPattern = "" // 详细地址
	/* 142-byte string literal not displayed */
	PostalCodePattern = `[1-9]\d{5}([^\d]|$)` // 邮政编码

	// 金融信息
	BankCardPattern   = `(?:(?:4\d{12}(?:\d{3})?)|(?:5[1-5]\d{14})|(?:6(?:011|5\d{2})\d{12})|(?:3[47]\d{13})|(?:(?:30[0-5]|36\d|38\d)\d{11}))` // 银行卡
	CreditCardPattern = ``                                                                                                                     // 信用卡
	/* 147-byte string literal not displayed */

	// 网络标识
	IPv4Pattern = `(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)` // IPv4
	IPv6Pattern = ""                                                                                          /* 661-byte string literal not displayed */
	MACPattern  = `(?:[0-9A-Fa-f]{2}[:-]){5}[0-9A-Fa-f]{2}`                                                   // MAC地址
	IMEIPattern = `\d{15,17}`                                                                                 // IMEI号

	// 车辆信息
	LicensePlatePattern = `` // 车牌号
	/* 154-byte string literal not displayed */
	VINPattern = `[A-HJ-NPR-Z0-9]{17}` // 车架号

	// 密钥和令牌
	APIKeyPattern      = `[a-zA-Z0-9]{32,}`                                         // API密钥
	JWTPattern         = `eyJ[A-Za-z0-9-_=]+\.[A-Za-z0-9-_=]+\.?[A-Za-z0-9-_.+/=]*` // JWT令牌
	AccessTokenPattern = `[a-zA-Z0-9]{40,}`                                         // 访问令牌

	// 设备标识
	DeviceIDPattern = `[A-F0-9]{8}-[A-F0-9]{4}-[A-F0-9]{4}-[A-F0-9]{4}-[A-F0-9]{12}`                // 设备ID
	UUIDPattern     = `[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}` // UUID

	// 加密哈希
	MD5Pattern    = `[a-fA-F0-9]{32}` // MD5哈希
	SHA1Pattern   = `[a-fA-F0-9]{40}` // SHA1哈希
	SHA256Pattern = `[a-fA-F0-9]{64}` // SHA256哈希

	// 其他标识
	LatLngPattern = `[-+]?([1-8]?\d(\.\d+)?|90(\.0+)?),\s*[-+]?(180(\.0+)?|((1[0-7]\d)|([1-9]?\d))(\.\d+)?)` // 经纬度

	// URL和域名
	URLPattern    = ``                                                                           /* 292-byte string literal not displayed */
	DomainPattern = `(?:[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?\.)+[a-z0-9][a-z0-9-]{0,61}[a-z0-9]` // 域名

	// 敏感内容
	PasswordPattern = `^[a-zA-Z]\w{5,17}$` // 密码(以字母开头,长度在6~18之间,只能包含字母、数字和下划线)
	// PasswordPattern,增加特殊字符要求
	// PasswordPattern = `^(?=.*[A-Za-z])(?=.*\d)(?=.*[@$!%*#?&])[A-Za-z\d@$!%*#?&]{8,}$`
	UsernamePattern = `[a-zA-Z0-9_-]{3,16}` // 用户名

	// 证件号码
	MedicalIDPattern = `[1-9]\d{7}`  // 医保卡号
	CompanyIDPattern = `[1-9]\d{14}` // 统一社会信用代码

	// 金融相关
	IBANPattern  = `[A-Z]{2}\d{2}[A-Z0-9]{4}\d{7}([A-Z\d]?){0,16}` // IBAN号码
	SwiftPattern = `[A-Z]{6}[A-Z0-9]{2}([A-Z0-9]{3})?`             // SWIFT代码

	// 代码相关
	GitRepoPattern = `(?:git|ssh|git@[\w\.]+)(?::(\/\/)?)([\w\.@\:/\-~]+)(\.git)(\/)?` // Git仓库

)

Variables

View Source
var (
	ErrInvalidMatcher = errors.New("invalid matcher configuration")
	ErrNotStruct      = errors.New("input must be a struct")
)
View Source
var (
	ChineseNameRegex    *regexp.Regexp
	ChineseIDCardRegex  *regexp.Regexp
	PassportRegex       *regexp.Regexp
	SocialSecurityRegex *regexp.Regexp
	DriversLicenseRegex *regexp.Regexp
	MobilePhoneRegex    *regexp.Regexp
	FixedPhoneRegex     *regexp.Regexp
	EmailRegex          *regexp.Regexp
	AddressRegex        *regexp.Regexp
	PostalCodeRegex     *regexp.Regexp
	BankCardRegex       *regexp.Regexp
	CreditCardRegex     *regexp.Regexp
	IPv4Regex           *regexp.Regexp
	IPv6Regex           *regexp.Regexp
	MACRegex            *regexp.Regexp
	IMEIRegex           *regexp.Regexp
	LicensePlateRegex   *regexp.Regexp
	VINRegex            *regexp.Regexp
	APIKeyRegex         *regexp.Regexp
	JWTRegex            *regexp.Regexp
	AccessTokenRegex    *regexp.Regexp
	DeviceIDRegex       *regexp.Regexp
	UUIDRegex           *regexp.Regexp
	MD5Regex            *regexp.Regexp
	SHA1Regex           *regexp.Regexp
	SHA256Regex         *regexp.Regexp
	LatLngRegex         *regexp.Regexp
	URLRegex            *regexp.Regexp
	DomainRegex         *regexp.Regexp
	PasswordRegex       *regexp.Regexp
	UsernameRegex       *regexp.Regexp
	MedicalIDRegex      *regexp.Regexp
	CompanyIDRegex      *regexp.Regexp
	IBANRegex           *regexp.Regexp
	SwiftRegex          *regexp.Regexp
	GitRepoRegex        *regexp.Regexp
)

Functions

func APIKeyDesensitize added in v0.0.18

func APIKeyDesensitize(key string) string

APIKeyDesensitize 处理API密钥,隐藏前面部分

func AccessTokenDesensitize added in v0.0.18

func AccessTokenDesensitize(token string) string

AccessTokenDesensitize 访问令牌脱敏

func AddressDesensitize added in v0.0.18

func AddressDesensitize(address string) string

AddressDesensitize 地址脱敏

func AesDesensitize added in v0.0.18

func AesDesensitize(data, key []byte) (string, error)

AesDesensitize AES加密脱敏方法

func BankCardDesensitize added in v0.0.18

func BankCardDesensitize(card string) string

BankCardDesensitize 银行卡脱敏,保留前6位和后4位,中间用*代替

func Base64Desensitize added in v0.0.18

func Base64Desensitize(data string) string

Base64Desensitize Base64编码脱敏方法

func BiographyDesensitize added in v0.0.18

func BiographyDesensitize(bio string) string

BiographyDesensitize 个人简介脱敏

func CertificateDesensitize added in v0.0.18

func CertificateDesensitize(cert string) string

CertificateDesensitize 证书脱敏

func ChineseIDCardDesensitize added in v0.0.18

func ChineseIDCardDesensitize(id string) bool

ChineseIDCardDesensitize 验证中国身份证号

func ChineseNameDesensitize added in v0.0.18

func ChineseNameDesensitize(name string) string

ChineseNameDesensitize 中文姓名脱敏

func ClearToEmptyDesensitize added in v0.0.18

func ClearToEmptyDesensitize(_ string) string

ClearToEmptyDesensitize 清空为空字符串的脱敏实现

func ClearToNullDesensitize added in v0.0.18

func ClearToNullDesensitize(_ string) string

ClearToNullDesensitize 清空为null的脱敏实现

func CommentDesensitize added in v0.0.18

func CommentDesensitize(comment string) string

CommentDesensitize 评论内容脱敏

func CompanyIDDesensitize added in v0.0.18

func CompanyIDDesensitize(id string) string

CompanyIDDesensitize 公司编号(统一信用代码)脱敏

func CoordinateDesensitize added in v0.0.18

func CoordinateDesensitize(coord string) string

CoordinateDesensitize 地理坐标脱敏

func CreditCardDesensitize added in v0.0.18

func CreditCardDesensitize(card string) string

CreditCardDesensitize 处理信用卡号,只显示后四位

func CustomizeKeepLengthDesensitize added in v0.0.18

func CustomizeKeepLengthDesensitize(data string, preKeep, postKeep int) string

CustomizeKeepLengthDesensitize 自定义保留长度的脱敏

func DesDesensitize added in v0.0.18

func DesDesensitize(data string, key []byte) (string, error)

DesDesensitize DES加密脱敏方法

func DeviceIDDesensitize added in v0.0.18

func DeviceIDDesensitize(id string) string

DeviceIDDesensitize 设备ID脱敏

func DomainDesensitize added in v0.0.18

func DomainDesensitize(domain string) string

DomainDesensitize 处理域名,隐藏前面部分

func DriversLicenseDesensitize added in v0.0.18

func DriversLicenseDesensitize(license string) string

DriversLicenseDesensitize 驾驶证号脱敏

func EmailDesensitize added in v0.0.18

func EmailDesensitize(email string) string

EmailDesensitize 邮箱脱敏,隐藏用户名中间3位,域名不打码

func FirstMaskDesensitize added in v0.0.18

func FirstMaskDesensitize(data string) string

FirstMaskDesensitize 仅保留首字符脱敏

func FixedPhoneDesensitize added in v0.0.18

func FixedPhoneDesensitize(phone string) string

FixedPhoneDesensitize 固定电话脱敏

func IMEIDesensitize added in v0.0.18

func IMEIDesensitize(imei string) string

IMEIDesensitize IMEI号脱敏

func IPv4Desensitize added in v0.0.18

func IPv4Desensitize(ip string) string

IPv4Desensitize IPv4地址脱敏

func IPv6Desensitize added in v0.0.18

func IPv6Desensitize(ip string) string

IPv6Desensitize IPv6地址脱敏

func IdCardDesensitize added in v0.0.18

func IdCardDesensitize(idCard string) string

IdCardDesensitize 身份证脱敏

func JWTDesensitize added in v0.0.18

func JWTDesensitize(token string) string

JWTDesensitize JWT令牌脱敏

func LatLngDesensitize added in v0.0.18

func LatLngDesensitize(latLng string) string

LatLngDesensitize 处理经纬度,隐藏具体数值

func LicensePlateDesensitize added in v0.0.21

func LicensePlateDesensitize(license string) string

LicensePlateDesensitize 车牌号脱敏

func MACDesensitize added in v0.0.18

func MACDesensitize(mac string) string

MACDesensitize MAC地址脱敏

func MD5Desensitize added in v0.0.18

func MD5Desensitize(input string) string

MD5Desensitize 计算输入的MD5哈希值并返回

func MaskString added in v0.0.18

func MaskString(str string, start, end int, maskChar string) string

MaskString 字符串遮罩处理

func MedicalIDDesensitize added in v0.0.18

func MedicalIDDesensitize(id string) string

MedicalIDDesensitize 医保卡号脱敏

func MobilePhoneDesensitize added in v0.0.18

func MobilePhoneDesensitize(phone string) string

MobilePhoneDesensitize 手机号脱敏

func NicknameDesensitize added in v0.0.18

func NicknameDesensitize(nickname string) string

NicknameDesensitize 昵称脱敏

func PassportDesensitize added in v0.0.18

func PassportDesensitize(passport string) string

PassportDesensitize 护照号脱敏

func PasswordDesensitize added in v0.0.18

func PasswordDesensitize(password string) string

PasswordDesensitize 密码脱敏

func PostalCodeDesensitize added in v0.0.18

func PostalCodeDesensitize(code string) string

PostalCodeDesensitize 处理邮政编码,隐藏中间三位

func PrivateKeyDesensitize added in v0.0.18

func PrivateKeyDesensitize(_ string) string

PrivateKeyDesensitize 私钥脱敏

func ProcessSensitiveData added in v0.0.18

func ProcessSensitiveData(v interface{}) error

ProcessSensitiveData 处理结构体的脱敏

func PublicKeyDesensitize added in v0.0.18

func PublicKeyDesensitize(key string) string

PublicKeyDesensitize 公钥脱敏

func RefreshTokenDesensitize added in v0.0.18

func RefreshTokenDesensitize(token string) string

RefreshTokenDesensitize 刷新令牌脱敏

func RegisterURLSensitiveParams added in v0.0.18

func RegisterURLSensitiveParams(params ...string)

RegisterURLSensitiveParams 添加自定义的URL参数脱敏规则

func RsaDesensitize added in v0.0.18

func RsaDesensitize(data []byte, publicKey *rsa.PublicKey) (string, error)

RsaDesensitize RSA加密脱敏方法

func SHA1Desensitize added in v0.0.18

func SHA1Desensitize(input string) string

SHA1Desensitize 计算输入的SHA1哈希值并返回

func SHA256Desensitize added in v0.0.18

func SHA256Desensitize(input string) string

SHA256Desensitize 处理输入,返回 SHA-256 哈希值

func SignatureDesensitize added in v0.0.18

func SignatureDesensitize(signature string) string

SignatureDesensitize 个性签名脱敏

func SocialSecurityDesensitize added in v0.0.18

func SocialSecurityDesensitize(ssn string) string

SocialSecurityDesensitize 社会保障号脱敏

func StringDesensitize added in v0.0.18

func StringDesensitize(data string, filterWords ...string) string

StringDesensitize 字符串脱敏

func URLDesensitize added in v0.0.18

func URLDesensitize(rawURL string) string

URLDesensitize URL脱敏实现

func UUIDDesensitize added in v0.0.18

func UUIDDesensitize(uuid string) string

UUIDDesensitize 处理UUID,隐藏中间部分

func UsernameDesensitize added in v0.0.18

func UsernameDesensitize(username string) string

UsernameDesensitize 用户名脱敏,显示前后两位

func VINDesensitize added in v0.0.18

func VINDesensitize(vin string) string

VINDesensitize 车架号脱敏

Types

type DesensitizeFunc added in v0.0.18

type DesensitizeFunc func(string) string

DesensitizeFunc 定义脱敏函数类型

type DlpConfig added in v0.0.18

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

func GetConfig added in v0.0.18

func GetConfig() *DlpConfig

GetConfig 获取全局配置实例

func (*DlpConfig) Disable added in v0.0.18

func (c *DlpConfig) Disable()

Disable 禁用脱敏功能

func (*DlpConfig) Enable added in v0.0.18

func (c *DlpConfig) Enable()

Enable 启用脱敏功能

func (*DlpConfig) GetStrategy added in v0.0.18

func (c *DlpConfig) GetStrategy(name string) (DesensitizeFunc, bool)

GetStrategy 获取脱敏策略

func (*DlpConfig) IsEnabled added in v0.0.18

func (c *DlpConfig) IsEnabled() bool

IsEnabled 检查脱敏功能是否启用

func (*DlpConfig) RegisterStrategy added in v0.0.18

func (c *DlpConfig) RegisterStrategy(name string, strategy DesensitizeFunc)

RegisterStrategy 注册自定义脱敏策略

type DlpEngine added in v0.0.18

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

DlpEngine 定义脱敏引擎结构体

func NewDlpEngine added in v0.0.18

func NewDlpEngine() *DlpEngine

NewDlpEngine 创建新的DLP引擎实例

func (*DlpEngine) DesensitizeSpecificType added in v0.0.18

func (e *DlpEngine) DesensitizeSpecificType(text string, sensitiveType string) string

DesensitizeSpecificType 对指定类型的敏感信息进行脱敏

func (*DlpEngine) DesensitizeStruct added in v0.0.18

func (e *DlpEngine) DesensitizeStruct(data interface{}) error

DesensitizeStruct 对结构体进行脱敏处理

func (*DlpEngine) DesensitizeText added in v0.0.18

func (e *DlpEngine) DesensitizeText(text string) string

DesensitizeText 对文本进行脱敏处理

func (*DlpEngine) DetectSensitiveInfo added in v0.0.18

func (e *DlpEngine) DetectSensitiveInfo(text string) map[string][]MatchResult

DetectSensitiveInfo 检测文本中的所有敏感信息

func (*DlpEngine) Disable added in v0.0.18

func (e *DlpEngine) Disable()

Disable 禁用DLP引擎

func (*DlpEngine) Enable added in v0.0.18

func (e *DlpEngine) Enable()

Enable 启用DLP引擎

func (*DlpEngine) GetSupportedTypes added in v0.0.18

func (e *DlpEngine) GetSupportedTypes() []string

GetSupportedTypes 获取所有支持的敏感信息类型

func (*DlpEngine) IsEnabled added in v0.0.18

func (e *DlpEngine) IsEnabled() bool

IsEnabled 检查DLP引擎是否启用

func (*DlpEngine) RegisterCustomMatcher added in v0.0.18

func (e *DlpEngine) RegisterCustomMatcher(matcher *Matcher) error

RegisterCustomMatcher 注册自定义匹配器

type MatchResult added in v0.0.18

type MatchResult struct {
	Type     string // 匹配类型
	Content  string // 匹配内容
	Position [2]int // 匹配位置 [start, end]
}

MatchResult 定义匹配结果结构体

type Matcher added in v0.0.18

type Matcher struct {
	Name        string              // 匹配器名称
	Pattern     string              // 正则表达式模式
	Regex       *regexp.Regexp      // 编译后的正则表达式
	Validator   func(string) bool   // 验证函数
	Transformer func(string) string // 转换函数
	Priority    int                 // 优先级,数字越大优先级越高
	Complexity  int                 // 正则表达式复杂度评分
}

Matcher 定义匹配器结构体

type RegexSearcher added in v0.0.18

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

RegexSearcher 定义正则搜索器

func NewRegexSearcher added in v0.0.18

func NewRegexSearcher() *RegexSearcher

NewRegexSearcher 创建新的正则搜索器

func (*RegexSearcher) AddMatcher added in v0.0.18

func (s *RegexSearcher) AddMatcher(matcher *Matcher) error

AddMatcher 添加新的匹配器

func (*RegexSearcher) GetAllSupportedTypes added in v0.0.18

func (s *RegexSearcher) GetAllSupportedTypes() []string

GetAllSupportedTypes 获取所有支持的敏感信息类型

func (*RegexSearcher) GetMatcher added in v0.0.18

func (s *RegexSearcher) GetMatcher(name string) *Matcher

GetMatcher 获取指定名称的匹配器

func (*RegexSearcher) Match added in v0.0.18

func (s *RegexSearcher) Match(text string) []MatchResult

Match 执行匹配操作

func (*RegexSearcher) RemoveMatcher added in v0.0.18

func (s *RegexSearcher) RemoveMatcher(name string)

RemoveMatcher 移除匹配器

func (*RegexSearcher) ReplaceParallel added in v0.0.18

func (s *RegexSearcher) ReplaceParallel(text string, matchType string) string

ReplaceParallel 并行处理敏感信息替换

func (*RegexSearcher) SearchSensitiveByType added in v0.0.18

func (s *RegexSearcher) SearchSensitiveByType(text string, typeName string) []MatchResult

SearchSensitiveByType 按类型搜索敏感信息

func (*RegexSearcher) UpdateMatcher added in v0.0.18

func (s *RegexSearcher) UpdateMatcher(name string, pattern string, validator func(string) bool, transformer func(string) string) error

UpdateMatcher 更新匹配器

type Sensitive added in v0.0.18

type Sensitive struct {
	Name           string `dlp:"chinese_name" json:"name,omitempty"`               // 姓名
	IdCard         string `dlp:"id_card" json:"id_card,omitempty"`                 // 身份证
	FixedPhone     string `dlp:"landline" json:"landline,omitempty"`               // 固定电话
	MobilePhone    string `dlp:"mobile" json:"mobile,omitempty"`                   // 手机号
	Address        string `dlp:"address" json:"address,omitempty"`                 // 地址
	Email          string `dlp:"email" json:"email,omitempty"`                     // 邮箱
	Password       string `dlp:"password" json:"password,omitempty"`               // 密码
	LicensePlate   string `dlp:"plate" json:"plate,omitempty"`                     // 车牌
	BankCard       string `dlp:"bank_card" json:"bank_card,omitempty"`             // 银行卡
	CreditCard     string `dlp:"credit_card" json:"credit_card,omitempty"`         // 信用卡
	Ipv4           string `dlp:"ipv4" json:"ipv_4,omitempty"`                      // IPv4
	Ipv6           string `dlp:"ipv6" json:"ipv_6,omitempty"`                      // IPv6
	Base64         string `dlp:"base64" json:"base_64,omitempty"`                  // Base64编码
	URL            string `dlp:"url" json:"url,omitempty"`                         // URL
	FirstMask      string `dlp:"first_mask" json:"first_mask,omitempty"`           // 仅保留首字符
	ClearToNull    string `dlp:"null" json:"null,omitempty"`                       // 清空为null
	ClearToEmpty   string `dlp:"empty" json:"empty,omitempty"`                     // 清空为空字符串
	JWT            string `dlp:"jwt" json:"jwt,omitempty"`                         // JWT令牌
	SocialSecurity string `dlp:"social_security" json:"social_security,omitempty"` // 社会保障号
	Passport       string `dlp:"passport" json:"passport,omitempty"`               // 护照号
	DriversLicense string `dlp:"license_number" json:"license_number,omitempty"`   // 驾驶证号
	MedicalID      string `dlp:"medical_id" json:"medical_id,omitempty"`           // 医保卡号
	CompanyID      string `dlp:"company_id" json:"company_id,omitempty"`           // 公司编号
	DeviceID       string `dlp:"device_id" json:"device_id,omitempty"`             // 设备ID
	MAC            string `dlp:"mac" json:"mac,omitempty"`                         // MAC地址
	VIN            string `dlp:"vin" json:"vin,omitempty"`                         // 车架号
	IMEI           string `dlp:"imei" json:"imei,omitempty"`                       // IMEI号
	Coordinate     string `dlp:"coordinate" json:"coordinate,omitempty"`           // 地理坐标
	AccessToken    string `dlp:"access_token" json:"access_token,omitempty"`       // 访问令牌
	RefreshToken   string `dlp:"refresh_token" json:"refresh_token,omitempty"`     // 刷新令牌
	PrivateKey     string `dlp:"private_key" json:"private_key,omitempty"`         // 私钥
	PublicKey      string `dlp:"public_key" json:"public_key,omitempty"`           // 公钥
	Certificate    string `dlp:"certificate" json:"certificate,omitempty"`         // 证书
	Username       string `dlp:"username" json:"username,omitempty"`               // 用户名
	Nickname       string `dlp:"nickname" json:"nickname,omitempty"`               // 昵称
	Biography      string `dlp:"biography" json:"biography,omitempty"`             // 个人简介
	Signature      string `dlp:"signature" json:"signature,omitempty"`             // 个性签名
	Comment        string `dlp:"comment" json:"comment,omitempty"`                 // 评论内容
}

Sensitive 定义敏感信息结构体

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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