fix: pre-release security and resource cleanup fixes for tracing
Description
Three issues found during pre-release review of v0.4.0 → v0.5.0 changes:
-
XSS in trace viewer (
viewer.ts:200):t.summary.statusis inserted into HTML without thee()escape function, while all other fields are properly escaped. An attacker with local file access could inject script via crafted trace JSON. -
Trace viewer server never gracefully shut down (
trace.ts): Theawait new Promise(() => {})keeps the process alive but there's no SIGINT/SIGTERM handler to explicitly close the Bun server on Ctrl+C. -
Silent temp file accumulation (
tracing.ts:631): When atomic rename fails and cleanup also fails, orphaned.tmp.*files accumulate silently with no diagnostic logging.
Impact
- Issue 1: Security (XSS) — low practical risk since viewer is localhost-only, but should be fixed
- Issue 2: Resource cleanup — server socket not explicitly closed on exit
- Issue 3: Disk space — orphaned temp files with no visibility
All three are minimal fixes (1-2 lines each).