Documentation ¶
Index ¶
- Constants
- Variables
- type ExtraConfig
- type MatchAction
- type MatchActionType
- type PartialRedactionDirection
- type ProximityKeywordsConfig
- type Rule
- func NewHashRule(id string, pattern string, extraConfig ExtraConfig) Rule
- func NewMatchingRule(id string, pattern string, extraConfig ExtraConfig) Rule
- func NewPartialRedactRule(id string, pattern string, characterCount uint32, ...) Rule
- func NewRedactingRule(id string, pattern string, redactionValue string, extraConfig ExtraConfig) Rule
- type RuleMatch
- type ScanResult
- type Scanner
- type SecondaryValidator
Constants ¶
const ( MatchActionNone = MatchActionType("None") MatchActionRedact = MatchActionType("Redact") MatchActionHash = MatchActionType("Hash") MatchActionPartialRedact = MatchActionType("PartialRedact") )
const ( LuhnChecksum = SecondaryValidator("LuhnChecksum") ChineseIdChecksum = SecondaryValidator("ChineseIdChecksum") )
const ( FirstCharacters = PartialRedactionDirection("FirstCharacters") LastCharacters = PartialRedactionDirection("LastCharacters") )
Variables ¶
Functions ¶
This section is empty.
Types ¶
type ExtraConfig ¶
type ExtraConfig struct { ProximityKeywords *ProximityKeywordsConfig SecondaryValidator SecondaryValidator }
ExtraConfig is used to provide more configuration while creating the rules.
type MatchAction ¶
type MatchAction struct { Type MatchActionType // used when Type == MatchActionRedact, empty otherwise RedactionValue string // used when Type == MatchActionPartialRedact, empty otherwise CharacterCount uint32 // used when Type == MatchActionPartialRedact, empty otherwise Direction PartialRedactionDirection }
MatchAction is used to configure the rules.
func (MatchAction) MarshalJSON ¶
func (m MatchAction) MarshalJSON() ([]byte, error)
MarshalJSON marshals the MatchAction in a format understood by the serde rust JSON library.
type MatchActionType ¶
type MatchActionType string
type PartialRedactionDirection ¶
type PartialRedactionDirection string
type ProximityKeywordsConfig ¶
type ProximityKeywordsConfig struct { LookAheadCharacterCount uint32 `json:"look_ahead_character_count"` IncludedKeywords []string `json:"included_keywords"` ExcludedKeywords []string `json:"excluded_keywords"` }
ProximityKeywordsConfig represents the proximity keyword matching for the core library.
func CreateProximityKeywordsConfig ¶
func CreateProximityKeywordsConfig(lookAheadCharaceterCount uint32, includedKeywords []string, excludedKeywords []string) *ProximityKeywordsConfig
CreateProximityKeywordsConfig creates a ProximityKeywordsConfig.
type Rule ¶
type Rule struct { Id string `json:"id"` Pattern string `json:"pattern"` MatchAction MatchAction `json:"match_action"` ProximityKeywords *ProximityKeywordsConfig `json:"proximity_keywords,omitempty"` SecondaryValidator SecondaryValidator `json:"validator,omitempty"` }
Rule is sent to the core library to create scanners.
func NewHashRule ¶
func NewHashRule(id string, pattern string, extraConfig ExtraConfig) Rule
NewHashRule returns a matching rule redacting with hashes.
func NewMatchingRule ¶
func NewMatchingRule(id string, pattern string, extraConfig ExtraConfig) Rule
NewMatchingRule returns a matching rule with no match _action_.
func NewPartialRedactRule ¶
func NewPartialRedactRule(id string, pattern string, characterCount uint32, direction PartialRedactionDirection, extraConfig ExtraConfig) Rule
NewPartialRedactRule returns a matching rule partially redacting matches.
func NewRedactingRule ¶
func NewRedactingRule(id string, pattern string, redactionValue string, extraConfig ExtraConfig) Rule
NewRedactingRule returns a matching rule redacting events.
type RuleMatch ¶
type RuleMatch struct { RuleIdx uint32 // TODO(remy): not implemented yet. Path string ReplacementType MatchAction StartIndex uint32 EndIndexExclusive uint32 ShiftOffset int32 }
RuleMatch stores the matches reported by the core library.
type ScanResult ¶
type ScanResult struct { // String Event contains the event after the scan. // In case of map input it contains the mutated string. (The input event is mutated in place) // If `Mutated` is true: // * it contains the processed event after redaction. // If `Mutated` is false: // * it contains the original event, unchanged. Event []byte // contains filtered or unexported fields }
ScanResult contains a Scan result.
type Scanner ¶
type Scanner struct { // Id of this scanner generated by the SDS library when the scanner is created. Id int64 // They are stored on creation for read-only usage. Rules []Rule }
Scanner wraps an SDS scanner. See `CreateScanner` to create one providing SDS rules. See `Scan`, `ScanEventsList` or a `ScanEventsMap` for usage.
func CreateScanner ¶
CreateScanner creates a scanner in the underlying SDS shared library. The library only returns an ID to then address what scanner to use on Scan calls. This ID is stored in the Scanner Go object for convenience. See `Scan` to process events. The rules used to create the Scanner are stored as a read-only information in the returned Scanner.
func (*Scanner) Delete ¶
func (s *Scanner) Delete()
Delete deletes the instance of the current Scanner. The current Scanner should not be reused.
func (*Scanner) Scan ¶
func (s *Scanner) Scan(event []byte) (ScanResult, error)
Scan sends the string event to the SDS shared library for processing.
func (*Scanner) ScanEventsMap ¶
func (s *Scanner) ScanEventsMap(event map[string]interface{}) (ScanResult, error)
ScanEventsMap sends a map event to the SDS shared library for processing. In case of mutation, event is updated in place. The returned ScanResult contains the mutated string in the Event attribute (not the event)
type SecondaryValidator ¶
type SecondaryValidator string
func (SecondaryValidator) MarshalJSON ¶
func (s SecondaryValidator) MarshalJSON() ([]byte, error)
MarshalJSON marshales the SecondaryValidator.