test(vscode): pin the webview hardening contract [roadmap:rac-editors-buildout]#5
Merged
Merged
Conversation
…-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.
9 tasks
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.
Summary
Implements the regression-coverage half of
rac/roadmaps/rac-editors-buildout.mdinitiative 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 (theclaudeHook.tspattern): 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.tsconsumes the module;tsconfig.test.jsoncompiles it into the battery. Behavior is unchanged.Roadmap / ADR Trace
rac/roadmaps/rac-editors-buildout.md(rac-core#254) — initiative 3; v0.21.10 initiative 2 is the underlying publish-gate contractScope
Included
Excluded
Product / Architecture Decisions
extension.ts: matches the establishedclaudeHook.tstesting pattern, keeps the battery's unit half runnable without an extension host, and leavesextension.tsas 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— cleannpx vsce package— VSIX unchanged in shape (11 files)Proven by this PR's CI
@vscode/test-electron.Review Path
vscode/src/webviewSecurity.ts(moved code — diff against the deletedextension.tsblocks)vscode/src/test/suite/webviewSecurity.test.tsvscode/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.