pii

package
v0.0.0-...-4fc5b5b Latest Latest
Warning

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

Go to latest
Published: Jun 3, 2024 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConcealElements

func ConcealElements(elems []string, safe map[string]struct{}) []string

ConcealElements conceals each element in elems that does not appear in the safe map. A copy of elems containing the changes is returned.

func MapWithPlurals

func MapWithPlurals(ss ...string) map[string]struct{}

MapWithPlurls places the toLower value of each string into a map[string]struct{}, along with a copy of the that string as a plural (ex: FoO => foo, foos).

Types

type SafeURL

type SafeURL struct {
	// the original URL
	URL string
	// path elements that do not need to be hidden
	// keys should be lower-cased
	SafePathElems map[string]struct{}
	// query parameters that do not need to be hidden
	// keys should be lower-cased
	SafeQueryKeys map[string]struct{}
}

SafeURL complies with the clues.Concealer and fmt.Stringer interfaces to produce a safely loggable version of the URL. Path elements that equal a SafePathWords entry will show in plain text. All other path elements will get hashed by clues. Query parameters that match a key in SafeQueryParams will have their values displayed in plain text. All other query parames will get hashed by clues.

func (SafeURL) Conceal

func (u SafeURL) Conceal() string

Conceal produces a string of the url with the sensitive info obscured (hashed or replaced).

func (SafeURL) Format

func (u SafeURL) Format(fs fmt.State, _ rune)

Format ensures the safeURL will output the Conceal() version even when used in a PrintF.

func (SafeURL) PlainString

func (u SafeURL) PlainString() string

func (SafeURL) String

func (u SafeURL) String() string

String complies with Stringer to ensure the Conceal() version of the url is printed anytime it gets transformed to a string.

Jump to

Keyboard shortcuts

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