redact

package
v0.1.6 Latest Latest
Warning

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

Go to latest
Published: Nov 2, 2026 License: Apache-2.0 Imports: 5 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package redact removes secrets from event payloads and bounds their size.

It runs twice: in the client hook before an event touches the local spool, and again on the server at ingest (defence in depth). Rules are deliberately conservative pattern matches; they reduce exposure, they do not guarantee it.

Index

Constants

View Source
const Placeholder = "[REDACTED]"

Placeholder replaces every redacted value.

Variables

This section is empty.

Functions

func Bound

func Bound(v any, maxString, maxTotal int) any

Bound truncates every string in v to maxString bytes, then shrinks the limit until the encoded value fits in maxTotal bytes. It also strips inline data: URIs (screenshots), which are large and useless for text retrieval.

func JSON

func JSON(raw []byte) []byte

JSON redacts a JSON document. Invalid JSON is redacted as plain text and wrapped so the result is always valid JSON.

func SensitiveKey

func SensitiveKey(k string) bool

SensitiveKey reports whether a JSON object key names a credential.

func SensitivePath

func SensitivePath(p string) bool

SensitivePath reports whether a file path looks like a secret store whose contents must never be captured (.env, private keys, cloud credentials…).

func String

func String(s string) string

String redacts secrets inside free text.

func Truncate

func Truncate(s string, max int) string

Truncate shortens s to at most about max bytes by cutting the middle: the beginning and the end of a text are where intent usually is (the question after a pasted log, the conclusion after a long explanation). Cuts fall on rune boundaries and the marker records how much was dropped.

func Value

func Value(v any) any

Value walks a decoded JSON value, redacting credential-named keys and secrets inside strings.

Types

This section is empty.

Jump to

Keyboard shortcuts

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