inspector/clients/web/src/lib
Repository files (latest commit first)
Filename Latest commit message Latest commit date
cliffhall 77e57e0d25 feat(web): add sandbox CSP builder library (closes #1558)
Add a pure, DOM-free CSP-builder library at
clients/web/src/lib/sandbox-csp.ts that validates app-supplied
`_meta.ui.csp` requests, filters them to safe sources, builds the
locked-down Content-Security-Policy string, and wraps untrusted widget
HTML in a fixed host shell whose first <head> child is the CSP meta.

- SAFE_CSP_SOURCE: strict regex that rejects directive/attribute
  breakouts (`;`, `"`, `<`, `>`, whitespace).
- approveCspSources(): drops unsafe entries (with a warning) and omits
  empty keys; echoes back only what the host will enforce.
- buildSandboxCspPolicy(): `default-src 'none'` catch-all, `form-action
  'none'`, source-allowlist filtering, `'unsafe-inline'` for the app's
  own inline script/style.
- escapeHtmlAttr() / wrapSandboxedHtml(): defense-in-depth so untrusted
  bytes never precede the applied policy.

Re-implements the sandbox-csp portion of PR #1510 (Wave 1 of #1579) as a
standalone library; wiring into the app bridge is a follow-up issue.
Adds full unit tests (100% lines/statements/functions/branches) and
lists the file in the web coverage `include` so it is gated (the
untested legacy src/lib siblings stay out until they get tests).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01S3fTN8H3R8YV4yUGvZjYnX
2026-07-01 18:23:13 -04:00
..
types Phase 0 foundations for component interfaces refactor 2026-04-15 16:06:23 -04:00
downloadFile.ts feat(web): History — Pin & Replay, plus two history-status fixes (#1438) (#1441) 2026-06-07 20:21:52 -04:00
environmentFactory.ts feat(web,core): enterprise-managed authorization (EMA) (#1509) (#1512) 2026-06-24 22:15:12 -04:00
sandbox-csp.test.ts feat(web): add sandbox CSP builder library (closes #1558) 2026-07-01 18:23:13 -04:00
sandbox-csp.ts feat(web): add sandbox CSP builder library (closes #1558) 2026-07-01 18:23:13 -04:00