Documentation
¶
Index ¶
- type HashByte
- type HashBytes
- type HashFloat
- type HashInt
- type HashRune
- type HashString
- type HashUint
- type HashValue
- type SafeByte
- type SafeBytes
- type SafeFloat
- type SafeFormatter
- type SafeInt
- type SafeMessager
- type SafePrinter
- type SafeRune
- type SafeString
- type SafeUint
- type SafeValue
- type SafeWriter
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type HashByte ¶ added in v1.1.7
type HashByte byte
HashByte represents a byte that should be hashed when redacted.
type HashBytes ¶ added in v1.1.7
type HashBytes []byte
HashBytes represents a byte slice that should be hashed when redacted.
type HashFloat ¶ added in v1.1.7
type HashFloat float64
HashFloat represents a floating-point value that should be hashed when redacted.
type HashInt ¶ added in v1.1.7
type HashInt int64
HashInt represents an integer that should be hashed when redacted.
type HashRune ¶ added in v1.1.7
type HashRune rune
HashRune represents a rune that should be hashed when redacted.
type HashString ¶ added in v1.1.7
type HashString string
HashString represents a string that should be hashed when redacted.
func (HashString) HashValue ¶ added in v1.1.7
func (HashString) HashValue()
HashValue makes HashString a HashValue.
type HashUint ¶ added in v1.1.7
type HashUint uint64
HashUint represents an unsigned integer that should be hashed when redacted.
type HashValue ¶ added in v1.1.7
type HashValue interface {
HashValue()
}
HashValue is a marker interface to be implemented by types whose values should be hashed when redacted, instead of being replaced with the redaction marker.
This allows correlation between log entries while maintaining privacy. The hash is computed during the Redact() call, not at log creation time.
Types implementing this interface should alias base Go types. The hash is applied to the string representation of the value.
type SafeByte ¶ added in v1.1.6
type SafeByte byte
SafeByte represents a byte that is not a sensitive value.
type SafeBytes ¶ added in v1.1.6
type SafeBytes []byte
SafeBytes represents a byte slice that is not a sensitive value.
type SafeFloat ¶
type SafeFloat float64
SafeFloat represents a floating-point value that is not a sensitive value.
type SafeFormatter ¶
type SafeFormatter interface {
// SafeFormat is like the Format method of fmt.Formatter, except
// that it operates using a SafePrinter instead of a fmt.State for
// output.
//
// The verb argument is the control character that defines
// the formatting mode in the surrounding Printf call.
// For example, if this method is called to format %03d,
// the verb is 'd'.
SafeFormat(s SafePrinter, verb rune)
}
SafeFormatter is implemented by object types that want to separate safe and non-safe information when printed out by a Printf-like formatter.
type SafeMessager ¶
type SafeMessager = interface {
SafeMessage() string
}
SafeMessager is an alternative to SafeFormatter used in previous versions of CockroachDB. NB: this interface is obsolete. Use SafeFormatter instead. TODO(knz): Remove this.
type SafePrinter ¶
type SafePrinter interface {
// SafePrinter inherits fmt.State to access format flags, however
// calls to fmt.State's underlying Write() as unsafe.
fmt.State
// SafePrinter provides the SafeWriter interface.
SafeWriter
}
SafePrinter is a stateful helper that abstracts an output stream in the context of printf-like formatting, but with the ability to separate safe and unsafe bits of data.
This package provides one implementation of this using marker delimiters for unsafe data, see markers.go. We would like to aim for alternate implementations to generate more structured formats.
type SafeString ¶
type SafeString string
SafeString represents a string that is not a sensitive value.
type SafeValue ¶
type SafeValue interface {
SafeValue()
}
SafeValue is a marker interface to be implemented by types that alias base Go types and whose natural representation via Printf is always safe for reporting.
This is recognized by the SafePrinter interface as an alternative to SafeFormatter.
It is provided to decorate "leaf" Go types, such as aliases to int.
Typically, a linter enforces that a type can only implement this interface if it aliases a base go type. More complex types should implement SafeFormatter instead.
It is advised to build an automatic process during builds to collect all the types that implement this interface, as well as all uses of this type, and produce a report. Changes to this report should receive maximal amount of scrutiny during code reviews.
type SafeWriter ¶
type SafeWriter interface {
// SafeString emits a safe string.
SafeString(SafeString)
// SafeInt emits a safe integer.
SafeInt(SafeInt)
// SafeUint emits a safe unsigned integer.
SafeUint(SafeUint)
// SafeFloat emits a safe floating-point value.
SafeFloat(SafeFloat)
// SafeRune emits a safe rune.
SafeRune(SafeRune)
// SafeByte emits a safe byte.
SafeByte(SafeByte)
// SafeBytes emits a safe byte slice.
SafeBytes(SafeBytes)
// Print emits its arguments separated by spaces.
// For each argument it dynamically checks for the SafeFormatter or
// SafeValue interface and either use that, or mark the argument
// payload as unsafe.
Print(args ...interface{})
// For printf, a linter checks that the format string is
// a constant literal, so the implementation can assume it's always
// safe.
Printf(format string, arg ...interface{})
// UnsafeString writes an unsafe string.
UnsafeString(string)
// UnsafeByte writes an unsafe byte.
UnsafeByte(byte)
// UnsafeBytes writes an unsafe byte slice.
UnsafeBytes([]byte)
// UnsafeRune writes an unsafe rune.
UnsafeRune(rune)
}
SafeWriter provides helper functions for use in implementations of SafeFormatter, to format mixes of safe and unsafe strings.