Documentation
¶
Overview ¶
Package redact removes credentials from Kubernetes objects and log text before anything is written to a Flightbay bundle. It records how many replacements were made and where, never the values themselves.
Index ¶
- Constants
- Variables
- type FieldRule
- type FieldRules
- type LineRedactor
- type Redactor
- func (r *Redactor) DropFields(paths []string) error
- func (r *Redactor) Lines(loc string) *LineRedactor
- func (r *Redactor) Object(loc string, obj map[string]any) map[string]any
- func (r *Redactor) Report() Report
- func (r *Redactor) Secret(loc string, obj map[string]any, mode SecretMode, helm bool) map[string]any
- func (r *Redactor) String(loc, s string) string
- type Report
- type SecretMode
Constants ¶
const LastApplied = "kubectl.kubernetes.io/last-applied-configuration"
LastApplied is the annotation that can hold a full copy of an object.
const Placeholder = "[REDACTED]"
Placeholder is written in place of every redacted value.
Variables ¶
var Rules = []struct{ Name, Description string }{
{"private-key", "PEM private keys (certificates are kept for expiry and SAN checks)"},
{"authorization", "Authorization: Bearer / Basic header values"},
{"jwt", "JSON Web Tokens"},
{"aws-access-key", "AWS access key IDs (AKIA..., ASIA...)"},
{"api-key", "sk-... and sk-ant-... style API keys"},
{"url-credentials", "user:password@ in URLs"},
{"sensitive-key", "the value of any key or variable whose name contains password, passwd, secret, token, api_key or credential"},
}
Rules describes the built-in scrubbers, in the order they run. The customer document (flightbay docs collects) is generated from this list.
var ( // SensitiveKey matches object keys and env var names whose values are credentials. SensitiveKey = regexp.MustCompile(`(?i)(password|passwd|secret|token|api[_\-]?key|credential)`) )
Functions ¶
This section is empty.
Types ¶
type FieldRule ¶
type FieldRule struct {
Source string
// contains filtered or unexported fields
}
FieldRule removes one path from every object, for example
metadata.annotations["corp.example/*"] spec.template.spec.containers[*].env data.license
Segments are separated by dots. A segment in ["..."] may contain dots and slashes (annotation and label keys). Both forms accept * and ? globs. [*] steps into every element of a list. The last segment names the key to remove.
func ParseFieldRule ¶
ParseFieldRule compiles one path.
type FieldRules ¶
type FieldRules []FieldRule
FieldRules is a compiled list.
func ParseFieldRules ¶
func ParseFieldRules(paths []string) (FieldRules, error)
ParseFieldRules compiles a list of paths.
type LineRedactor ¶
type LineRedactor struct {
// contains filtered or unexported fields
}
LineRedactor scrubs a stream of log lines, including private keys that span lines.
type Redactor ¶
type Redactor struct {
// contains filtered or unexported fields
}
Redactor applies the built-in scrubbers plus customer-supplied patterns.
func (*Redactor) DropFields ¶
DropFields makes the Redactor remove these paths from every object it scrubs. Removals are counted in the redaction report as drop-field-N.
func (*Redactor) Lines ¶
func (r *Redactor) Lines(loc string) *LineRedactor
Lines returns a stateful redactor for one log stream.
type Report ¶
type Report struct {
Total int `json:"total"`
Locations map[string]map[string]int `json:"locations"`
Note string `json:"note"`
}
Report is written to redaction-report.json.
type SecretMode ¶
type SecretMode string
SecretMode controls how much of a Secret is captured. No mode captures values.
const ( SecretMetadata SecretMode = "metadata" // name, type, labels, annotations SecretKeys SecretMode = "keys" // metadata plus key names and byte lengths )