Documentation
¶
Index ¶
- Variables
- type AnonymizeOptions
- type AnonymizeStrategy
- type Matcher
- func Address() Matcher
- func All(funcs ...Matcher) Matcher
- func And(a, b Matcher) Matcher
- func Any(funcs ...Matcher) Matcher
- func AtLeastN(n int, funcs ...Matcher) Matcher
- func BankInfo() Matcher
- func BrazilianPII() Matcher
- func CNPJ() Matcher
- func CPF() Matcher
- func CreditCard() Matcher
- func Email() Matcher
- func HaltLangDetect() Matcher
- func IP() Matcher
- func IPv4() Matcher
- func IPv6() Matcher
- func Link() Matcher
- func Not(f Matcher) Matcher
- func Or(a, b Matcher) Matcher
- func Phone() Matcher
- func SSN() Matcher
- func UUID() Matcher
- func VIN() Matcher
- type Rule
- type RuleSet
- type StringTester
- type StringTesterResult
Constants ¶
This section is empty.
Variables ¶
var ( // DefaultRuleSet provides a rule set of default PII rules DefaultRuleSet = RuleSet{ "cpf_number": DefaultCPFRule, "cnpj_number": DefaultCNPJRule, "email_address": DefaultEmailRule, "ip_address": DefaultIPRule, "credit_card": DefaultCreditCardRule, } // DefaultCPFRule is a default rule for Brazilian CPF DefaultCPFRule = Rule{ Name: "brazilian_CPF", Description: "Brazilian CPF", Severity: 3, Filter: CPF(), } // DefaultCNPJRule is a default rule for Brazilian CNPJ DefaultCNPJRule = Rule{ Name: "brazilian_CNPJ", Description: "Brazilian CNPJ", Severity: 3, Filter: CNPJ(), } // DefaultEmailRule is a default rule for email address DefaultEmailRule = Rule{ Name: "email_address", Description: "valid email address", Severity: 3, Filter: Email(), } // DefaultIPRule is a default rule for IP address DefaultIPRule = Rule{ Name: "ip_address", Description: "valid IPv4 address", Severity: 2, Filter: IPv4(), } // DefaultCreditCardRule is a default rule for credit card number DefaultCreditCardRule = Rule{ Name: "credit_card", Description: "valid credit card number", Severity: 5, Filter: CreditCard(), } )
var DefaultMaskString = "<MASKED>"
DefaultMaskString is used to mask matches. It's useful when should report leaks on security alerts
var DefaultRedactString = "<REDACTED>"
DefaultRedactString is used to redact matches. It's useful when should report leaks on security alerts
Functions ¶
This section is empty.
Types ¶
type AnonymizeOptions ¶ added in v0.2.0
type AnonymizeOptions struct {
Strategy AnonymizeStrategy
AnonymizeString string
AnonymizeLength int
}
AnonymizeOptions defines the options for anonymizing a finding
type AnonymizeStrategy ¶ added in v0.2.0
type AnonymizeStrategy int
AnonymizeStrategy defines the strategy for anonymizing a finding
const ( // REDACT is the strategy for redacting a finding REDACT AnonymizeStrategy = iota // MASK is the strategy for masking a finding MASK )
type Matcher ¶
Matcher is an evaluation type
func Address ¶
func Address() Matcher
Address returns a matcher for identifying street address, po boxes, and zip codes
func BankInfo ¶
func BankInfo() Matcher
BankInfo returns a matcher for identifying either IBANs or US Routing #s
func BrazilianPII ¶
func BrazilianPII() Matcher
BrazilianPII generates a matcher for identifying Brazilian identification numbers
func CreditCard ¶
func CreditCard() Matcher
CreditCard returns a matcher for identifying major credit card numbers
func HaltLangDetect ¶
func HaltLangDetect() Matcher
HaltLangDetect is a special matcher for preventing language detection from running
func Link ¶
func Link() Matcher
Link returns a matcher for identifying URLs and links that are not emails
type Rule ¶
type Rule struct {
Name string `json:"name,omitempty"`
Description string `json:"description,omitempty"`
Severity int `json:"severity,omitempty"`
Filter Matcher `json:"-"`
Anonymize bool `json:"redact,omitempty"`
AnonymizeOptions AnonymizeOptions `json:"anonymize,omitempty"`
}
Rule defines a matching requirement
type StringTester ¶
type StringTester struct {
Rules []Rule `json:"rules,omitempty"`
}
StringTester defines a test harness for assessment
func NewDefaultStringTester ¶
func NewDefaultStringTester() *StringTester
NewDefaultStringTester creates a new default StringTester object with all default rules included
func NewEmptyStringTester ¶
func NewEmptyStringTester() *StringTester
NewEmptyStringTester returns an empty StringTester object with no rules loaded
func NewStringTester ¶
func NewStringTester(set RuleSet) *StringTester
NewStringTester creates a new StringTester object with all rules included by the user
func (*StringTester) AnonymizeFindings ¶ added in v0.2.0
func (t *StringTester) AnonymizeFindings(s string) (string, bool)
AnonymizeFindings anonymizes all matches within the rules
func (*StringTester) Find ¶
func (t *StringTester) Find(s []string) (StringTesterResult, error)
Find creates a new default StringTesterResult object with all default rules included
func (*StringTester) MaskFindings ¶
func (t *StringTester) MaskFindings(s string) string
MaskFindings masks all matches within the rules
type StringTesterResult ¶
type StringTesterResult struct {
BrazilianCNPJ bool `json:"brazilian_CNPJ"`
BrazilianCPF bool `json:"brazilian_CPF"`
CreditCard bool `json:"credit_card"`
EmailAddress bool `json:"email_address"`
IPAddress bool `json:"ip_address"`
}
StringTesterResult must sync with the DefaultRuleSet TODO: use code generation for this
