fix: [AI-194] pre-release security and resource cleanup fixes for tracing#197
Merged
anandgupta42 merged 4 commits intomainfrom Mar 16, 2026
Merged
fix: [AI-194] pre-release security and resource cleanup fixes for tracing#197anandgupta42 merged 4 commits intomainfrom
anandgupta42 merged 4 commits intomainfrom
Conversation
…cing - Escape `t.summary.status` with `e()` in trace viewer HTML to prevent XSS - Add SIGINT/SIGTERM handlers to gracefully stop trace viewer server on Ctrl+C - Log snapshot write failures with `console.debug` instead of silently swallowing Closes #194 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Systematically escape all user-controllable fields in `viewer.ts`: - Escape `span.kind` and `span.status` in detail panel, waterfall, tree, and log views - Escape `span.spanId` in `data-sid` attributes - Coerce all numeric fields with `Number()` to prevent string injection via `.toLocaleString()` - Add single-quote escaping (`'`) to the `e()` function for defense-in-depth Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
`Bun.Server.stop()` returns a `Promise<void>` — calling it without `await` exits the process before in-flight requests are drained. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Prevents unhandled promise rejection if the server fails to stop cleanly on SIGINT/SIGTERM. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
anandgupta42
added a commit
that referenced
this pull request
Mar 17, 2026
…cing (#197) * fix: [AI-194] pre-release security and resource cleanup fixes for tracing - Escape `t.summary.status` with `e()` in trace viewer HTML to prevent XSS - Add SIGINT/SIGTERM handlers to gracefully stop trace viewer server on Ctrl+C - Log snapshot write failures with `console.debug` instead of silently swallowing Closes #194 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * fix: comprehensive XSS hardening for trace viewer HTML Systematically escape all user-controllable fields in `viewer.ts`: - Escape `span.kind` and `span.status` in detail panel, waterfall, tree, and log views - Escape `span.spanId` in `data-sid` attributes - Coerce all numeric fields with `Number()` to prevent string injection via `.toLocaleString()` - Add single-quote escaping (`'`) to the `e()` function for defense-in-depth Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * fix: await `server.stop()` for graceful shutdown in trace viewer `Bun.Server.stop()` returns a `Promise<void>` — calling it without `await` exits the process before in-flight requests are drained. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * fix: catch `server.stop()` rejection in shutdown handler Prevents unhandled promise rejection if the server fails to stop cleanly on SIGINT/SIGTERM. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR do?
Three targeted fixes found during pre-release review (v0.4.0 → v0.5.0):
viewer.ts:200): Escapet.summary.statuswith the existinge()HTML escape function — it was the only unescaped user-controllable field in the header tags blocktrace.ts): Add SIGINT/SIGTERM handlers to explicitly stop the Bun server on Ctrl+C instead of relying on process terminationtracing.ts:631): Log failed trace snapshot writes withconsole.debuginstead of silently swallowing errorsType of change
Issue for this PR
Closes #194
How did you verify your code works?
Checklist