Documentation
¶
Index ¶
- Constants
- Variables
- func ValidateRegex(regex string) (bool, error)
- type Duration
- type ExtraConfig
- type MatchAction
- type MatchActionType
- type MatchStatus
- type PartialRedactionDirection
- type ProximityKeywordsConfig
- type RegexRuleConfig
- func NewHashRule(id string, pattern string, extraConfig ExtraConfig) RegexRuleConfig
- func NewMatchingRule(id string, pattern string, extraConfig ExtraConfig) RegexRuleConfig
- func NewPartialRedactRule(id string, pattern string, characterCount uint32, ...) RegexRuleConfig
- func NewRedactingRule(id string, pattern string, redactionValue string, extraConfig ExtraConfig) RegexRuleConfig
- type ReplacementType
- type Rule
- type RuleConfig
- type RuleList
- type RuleMatch
- type ScanResult
- type Scanner
- func (s *Scanner) Delete()
- func (s *Scanner) Scan(event []byte) (ScanResult, error)
- func (s *Scanner) ScanEventsMap(event map[string]interface{}) (ScanResult, error)
- func (s *Scanner) ScanEventsMapWithValidation(event map[string]interface{}, withValidateMatching bool) (ScanResult, error)
- func (s *Scanner) ScanWithValidation(event []byte, withValidateMatching bool) (ScanResult, error)
- type SecondaryValidator
- type StatusCodeRange
- type ThirdPartyActiveChecker
- type ThirdPartyActiveCheckerConfig
- type ThirdPartyActiveCheckerConfigAws
- type ThirdPartyActiveCheckerConfigHttp
Constants ¶
const ( MatchActionNone = MatchActionType("None") MatchActionRedact = MatchActionType("Redact") MatchActionHash = MatchActionType("Hash") MatchActionPartialRedact = MatchActionType("PartialRedact") ReplacementTypeNone = ReplacementType("none") ReplacementTypePlaceholder = ReplacementType("placeholder") ReplacementTypeHash = ReplacementType("hash") ReplacementTypePartialStart = ReplacementType("partial_beginning") ReplacementTypePartialEnd = ReplacementType("partial_end") )
const ( LuhnChecksum = SecondaryValidator("LuhnChecksum") ChineseIdChecksum = SecondaryValidator("ChineseIdChecksum") )
const ( FirstCharacters = PartialRedactionDirection("FirstCharacters") LastCharacters = PartialRedactionDirection("LastCharacters") )
const ( // The ordering here is important, values further down the list have a higher priority when merging. MatchStatusNotChecked = MatchStatus("NotChecked") MatchStatusNotAvailable = MatchStatus("NotAvailable") MatchStatusInvalid = MatchStatus("Invalid") MatchStatusError = MatchStatus("Error") MatchStatusValid = MatchStatus("Valid") )
Variables ¶
Functions ¶
func ValidateRegex ¶
Types ¶
type ExtraConfig ¶
type ExtraConfig struct { ProximityKeywords *ProximityKeywordsConfig SecondaryValidator SecondaryValidator ThirdPartyActiveChecker ThirdPartyActiveChecker }
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 MatchStatus ¶
type MatchStatus 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 RegexRuleConfig ¶
type RegexRuleConfig 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"` ThirdPartyActiveChecker ThirdPartyActiveChecker `json:"third_party_active_checker,omitempty"` }
func NewHashRule ¶
func NewHashRule(id string, pattern string, extraConfig ExtraConfig) RegexRuleConfig
NewHashRule returns a matching rule redacting with hashes.
func NewMatchingRule ¶
func NewMatchingRule(id string, pattern string, extraConfig ExtraConfig) RegexRuleConfig
NewMatchingRule returns a matching rule with no match _action_.
func NewPartialRedactRule ¶
func NewPartialRedactRule(id string, pattern string, characterCount uint32, direction PartialRedactionDirection, extraConfig ExtraConfig) RegexRuleConfig
NewPartialRedactRule returns a matching rule partially redacting matches.
func NewRedactingRule ¶
func NewRedactingRule(id string, pattern string, redactionValue string, extraConfig ExtraConfig) RegexRuleConfig
NewRedactingRule returns a matching rule redacting events.
func (RegexRuleConfig) CreateRule ¶
func (c RegexRuleConfig) CreateRule() (*Rule, error)
type ReplacementType ¶
type ReplacementType string
type Rule ¶
type Rule struct {
// contains filtered or unexported fields
}
func CreateRuleFromRawPtr ¶
type RuleConfig ¶
type RuleList ¶
type RuleList struct {
// contains filtered or unexported fields
}
func CreateRuleList ¶
func CreateRuleList() RuleList
func (RuleList) AppendRule ¶
type RuleMatch ¶
type RuleMatch struct { RuleIdx uint32 Path string ReplacementType ReplacementType StartIndex uint32 EndIndexExclusive uint32 ShiftOffset int32 MatchStatus MatchStatus }
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 // Mutated indicates if the processed event has been // mutated or not (e.g. redacted). Mutated bool // Matches contains all rule matches if any. Matches []RuleMatch }
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. RuleConfigs []RuleConfig }
Scanner wraps an SDS scanner. See `CreateScanner` to create one providing SDS rules. See `Scan`, `ScanEventsList` or a `ScanEventsMap` for usage.
func CreateScanner ¶
func CreateScanner(ruleConfigs []RuleConfig) (*Scanner, error)
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. withValidateMatching defaults to false.
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) withValidateMatching defaults to false.
func (*Scanner) ScanEventsMapWithValidation ¶
func (s *Scanner) ScanEventsMapWithValidation(event map[string]interface{}, withValidateMatching bool) (ScanResult, error)
ScanEventsMapWithValidation sends a map event to the SDS shared library for processing with explicit control over match validation. In case of mutation, event is updated in place. The returned ScanResult contains the mutated string in the Event attribute (not the event)
func (*Scanner) ScanWithValidation ¶
func (s *Scanner) ScanWithValidation(event []byte, withValidateMatching bool) (ScanResult, error)
ScanWithValidation sends the string event to the SDS shared library for processing with explicit control over match validation.
type SecondaryValidator ¶
type SecondaryValidator string
func (SecondaryValidator) MarshalJSON ¶
func (s SecondaryValidator) MarshalJSON() ([]byte, error)
MarshalJSON marshales the SecondaryValidator.
type StatusCodeRange ¶
type ThirdPartyActiveChecker ¶
type ThirdPartyActiveChecker struct { Type string `json:"type"` Config ThirdPartyActiveCheckerConfig `json:"config"` }
ThirdPartyActiveChecker is used to validate if a given match is still active or not. It applies well to tokens that have an expiration date for instance.
func (ThirdPartyActiveChecker) MarshalJSON ¶
func (t ThirdPartyActiveChecker) MarshalJSON() ([]byte, error)
MarshalJSON implements custom JSON marshaling to handle empty validation types
type ThirdPartyActiveCheckerConfig ¶
type ThirdPartyActiveCheckerConfig struct { *ThirdPartyActiveCheckerConfigAws *ThirdPartyActiveCheckerConfigHttp }
type ThirdPartyActiveCheckerConfigHttp ¶
type ThirdPartyActiveCheckerConfigHttp struct { Endpoint string `json:"endpoint"` Hosts []string `json:"hosts,omitempty"` Method string `json:"http_method"` RequestHeader map[string]string `json:"request_headers"` ValidHttpStatusCodes []StatusCodeRange `json:"valid_http_status_code"` InvalidHttpStatusCodes []StatusCodeRange `json:"invalid_http_status_code"` Timeout int `json:"timeout_seconds"` }