Skip to content

feat(mask): add string pool masking, live preview, and masked .khi export - #1199

Merged
kyasbal merged 8 commits into
GoogleCloudPlatform:mainfrom
kyasbal:push-klvnmtkmmlln
Oct 30, 2026
Merged

kyasbal merged 8 commits into
GoogleCloudPlatform:mainfrom
kyasbal:push-klvnmtkmmlln

Conversation

@kyasbal

@kyasbal kyasbal commented Oct 30, 2026

Copy link
Copy Markdown
Member

Background

Sharing .khi inspection archives across teams or in support tickets often requires sanitizing sensitive cluster identifiers—such as project IDs, cluster names, namespaces, node names, pod names, user principals, or IP addresses—before exporting the file. Previously, KHI had no built-in mechanism to browse unique strings in a loaded inspection dataset, preview how masking rules affect the UI, or export a sanitized .khi archive without re-running log collection.

Approach

  • Single-Pass .khi v6 Archive String Masking: Adds a streaming archive transformation (ExportMaskedArchiveWithProgress) that rewrites client and server InterningPoolChunk entries, MetadataChunk headers and queries, and TimelineChunk items using a longest-match-first single-pass replacer (strings.NewReplacer). Sequential <masked_N> placeholders are assigned by default so distinct identifiers remain distinguishable without cascading replacements, while empty replacements delete matched substrings.
  • On-Demand String Pool Trigram Index & MaskService RPCs: Introduces apiv1.MaskService with streaming and polling-fallback RPCs to watch on-demand trigram index construction (WatchStringPoolIndexProgress), query unique dataset strings via case-insensitive RE2 regular expressions (ListWorkbenchStrings with trigram pre-filtering and linear-scan fallback while indexing is in progress), and stream archive masking progress (CreateMaskedInspection).
  • Live Mask Preview & Dockable String Masking Pane: Adds StringMaskService and InternPoolStore transform hooks so enabled mask rules immediately preview across Timeline, Log, and Diff views without mutating underlying raw labels used by backend filters. Provides a dockable String Masking pane to search and bulk-select candidate strings, customize or delete replacements, and export the masked .khi file with determinate progress feedback.
@kyasbal kyasbal added type:feature New feature or request area:backend-core Core backend frameworks, DAG task runner, and server API area:frontend Web frontend application and UI components area:khifile .khi file format, serialization, and schema labels Oct 30, 2026

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a sensitive data masking feature, allowing users to browse unique strings, configure masking rules, preview masked data live, and export sanitized .khi archives. Key additions include the MaskService Connect-RPC handler, on-demand string pool trigram indexing with linear-scan fallback, and a dockable frontend masking pane. Feedback on these changes highlights a critical issue where the KHI writer is not closed in ExportMaskedKHIFile, potentially corrupting exported archives. Additionally, redundant nil checks on protobuf getters in Go should be simplified, and a potential memory leak in the frontend's watchStringPoolIndexProgress delay loop should be resolved by properly handling the abort signal.

Comment thread pkg/model/khifile/v6/mask.go Resolved
Comment thread pkg/server/workbench/strings.go Resolved
@kyasbal
kyasbal added this pull request to the merge queue Oct 30, 2026
Merged via the queue into GoogleCloudPlatform:main with commit 4664de9 Oct 30, 2026
17 checks passed
@kyasbal
kyasbal deleted the push-klvnmtkmmlln branch October 30, 2026 04:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:backend-core Core backend frameworks, DAG task runner, and server API area:frontend Web frontend application and UI components area:khifile .khi file format, serialization, and schema type:feature New feature or request

1 participant