test(parser-vscode): make non-Windows server-dir test platform-independent#104
Open
JuliusGruber wants to merge 1 commit into
Open
test(parser-vscode): make non-Windows server-dir test platform-independent#104JuliusGruber wants to merge 1 commit into
JuliusGruber wants to merge 1 commit into
Conversation
…s hosts findVsCodeDirs() branches on process.platform: on win32 it reads editions from %APPDATA% and skips the .vscode-server block entirely. The 'non-Windows hosts' test builds a ~/.config + ~/.vscode-server layout and asserts all four dirs are returned, but never stubbed process.platform, so it only passed when the test process itself ran on a non-Windows OS. On Windows the function (correctly) returns [], failing the assertion. Pin process.platform to 'linux' for the test's duration and restore it in the existing finally block, making the test deterministic across Windows, macOS, and Linux.
Collaborator
|
@JuliusGruber Thanks for your PR, Please agree with contributor license agreement https://github.com/microsoft/ContributorLicenseAgreement |
san360
approved these changes
Jun 7, 2026
Collaborator
san360
left a comment
There was a problem hiding this comment.
Thanks for this thorough security hardening pass — great work! All 1063 tests pass, build is clean, and every change tightens an attack surface. A few notes:
Highlights:
- Prototype pollution guards in \setAtPath/\�ppendAtPath\ with \FORBIDDEN_KEYS\ — well done.
- \safeJoinUnder\ is a much stronger replacement for the ad-hoc ...\ substring checks.
- RPC dispatch hardening with \hasOwnProperty.call\ + \ ypeof handler === 'function'\ closes a real prototype-chain invocation vector.
- \isSafeExternalHttpsUrl\ and the sidebar command allowlist are clean, focused mitigations.
- The \�alanceTruncatedJson\ rewrite is more robust than the old 4-attempt approach.
eadTextWithByteLimit\ with streaming enforcement is a nice touch against response size bombs.
Two minor nits (non-blocking):
- CHANGELOG.md — No entry was added for these changes. Consider adding a patch-level entry so users upgrading can see what changed.
- *\setMatchesChar* in \safe-regex.ts\ — constructs a
ew RegExp\ from extracted character class source. The try/catch fail-closed path handles it well, but a belt-and-suspenders length check on \source\ before construction could be a nice addition (low priority since outer pattern is already capped at 1000 chars).
LGTM — approving as-is. 🚀
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.
Problem
findVsCodeDirs()branches onprocess.platform— onwin32it reads theCode/Code - Insiderseditions from%APPDATA%and skips the.vscode-serverblock entirely (VS Code Server doesn't run natively on Windows).The test "includes server workspaceStorage paths on non-Windows hosts" builds a non-Windows layout (
~/.config/Code/...+~/.vscode-server/...) and asserts all four directories come back — but it never stubsprocess.platform. So it only passes when the test process itself runs on a non-Windows OS:npm testlocally — the function (correctly) returns[], so the assertion fails.Fix
Pin
process.platformto'linux'for the duration of the test and restore it in the existingfinallyblock. This makes the test deterministic across Windows, macOS, and Linux.Test-only change — production behavior is unchanged (returning
[]on real Windows is correct).Verification
src/core/parser-vscode.test.ts39/39 passing after the fix.tsc --noEmitclean.eslint src/core/parser-vscode.test.tsclean.🤖 Generated with Claude Code