Documentation
¶
Overview ¶
Package detector implements detector functions
Index ¶
- Constants
- type ContextVerifyFunc
- type Detector
- func (I *Detector) Close()
- func (I *Detector) DetectBytes(inputBytes []byte) ([]*dlpheader.DetectResult, error)
- func (I *Detector) DetectList(kvList []*KVItem) ([]*dlpheader.DetectResult, error)
- func (I *Detector) DetectMap(inputMap map[string]string) ([]*dlpheader.DetectResult, error)
- func (I *Detector) GetMaskRuleName() string
- func (I *Detector) GetRuleID() int32
- func (I *Detector) GetRuleInfo() string
- func (I *Detector) IsKV() bool
- func (I *Detector) IsValue() bool
- func (I *Detector) UseRegex() bool
- type DetectorAPI
- type KVItem
Constants ¶
View Source
const ( RULE_TYPE_VALUE = 0 RULE_TYPE_KV = 1 RESULT_TYPE_VALUE = "VALUE" RESULT_TYPE_KV = "KV" BLACKLIST_ALGO_MASKED = "MASKED" VERIFY_ALGO_IDCARD = "IDCARD" VERIFY_ALGO_ABAROUTING = "ABAROUTING" VERIFY_ALGO_CREDITCARD = "CREDITCARD" VERIFY_ALGO_BITCOIN = "BITCOIN" VERIFY_ALGO_DOMAIN = "DOMAIN" MASKED_CHARLIST = "*#" DEF_RESULT_SIZE = 4 DEF_CONTEXT_RANGE = 32 DEF_IDCARD_LEN = 18 )
RuleType is different with ResultType, bacause for input string contains KV object, KV rule will generate Value Detect Type
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ContextVerifyFunc ¶
type ContextVerifyFunc func(*Detector, []byte, *dlpheader.DetectResult) bool
ContextVerifyFunc defines verify by context function
type Detector ¶
type Detector struct { RuleType int // VALUE if there is no KReg and KDict // Detect section in conf KReg []*regexp.Regexp // regex list for Key KDict map[string]struct{} // Dict for Key VReg []*regexp.Regexp // Regex list for Value VDict []string // Dict for Value // Filter section in conf BAlgo []string // algorithm for blacklist, supports MASKED BDict []string // Dict for blacklist BReg []*regexp.Regexp // Regex list for blacklist // Verify section in conf CDict []string // Dict for Context Verification CReg []*regexp.Regexp // Regex List for Context Verification VAlgo []string // algorithm for Verifycation, such as IDCARD // contains filtered or unexported fields }
func (*Detector) DetectBytes ¶
func (I *Detector) DetectBytes(inputBytes []byte) ([]*dlpheader.DetectResult, error)
DetectBytes detects sensitive info for bytes, is called from Detect()
func (*Detector) DetectList ¶
func (I *Detector) DetectList(kvList []*KVItem) ([]*dlpheader.DetectResult, error)
func (*Detector) GetMaskRuleName ¶
GetMaskRuleName returns MaskRuleName used in Detect Rule
func (*Detector) GetRuleInfo ¶
GetRuleInfo returns rule as string
type DetectorAPI ¶
type DetectorAPI interface { // GetRuleInfo returns rule as string GetRuleInfo() string // GetRuleID returns RuleID GetRuleID() int32 // GetMaskRuleName returns MaskRuleName GetMaskRuleName() string // IsValue checks whether RuleType is VALUE IsValue() bool // IsValue checks whether RuleType is KV IsKV() bool // UseRegex checks whether Rule use Regex UseRegex() bool // DetectBytes detects sensitive info for bytes DetectBytes(inputBytes []byte) ([]*dlpheader.DetectResult, error) // DetectMap detects sensitive info for map DetectMap(inputMap map[string]string) ([]*dlpheader.DetectResult, error) DetectList(kvList []*KVItem) ([]*dlpheader.DetectResult, error) // Close release detector object Close() }
func NewDetector ¶
func NewDetector(ruleItem conf.RuleItem) (DetectorAPI, error)
NewDetector creates detector object from rule
Click to show internal directories.
Click to hide internal directories.