Introducing a new way to review your PRs.

Read the announcement

replicatedhq / troubleshoot

Preflight Checks and Support Bundles Framework for Kubernetes Applications

View on GitHub

19 documents · Updated Nov 20, 2026

docs / support-bundle-redaction

Support bundle redaction

Support bundle redaction removes or replaces sensitive values before collected data leaves the customer environment. It combines built-in rules with redaction specifications so that plain text, structured text, archives, and YAML content can be protected without removing the surrounding data that engineers need for diagnosis. See Support bundle workflows for the wider bundle life cycle.

Redaction boundary

The redaction boundary is the point between collection and archive delivery. The system reads each collected result, applies the rules that match its path, writes the changed content back, and then archives the result for later analysis or upload.

The diagram shows how a bundle moves through the redaction boundary and becomes a safe-to-share archive.

flowchart LR
    A[Collected files] --> B[File scope match]
    B --> C[Built-in and custom rules]
    C --> D[Redacted files]
    D --> E[Rebuilt support bundle]
    E --> F[Analysis or upload]

Archive files are handled as nested bundles. The system unpacks a .tar, .tgz, or .tar.gz file, redacts its regular files, and writes the archive again. A symbolic link is followed to its target before the target is changed. This lets a rule protect content inside a collected archive instead of only protecting the outer file (pkg/…/redact.go• L57-182).

Redaction stages

When the system processes a file, it follows this sequence:

  1. It selects the built-in rules and the custom rules whose file selectors match the path.
  2. It applies those rules in their configured order.
  3. It replaces the original result with the redacted content.
  4. It records which rule changed which file.
  5. It rebuilds an archive when the changed result belongs to a nested or top-level archive.

The command-line redaction flow can also start with an existing support bundle. It loads redactor manifests from local paths or remote URLs, extracts the bundle, applies the same result-level redaction, and creates a new archive (cmd/…/redact.go• L16-71).

Redaction records

Each changed result can produce a record with the redactor name, file path, line number, and change size. YAML changes use line 0 because a structured rewrite does not identify one source line (pkg/…/redact.go• L86-98, pkg/…/yaml.go• L79-85).

References: pkg/…/redact.go• L57-182 cmd/…/redact.go• L16-71 pkg/…/redact.go• L86-98 pkg/…/yaml.go• L79-85

Redaction specifications

A redaction specification describes which files are in scope and which values to remove from them. The Redactor resource holds a list of named rules. Each rule can use exact values, regular expressions, or YAML paths (pkg/…/redact_shared.go• L3-23).

File scope

The file selector limits a rule to one path or to a list of glob patterns. A rule with no file selector applies to every result. A path match is checked before the rule creates any removal action, so a rule can be broad without changing unrelated files (pkg/…/redact.go• L153-232).

Removal kinds

The removals section maps each declaration to a redaction path:

Specification fieldRedaction pathMain use
valuesLiteral replacementRemove a known exact value wherever it occurs.
regex without selectorSingle-line pattern replacementReplace a value matched within one line.
regex with selectorMulti-line pattern replacementUse one line as context and redact a value on the next line.
yamlPathYAML-aware replacementReplace a value at a path in parsed YAML data.

This split lets a specification choose the smallest rule that fits the source format. The rule builder turns each selected declaration into the matching redactor and keeps custom rules separate from built-in rules (pkg/…/redact.go• L105-121, pkg/…/redact.go• L153-199).

References: pkg/…/redact_shared.go• L3-23 pkg/…/redact.go• L105-121 pkg/…/redact.go• L153-199

Redaction paths

The path type controls how much context the system needs before it changes content. All paths use the same replacement marker when tokenization is off. When tokenization is on, the matched secret can become a stable token instead.

Literal replacement

Literal replacement protects a value that is already known. It replaces every exact byte match in each selected file while keeping the file's original line endings and the presence or absence of a final newline (pkg/…/literal.go• L29-35, pkg/…/literal.go• L55-105).

This path is useful for a customer-specific name, key, or phrase that does not need pattern matching. It does not infer similar values, so a specification must provide each value that it wants to protect.

References: pkg/…/literal.go• L14-35 pkg/…/literal.go• L55-105

Single-line pattern replacement

Single-line replacement applies a regular expression to one line at a time. A named mask group marks the sensitive part for replacement. A named drop group removes its content, while other groups preserve context around the changed value (pkg/…/redact.go• L533-600).

Built-in single-line rules cover common secret-bearing environment values and connection strings. Custom rules use the same model, which keeps the visible field name or connection structure while hiding the sensitive part (pkg/…/redact.go• L252-410, pkg/…/single_line.go• L86-124).

The line-oriented path preserves source layout when a rule does not change the value. It does not add a final newline, and it retains LF or CRLF line endings. Unmatched binary or mixed content remains unchanged (pkg/…/single_line_test.go• L338-451, pkg/…/single_line_test.go• L559-650).

References: pkg/…/redact.go• L252-410 pkg/…/redact.go• L533-600 pkg/…/single_line.go• L43-124 pkg/…/single_line_test.go• L338-451 pkg/…/single_line_test.go• L559-650

Multi-line pattern replacement

Multi-line replacement uses a selector on one line to identify a record and a second regular expression to change the related value on the next line. This fits formats such as pretty-printed JSON where a field name and its value occupy separate lines (pkg/…/multi_line.go• L48-58, pkg/…/multi_line.go• L100-165).

The selector is context rather than the value to hide. The second expression still marks the sensitive part with mask or drop. The original line breaks remain in the output, so the result keeps the shape that an engineer expects during analysis.

References: pkg/…/multi_line.go• L16-58 pkg/…/multi_line.go• L100-165

YAML-aware replacement

YAML-aware replacement treats the selected file as structured YAML instead of searching its text. A dot-separated YAML path walks map keys and array positions. A * segment applies the rest of the path to every child in a map or array (pkg/…/yaml.go• L90-145).

The system leaves a file unchanged when it cannot parse it as YAML or when the path has no match. When a path matches, it replaces the value and serializes the YAML again. This protects the selected field but can also change formatting because the output is a new YAML serialization (pkg/…/yaml.go• L39-87).

References: pkg/…/yaml.go• L15-28 pkg/…/yaml.go• L39-87 pkg/…/yaml.go• L90-145

Tokenized replacement

Tokenized replacement is a mode that can apply to literal, single-line, multi-line, and YAML-aware paths. Instead of using the same hidden marker for every match, it maps a secret to a stable placeholder. The same normalized secret can then be recognized across files without exposing its original value (pkg/…/tokenizer.go• L343-408, pkg/…/redact.go• L552-600).

The token includes a broad secret type when the context or value makes that type clear. The tokenizer keeps a private reverse map and can create a redaction map with the original values, file references, and summary data. That map is more sensitive than the redacted bundle and must be protected if it is generated (pkg/…/tokenizer.go• L75-103, pkg/…/tokenizer.go• L411-419).

Tokenization is enabled for a support-bundle run when requested. The run can also emit tokenization statistics or a redaction map. The support-bundle response carries the bundle ID and any requested map path so downstream users know that the placeholders belong to one redaction run (pkg/…/supportbundle.go• L309-364).

References: pkg/…/tokenizer.go• L36-87 pkg/…/tokenizer.go• L343-408 pkg/…/redact.go• L552-600 pkg/…/supportbundle.go• L309-364 pkg/…/literal.go• L71-81 pkg/…/single_line.go• L102-114 pkg/…/multi_line.go• L134-145 pkg/…/yaml.go• L90-105

Built-in protection

Built-in protection supplies a baseline for common secrets even when a customer does not provide a custom specification. It targets values that look like cloud credentials, passwords, tokens, database connection details, and selected platform credentials (pkg/…/redact.go• L252-410, pkg/…/redact.go• L421-498).

Environment variable names that contain terms such as API key, secret, authorization, private key, or credential receive protection in both one-line and multi-line JSON forms. The matching is case-insensitive, so the same protection covers common naming variations (pkg/…/redact.go• L234-250, pkg/…/redact.go• L500-521).

Built-in connection-string rules cover URI and database-driver forms. They also protect forms that contain a user and password but do not have a trailing database name (pkg/…/redact.go• L315-353).

Some built-in rules are limited to known resource paths. For example, installer resource files receive protection for bootstrap and certificate-related fields. This path limit reduces unwanted changes in files that use similar field names for non-secret data (pkg/…/redact.go• L38-62).

References: pkg/…/redact.go• L38-62 pkg/…/redact.go• L234-250 pkg/…/redact.go• L252-410 pkg/…/redact.go• L421-521

Redaction is one stage in a larger support-bundle process. Collection creates the source results. Analysis reads the redacted bundle. Artifact and upload handling moves the resulting archive to its next destination.

Change checklist

When these files or sections are changed, remember to consider these:

  • Keep the Redact schema fields aligned with the rule builder so each declared removal still selects the intended path type.
  • Keep the mask and drop group contract aligned between custom regex guidance and both single-line and multi-line replacement paths.
  • Keep each built-in credential-name pattern paired across one-line and multi-line JSON rules.
  • Keep tokenized replacements aligned across all path types so repeated secrets preserve the same cross-file identity.
  • Keep archive extraction and reconstruction aligned with supported archive suffixes so nested files do not bypass redaction.
  • Keep redaction-map contents and bundle IDs aligned with the support-bundle response when tokenization output changes.
  • Keep file-selector glob behavior aligned with the paths recorded by collection, including paths reached through symbolic links.

Important failure modes

TriggerConsequenceGuard
A custom file selector does not match the collected path.The rule is valid but protects no content.Compare the selector with the bundle's relative paths before relying on the rule.
A regex omits the mask or drop group.The match may be preserved instead of hidden, or the rule may not express the intended change.Mark the sensitive capture explicitly and keep surrounding groups as context.
A built-in credential-name pattern is added to only one JSON layout.Secrets in the other layout can remain visible.Keep the escaped one-line and pretty multi-line rules generated from the same pattern.
A YAML path targets the wrong key, index, or wildcard depth.No value changes, while the original content remains in the bundle.Check the path against the parsed YAML shape and use wildcards only at the needed level.
A selected file is not valid YAML.The YAML-aware path leaves the original bytes unchanged.Use a literal or regex path for text that only resembles YAML.
A tokenization redaction map is shared with the bundle.Readers can recover the original secret values from the map.Treat the map as a secret and use encryption when the map must be retained.
A nested archive is handled as an ordinary file.Sensitive files inside it can remain unredacted.Let the collection redaction stage unpack and rebuild supported tar formats.

Key files

FileWhy to read it
pkg/…/redact_shared.goDefines the rule contract for file scope and the four removal kinds.
pkg/…/redact.goConnects built-in rules, custom specifications, file matching, replacement groups, and redaction records.
pkg/…/literal.goShows exact-value replacement and output preservation.
pkg/…/single_line.goShows one-line matching and replacement behavior.
pkg/…/multi_line.goShows selector-based matching across related lines.
pkg/…/yaml.goShows structured YAML path traversal and the parse-failure behavior.
pkg/…/tokenizer.goDefines stable token replacement and the sensitive redaction map.
pkg/…/redact.goApplies redaction to collected results and nested archives.
pkg/…/supportbundle.goConnects tokenization options and redaction-map output to bundle creation.
cmd/…/redact.goShows the standalone command that redacts an existing archive and creates a new one.