Loading…
Loading…
Explains how the platform generates compressed diagnostic debug bundles containing masked API traffic samples, topology, and telemetry for troubleshooting.
The Debug Bundle Builder is a component responsible for assembling a self-contained, compressed diagnostic package for a given traffic capture session. This package, known as a debug bundle, aids in troubleshooting by providing masked API transaction samples, a tokenized system topology, and contextual telemetry in a single ZIP archive.
The builder takes a capture session ID as input and produces the cleartext, compressed bundle as an in-memory byte array. It is designed to be a part of a larger diagnostic workflow; it generates the bundle's content but does not persist or transmit the resulting cleartext archive. A separate component is responsible for encrypting the bundle before storage or delivery.
A key feature of the builder is its security-conscious design. It uses a transient, per-bundle salt to perform irreversible masking of sensitive data in the captured events and system topology. This salt is generated for a single build operation and is securely discarded immediately afterward, ensuring that the tokenized data in the bundle cannot be reversed.
The bundle generation process is triggered by a call to buildCleartextBundle with a specific sessionId. The component then executes a series of steps to gather, mask, and package the required diagnostic data.
flowchart TD
subgraph Bundle Generation Flow
A[Start: sessionId] --> B{Fetch Session Data};
B --> C[Generate Per-Bundle Salt];
C --> D[Fetch & Mask Captured Events];
C --> E[Extract Tokenized Topology];
B --> F[Collect Scoped Telemetry];
D & E & F --> G[Generate Manifest with Hashes];
G & D & E & F --> H[Assemble ZIP Archive];
H --> I[Return Cleartext Bundle];
end
subgraph Security
C --> J[Salt is used for masking];
I --> K[Discard Per-Bundle Salt];
endSession Retrieval: The process begins by retrieving the specified capture session's metadata from the DebugCaptureRepository using the provided sessionId. If the session does not exist, the process fails.
Salt Generation: A new, cryptographically-secure salt is generated specifically for this bundle. This salt is held in memory only for the duration of the build.
Data Collection and Masking:
500 samples (MAX_SAMPLES). Each event's raw data is processed through a MaskingPipeline using the generated salt. This replaces sensitive values with non-reversible tokens. The gateway_type and captured_at timestamp are added to the masked output.TopologyExtractor. This process also uses the same per-bundle salt to tokenize identifiers, ensuring consistency between the topology data and the event samples. No credentials are included.DiagnosticTelemetryCollector. This information is automatically scoped to the current tenant to prevent data leakage in a multi-tenant environment.Manifest Creation: A manifest.json file is generated. It contains essential metadata about the bundle:
bundleId (UUID).sessionId.tier and redactionProfile.ZIP Assembly: All generated artifacts—manifest.json, topology/topology.json, telemetry-v2.json, and the individual samples/<n>.json files—are assembled into a single ZIP archive in memory.
Cleanup and Return:
finally block, the per-bundle salt is securely zeroed out and discarded from memory. This is a critical step to guarantee the non-reversibility of the masked data.CleartextBundle object, which contains the new bundleId, the ZIP archive bytes, and the manifest map, is returned to the caller.IMPORTANT
The BundleBuilder only produces the cleartext bundle in memory. It does not persist this cleartext data to the database or any other storage. A subsequent process is responsible for encrypting the bundle before it is stored or transmitted.
Each generated debug bundle is a ZIP archive containing the following files:
| File Path | Description |
|---|---|
manifest.json | A JSON file containing metadata for the entire bundle, including a unique bundle ID, session details, event counts, and SHA-256 hashes for all other files in the archive. |
topology/topology.json | A JSON representation of the system topology. Identifiers are tokenized using the same salt as the event samples. It does not contain any credentials. |
telemetry-v2.json | A snapshot of Tier-0 diagnostic data providing operational context. The schema version is included. |
samples/<n>.json | A sequence of JSON files (samples/0.json, samples/1.json, etc.), each containing a single masked and parsed API event captured during the session. |
Before generating a full bundle, an API publisher can request a "dry-run" preview. The preview() method provides a partial, uncompressed view of the data that would be included in a bundle. This allows for verification of the masking and redaction rules.
The preview is generated using a temporary, throwaway salt that is immediately discarded. The tokens in a preview are not guaranteed to match the tokens in a subsequently generated bundle.
A call to preview(sessionId, sampleLimit) returns a map containing:
session_id, redaction_profile, tier).total_events, preview_sample_count).manifest object similar to the one in a real bundle, but with empty file hashes.samples, where each entry is a masked event map.topology_preview object showing the tokenized topology.The number of samples in a preview is determined by the sampleLimit parameter, which defaults to 3 if the input is 0 or less, and is capped at a maximum of 25.
The BundleBuilder component exposes the following public methods.
| Method | Description |
|---|---|
buildCleartextBundle(UUID sessionId) | Builds the complete, compressed, cleartext debug bundle for the specified session. This is the primary method for bundle generation. It returns a CleartextBundle record containing the bundleId, ZIP bytes, and manifest. |
preview(UUID sessionId, int sampleLimit) | Generates a "dry-run" preview of the bundle's contents for UI display, including a small number of masked samples and the manifest structure. Does not create a ZIP archive. Returns a Map of the preview data. |
The builder includes an internal constant that defines an operational limit.
| Name | Type | Value | Description |
|---|---|---|---|
MAX_SAMPLES | int | 500 | A hard-coded maximum limit on the number of event samples included in any single debug bundle. This is a defense-in-depth measure. |
The design of the BundleBuilder incorporates several important security controls.
To ensure that masked data cannot be reversed, the builder generates a unique salt for each bundle creation operation.
MaskingPipeline to tokenize sensitive fields in event samples and the topology.buildCleartextBundle or preview method call.finally block ensures the byte array holding the salt is overwritten with zeros before the method returns, securely discarding it.The output of this component is a CleartextBundle. The raw, unencrypted ZIP archive exists only as an in-memory byte array. The component itself does not write this cleartext data to disk or the database. It is the responsibility of the calling service to handle the encryption of these bytes before any persistence or transmission.
To prevent unauthorized information disclosure in multi-tenant deployments, the included diagnostic telemetry is strictly scoped. The collectForBoundTenant() method ensures that an operator can only retrieve telemetry relevant to their own tenant, not platform-wide data or data from other tenants.
| Condition | Trigger | Meaning |
|---|---|---|
IllegalArgumentException: session not found | Calling buildCleartextBundle or preview with a sessionId that does not exist in the repository. | The provided session ID is invalid or the session has been deleted. The caller must provide a valid, existing session ID. |
IllegalStateException | An internal error occurs during JSON serialization or ZIP file assembly. | This indicates a bug or an unexpected data state that prevents the bundle from being created. The exception message will specify whether the failure was in "JSON serialization" or "ZIP assembly". |
Log: S2R-DBG telemetry snapshot failed | The telemetry.collectForBoundTenant() method throws an exception during the build. | The telemetry collection step failed. The bundle will still be generated successfully, but the telemetry-v2.json file inside it will be empty. This is a non-fatal error. |
Log: S2R-DBG scope summary parse failed | The scopeJson field for the session contains malformed JSON. | The scope summary in manifest.json could not be generated. The bundle will still be created, but the manifest will be missing the scopeSummary section. This is a non-fatal error. |