Repository navigation
feat(mask): add string pool masking, live preview, and masked .khi export - #1199
Conversation
There was a problem hiding this comment.
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.
0536aac to
0b1637a
Compare
4664de9
Background
Sharing
.khiinspection 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.khiarchive without re-running log collection.Approach
.khiv6 Archive String Masking: Adds a streaming archive transformation (ExportMaskedArchiveWithProgress) that rewrites client and serverInterningPoolChunkentries,MetadataChunkheaders and queries, andTimelineChunkitems 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.MaskServiceRPCs: Introducesapiv1.MaskServicewith streaming and polling-fallback RPCs to watch on-demand trigram index construction (WatchStringPoolIndexProgress), query unique dataset strings via case-insensitive RE2 regular expressions (ListWorkbenchStringswith trigram pre-filtering and linear-scan fallback while indexing is in progress), and stream archive masking progress (CreateMaskedInspection).StringMaskServiceandInternPoolStoretransform 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.khifile with determinate progress feedback.