redact

package
v1.1.0-beta.0...-e2f85cd Latest Latest
Warning

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

Go to latest
Published: Nov 15, 2026 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DeRedact

func DeRedact(remove bool, input io.Reader, output io.Writer, sep string) error

DeRedact is similar to DeRedactFile, but act on reader/writer, it works line by line.

func DeRedactFile

func DeRedactFile(remove bool, input string, output string) error

DeRedactFile will deredact the input file, either removing marked contents, or remove the marker. It works line by line.

func InitRedact

func InitRedact(redactLog bool)

InitRedact inits the enableRedactLog

func Key

func Key(key []byte) string

Key receives a key return omitted information if redact log enabled

func LockInfo

func LockInfo(lock *kvrpcpb.LockInfo) fmt.Stringer

LockInfo returns a fmt.Stringer of the lock info. The keys in the lock info (primary lock, key, secondaries and the keys of nested shared locks) are replaced by '?' if redact log is enabled. The String() method is evaluated lazily, so it is cheap to pass it to a logger whose level is not enabled.

func LockInfoWithMode

func LockInfoWithMode(lock *kvrpcpb.LockInfo, mode string) fmt.Stringer

LockInfoWithMode is like LockInfo, but also masks keys when mode is ON or MARKER. Process-global redaction still applies when mode is OFF or empty. All enabled modes replace key bytes with '?', and formatting remains lazy.

func NeedRedact

func NeedRedact() bool

NeedRedact returns whether to redact log

func RegionError

func RegionError(regionErr *errorpb.Error) string

RegionError formats a region error without modifying it. When redaction is enabled, keys and the top-level message are masked while internal diagnostic metadata, including nested reasons and messages, is preserved.

func String

func String(mode string, input string) string

String will redact the input string according to 'mode'. Check 'tidb_redact_log': https://github.com/pingcap/tidb/blob/acf9e3128693a5a13f31027f05f4de41edf8d7b2/pkg/sessionctx/variable/sysvar.go#L2154.

func Stringer

func Stringer(mode string, input fmt.Stringer) redactStringer

Stringer will redact the input stringer according to 'mode', similar to String().

func Value

func Value(arg string) string

Value receives string argument and return omitted information if redact log enabled

func WriteRedact

func WriteRedact(build *strings.Builder, v string, redact string)

WriteRedact is to write string with redact into `strings.Builder`

Types

type TaskInfoRedacted

type TaskInfoRedacted struct {
	Info *backup.StreamBackupTaskInfo
}

TaskInfoRedacted is a wrapper of backup.StreamBackupTaskInfo to redact sensitive information

func (TaskInfoRedacted) String

func (t TaskInfoRedacted) String() string

String returns the redacted string of the task info

Jump to

Keyboard shortcuts

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