Documentation ¶
Index ¶
Constants ¶
const DefaultReplace = "<REDACTED>"
DefaultReplace is the default string to include in place of matched redactions.
const EmailPattern = `([a-zA-Z0-9_.+-]+)@([a-zA-Z0-9-]+\.[a-zA-Z0-9-.]+)`
EmailPattern is a simple RegEx pattern intended to identify anything that looks like an email address.
const EmailReplace = "REDACTED@REDACTED"
EmailReplace is the default replacement pattern for email addresses. It includes the @ symbol to indicate it was an email address, but otherwise, the remainder of the address is redacted.
Variables ¶
This section is empty.
Functions ¶
func Apply ¶
Apply takes a slice of redactions and a writer + reader, reading everything in and applying redactions in sequential order before writing. Therefore, each Redact that appears earlier in the list takes precedence over later Redacts. It is possible for redactions to collide with one another if a matcher can match with the Replace string of an earlier Redact.
func Bytes ¶
Bytes takes a byte slice and a slice of redactions, and wraps it with a reader and writer to apply the redactions, returning a string back. TODO(mkcp): Speed improvement & out of memory error: JSON responses can be really big, so we're going to have to chunk extremely large byte arrays down.
func JSON ¶
JSON accepts a json map or array and traverses the collections and redacts any strings we find.
func String ¶
String takes a string result and a slice of redactions, and wraps it with a reader and writer to apply the redactions, returning a string back. TODO(mkcp): Speed improvement & out of memory error: JSON responses can be really big, so we're going to have to chunk extremely large strings down.
Types ¶
type Redact ¶
type Redact struct { ID string `json:"ID"` Replace string `json:"replace"` // contains filtered or unexported fields }
func Flatten ¶
Flatten takes any number of slices of redacts and returns one slice containing all redacts in argument order