pii

package module
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: May 16, 2023 License: AGPL-3.0 Imports: 3 Imported by: 1

README

pii

PII Searching

Description

pii is a small library and command line utility that aims to make detecting PII a little easier for security analysts by doing the following:

  • Attempts to standardize well-known PII regular expressions to avoid discrepencies
  • Allows the creation of combinatorial logic around multiple regular expressions for more granularity
  • Proccesses files in parallel, giving performance enhancements over Python / Ruby / etc.
  • Is written as a library allowing for easy integration into existing Go tools

The tool is very much evolving as people contribute. This is one of those tools that should get better over time as improvements are made and the patterns are tuned even further.

Installation

go get github.com/gen0cide/pii/cmd/pii

Usage

pii search foo.txt
Options
  • pii -j/--json will output the data in JSON format.
  • pii search --find-matches will attempt to extract the findings from the files (expirimental)
Contact

Twitter: @alexlevinson

Slack: LOTR Slack (gandalf, #pii)

Documentation

Index

Constants

View Source
const Version = `0.0.1`

Version represents the version of the PII library

Variables

View Source
var (
	// DefaultRuleSet provides a rule set of default PII rules
	DefaultRuleSet = RuleSet{
		"phone_number":   defaultPhoneRule,
		"ssn":            defaultSSNRule,
		"email_address":  defaultEmailRule,
		"ip_address":     defaultIPRule,
		"credit_card":    defaultCreditCardRule,
		"street_address": defaultAddressRule,
		"banking_info":   defaultBankInfoRule,
		"uuid":           defaultUUIDRule,
		"vin":            defaultVINRule,
	}
)

Functions

func ExportAddresses

func ExportAddresses(s string) (matches []string)

ExportAddresses is not really working - disregard for the meantime.

func ExportBankInfos

func ExportBankInfos(s string) (matches []string)

ExportBankInfos attempts to extract all bank info matches from a string

func ExportCreditCards

func ExportCreditCards(s string) (matches []string)

ExportCreditCards attempts to extract all credit card numbers from a string

func ExportEmails

func ExportEmails(s string) (matches []string)

ExportEmails attempts to extract all email address matches from a string

func ExportIPs

func ExportIPs(s string) (matches []string)

ExportIPs attempts to extract all IP Address matches from a string

func ExportLinks(s string) (matches []string)

ExportLinks attempts to grab all links and URLs from a string

func ExportPhones

func ExportPhones(s string) (matches []string)

ExportPhones attempts to extract all phone matches from a string

func ExportSSNs

func ExportSSNs(s string) (matches []string)

ExportSSNs attempts to extract all SSN and India PAN number matches from a string

func ExportUUIDs

func ExportUUIDs(s string) (matches []string)

ExportUUIDs attempts to extract all UUID matches from a string

func ExportVINs

func ExportVINs(s string) (matches []string)

ExportVINs attempts to extract all VIN matches from a string

Types

type Exporter

type Exporter func(s string) []string

Exporter is an extraction helper function to pull features matched by a Matcher

type Matcher

type Matcher func(string) bool

Matcher is an evaluation type

func Address

func Address() Matcher

Address returns a matcher for identifying street address, po boxes, and zip codes

func All

func All(funcs ...Matcher) Matcher

All returns a meta-matcher that requires all supplied matchers evaluate to true

func And

func And(a, b Matcher) Matcher

And creates a meta matcher for requiring a logical AND between supplied matchers

func Any

func Any(funcs ...Matcher) Matcher

Any creates a meta matcher for any possible hits against a set of matchers

func AtLeastN

func AtLeastN(n int, funcs ...Matcher) Matcher

AtLeastN creates an at least n rule against a set of matchers

func BankInfo

func BankInfo() Matcher

BankInfo returns a matcher for identifying either IBANs or US Routing #s

func CreditCard

func CreditCard() Matcher

CreditCard returns a matcher for identifying major credit card numbers

func Email

func Email() Matcher

Email returns a matcher for identifying email addresses

func HaltLangDetect

func HaltLangDetect() Matcher

HaltLangDetect is a special matcher for preventing language detection from running

func IP

func IP() Matcher

IP returns a matcher for identifying IP addresses

func Link() Matcher

Link returns a matcher for identifying URLs and links that are not emails

func Not

func Not(f Matcher) Matcher

Not is the logical negation of a Matcher

func Or

func Or(a, b Matcher) Matcher

Or creates a meta matcher for performing a logical OR on two matchers

func Phone

func Phone() Matcher

Phone returns a matcher for identifying international phone numbers

func SSN

func SSN() Matcher

SSN returns a matcher for identifying US social security numbers

func UUID

func UUID() Matcher

UUID returns a matcher for identifying GUIDs, UUIDs, v3, v4, and v5

func VIN

func VIN() Matcher

VIN generates a matcher for identifying vehicle identification numbers

type Rule

type Rule struct {
	Name        string   `json:"name,omitempty" csv:"name"`
	Description string   `json:"description,omitempty" csv:"description"`
	Severity    int      `json:"severity,omitempty" csv:"severity"`
	Filter      Matcher  `json:"-"`
	Exporter    Exporter `json:"-"`
}

Rule defines a matching requirement

type RuleSet

type RuleSet map[string]Rule

RuleSet creates a map of multiple rules

func (RuleSet) Hits

func (r RuleSet) Hits(s string) []Rule

Hits enumerates all rules within a ruleset returning any matching rules

Jump to

Keyboard shortcuts

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