interfaces

package
v1.1.7 Latest Latest
Warning

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

Go to latest
Published: Mar 4, 2026 License: Apache-2.0 Imports: 1 Imported by: 8

Documentation

Index

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.

func (HashByte) HashValue added in v1.1.7

func (HashByte) HashValue()

HashValue makes HashByte a HashValue.

type HashBytes added in v1.1.7

type HashBytes []byte

HashBytes represents a byte slice that should be hashed when redacted.

func (HashBytes) HashValue added in v1.1.7

func (HashBytes) HashValue()

HashValue makes HashBytes a HashValue.

type HashFloat added in v1.1.7

type HashFloat float64

HashFloat represents a floating-point value that should be hashed when redacted.

func (HashFloat) HashValue added in v1.1.7

func (HashFloat) HashValue()

HashValue makes HashFloat a HashValue.

type HashInt added in v1.1.7

type HashInt int64

HashInt represents an integer that should be hashed when redacted.

func (HashInt) HashValue added in v1.1.7

func (HashInt) HashValue()

HashValue makes HashInt a HashValue.

type HashRune added in v1.1.7

type HashRune rune

HashRune represents a rune that should be hashed when redacted.

func (HashRune) HashValue added in v1.1.7

func (HashRune) HashValue()

HashValue makes HashRune a HashValue.

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.

func (HashUint) HashValue added in v1.1.7

func (HashUint) HashValue()

HashValue makes HashUint a HashValue.

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.

func (SafeByte) SafeValue added in v1.1.6

func (SafeByte) SafeValue()

SafeValue makes SafeByte a SafeValue.

type SafeBytes added in v1.1.6

type SafeBytes []byte

SafeBytes represents a byte slice that is not a sensitive value.

func (SafeBytes) SafeValue added in v1.1.6

func (SafeBytes) SafeValue()

SafeValue makes SafeBytes a SafeValue.

type SafeFloat

type SafeFloat float64

SafeFloat represents a floating-point value that is not a sensitive value.

func (SafeFloat) SafeValue

func (SafeFloat) SafeValue()

SafeValue makes SafeFloat a SafeValue.

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 SafeInt

type SafeInt int64

SafeInt represents an integer that is not a sensitive value.

func (SafeInt) SafeValue

func (SafeInt) SafeValue()

SafeValue makes SafeInt a SafeValue.

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 SafeRune

type SafeRune rune

SafeRune aliases rune. See the explanation for SafeString.

func (SafeRune) SafeValue

func (SafeRune) SafeValue()

SafeValue makes SafeRune a SafeValue.

type SafeString

type SafeString string

SafeString represents a string that is not a sensitive value.

func (SafeString) SafeValue

func (SafeString) SafeValue()

SafeValue makes SafeString a SafeValue.

type SafeUint

type SafeUint uint64

SafeUint represents an integer that is not a sensitive value.

func (SafeUint) SafeValue

func (SafeUint) SafeValue()

SafeValue makes SafeUint a SafeValue.

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.

Jump to

Keyboard shortcuts

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