Skip to content

test(vscode): pin the webview hardening contract [roadmap:rac-editors-buildout]#5

Merged
tcballard merged 1 commit into
mainfrom
claude/rac-editors-review-nm7rzw
Jul 2, 2026
Merged

test(vscode): pin the webview hardening contract [roadmap:rac-editors-buildout]#5
tcballard merged 1 commit into
mainfrom
claude/rac-editors-review-nm7rzw

Conversation

@tcballard

@tcballard tcballard commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

Summary

Implements the regression-coverage half of rac/roadmaps/rac-editors-buildout.md initiative 3 (the hardening itself shipped with the recovered source; it carried no tests).

Adds:

  • vscode/src/webviewSecurity.ts — the publish-blocking hardening seams extracted as pure, vscode-free functions (the claudeHook.ts pattern): the strict Explorer CSP, hardenWebviewHtml, the validated bridge envelope (parseExplorerMessage), and the workspace path confinement (isPathInside).
  • vscode/src/test/suite/webviewSecurity.test.ts — pins the contract: default-src 'none' with no connect-src and no eval, CSP meta first in <head> (and prepended when head-less), forged/malformed bridge messages ignored (wrong type, missing/non-string/empty id), path-shaped ids treated as opaque tokens, ..-escapes and absolute outside paths rejected.
  • extension.ts consumes the module; tsconfig.test.json compiles it into the battery. Behavior is unchanged.

Roadmap / ADR Trace

Scope

Included

  • The extraction and the tests. No policy change: the CSP directives and envelope rules are byte-identical to the recovered implementation.

Excluded

  • The release pipeline and listing content — the next (final) iteration.

Product / Architecture Decisions

  • Pure-module extraction over exporting internals from extension.ts: matches the established claudeHook.ts testing pattern, keeps the battery's unit half runnable without an extension host, and leaves extension.ts as the only vscode-coupled surface.

User-Facing Contract

None — internal refactor plus tests; the extension's behavior and the CSP it ships are unchanged.

Verification

Ran (locally)

  • npm run check-types, npm run compile-tests, npm run compile — clean
  • The new suite's assertions executed against the compiled module — pass
  • npx vsce package — VSIX unchanged in shape (11 files)

Proven by this PR's CI

  • The full battery including the new suite under @vscode/test-electron.

Review Path

  1. vscode/src/webviewSecurity.ts (moved code — diff against the deleted extension.ts blocks)
  2. vscode/src/test/suite/webviewSecurity.test.ts
  3. vscode/src/extension.ts (consumption only)

Implementation Process

Implemented with AI assistance under the roadmap contract; final scope, review, and acceptance decisions were made by the maintainer.

…-buildout]

The publish-blocking hardening (v0.21.10 initiative 2) shipped with the
recovered source but carried no regression coverage. Extracts the pure
seams — the strict Explorer CSP, the validated bridge envelope, and the
workspace path confinement — into webviewSecurity.ts (the claudeHook
pattern: vscode-free, unit-testable in the battery) and pins them:
default-src 'none' with no connect-src, CSP meta first in <head>,
forged/malformed bridge messages ignored, ..-escapes and absolute paths
rejected. extension.ts consumes the module; behavior is unchanged.
@tcballard
tcballard merged commit 91d3079 into main Jul 2, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant