Restrict CSS mirror writes to workspace - #4962
Open
Vidal Ortega (vidorteg) wants to merge 1 commit into
Open
Conversation
There was a problem hiding this comment.
🟢 Approval recommended
The changes correctly restrict CSS mirroring writes to trusted roots and include targeted tests covering both allowed and blocked paths.
Pull request overview
This PR hardens the CSS mirroring feature so that stylesheet writes initiated by the inspected page cannot write to arbitrary filesystem locations, and are instead restricted to trusted local roots (workspace folders, or the target file’s directory for single-file debugging).
Changes:
- Add a “trusted root” guard to CSS mirroring that blocks writes outside the workspace (and blocks path traversal escapes).
- Define trusted roots as the opened workspace folder(s), with a fallback to the target file’s directory when debugging a single local file.
- Update and extend unit tests/mocks to validate both allowed (in-workspace) and blocked (out-of-workspace / traversal) mirroring scenarios.
File summaries
| File | Description |
|---|---|
src/devtoolsPanel.ts |
Adds trusted-root computation and enforcement for CSS mirror writes. |
test/devtoolsPanel.test.ts |
Updates existing CSS mirroring test and adds negative tests for out-of-workspace + traversal paths. |
test/helpers/helpers.ts |
Adjusts VS Code workspace folder mock shape to include uri.fsPath needed by the new trusted-root logic. |
Review details
- Files reviewed: 3/3 changed files
- Comments generated: 0
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
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.
Restrict CSS mirror writes to workspace