Repository navigation
feat(configuration): support extends in folder settings files - #299164
scarf (scarf005) wants to merge 2 commits into
Conversation
Resolve .vscode/settings.json extends chains before parsing so shared settings files can be inherited and watched for updates. Add coverage for merge precedence and dependency-file change propagation. Assisted-by: openai/gpt-5.3-codex on opencode Co-authored-by: chatgpt-codex-connector[bot] <199175422+chatgpt-codex-connector[bot]@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Adds support for extends in folder-level workspace settings (.vscode/settings.json) by resolving and merging inherited settings prior to parsing, and wiring file watching so changes in inherited settings trigger a configuration reload. This fits into the workbench configuration pipeline by enhancing how FolderConfiguration (and the underlying file-service based configuration loader) resolves settings content.
Changes:
- Resolve and merge
extendschains for folder settings before parsing intoConfigurationModel. - Track/watch resolved inherited settings resources so changes propagate via configuration reload events.
- Add browser-side configuration service tests covering precedence and change propagation for extended settings.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| src/vs/workbench/services/configuration/browser/configuration.ts | Implements extends resolution/merging for settings content and watches inherited resources to trigger reloads. |
| src/vs/workbench/services/configuration/test/browser/configurationService.test.ts | Adds tests for extended folder settings precedence and reload propagation when an inherited file changes. |
Comments suppressed due to low confidence (1)
src/vs/workbench/services/configuration/browser/configuration.ts:429
resolveExtendsResourcetreats any string that parses with a URI scheme as an absolute URI. This breaks common absolute Windows paths likeC:\foo\bar.jsonorc:/foo/bar.jsonbecauseURI.parseinterprets the drive letter as the scheme (c:), causing laterreadFilecalls to fail. Consider detecting Windows drive/UNC paths (and other non-URI absolute paths) and routing them throughextUri.resolvePathinstead ofURI.parsescheme handling.
private resolveExtendsResource(settingsResource: URI, extendsRef: string): URI | undefined {
try {
const parsed = URI.parse(extendsRef);
if (parsed.scheme) {
return parsed;
}
| try { | ||
| const parsed = URI.parse(extendsRef); | ||
| if (parsed.scheme) { | ||
| return parsed; | ||
| } | ||
| } catch { | ||
| } | ||
|
|
||
| if (!extendsRef.trim()) { | ||
| return undefined; | ||
| } | ||
|
|
||
| return this.uriIdentityService.extUri.resolvePath(this.uriIdentityService.extUri.dirname(settingsResource), extendsRef); |
There was a problem hiding this comment.
extends references are resolved via extUri.resolvePath(dirname(settingsResource), extendsRef), which allows .. segments to escape the .vscode configuration folder (and even the workspace) and then readFile will load that external file. Because workspace settings are repo-controlled, this enables arbitrary file reads outside the workspace and can expose local data via configuration APIs. Please restrict allowed extends targets (e.g., require the resolved resource to be equal-or-child of the configuration folder and to match the base scheme/authority), and ignore/log otherwise.
| try { | |
| const parsed = URI.parse(extendsRef); | |
| if (parsed.scheme) { | |
| return parsed; | |
| } | |
| } catch { | |
| } | |
| if (!extendsRef.trim()) { | |
| return undefined; | |
| } | |
| return this.uriIdentityService.extUri.resolvePath(this.uriIdentityService.extUri.dirname(settingsResource), extendsRef); | |
| const trimmedRef = extendsRef.trim(); | |
| if (!trimmedRef) { | |
| return undefined; | |
| } | |
| const baseDir = this.uriIdentityService.extUri.dirname(settingsResource); | |
| let candidate: URI | undefined; | |
| try { | |
| const parsed = URI.parse(trimmedRef); | |
| if (parsed.scheme) { | |
| candidate = parsed; | |
| } | |
| } catch { | |
| // Not a URI, treat as relative path below | |
| } | |
| if (!candidate) { | |
| candidate = this.uriIdentityService.extUri.resolvePath(baseDir, trimmedRef); | |
| } | |
| // Enforce same scheme/authority and restrict to configuration directory subtree | |
| if (candidate.scheme !== baseDir.scheme || candidate.authority !== baseDir.authority) { | |
| this.logService.trace(`Ignoring extends reference '${extendsRef}' from '${settingsResource.toString()}' because it has a different scheme or authority.`); | |
| return undefined; | |
| } | |
| if (!this.uriIdentityService.extUri.isEqualOrParent(candidate, baseDir)) { | |
| this.logService.trace(`Ignoring extends reference '${extendsRef}' from '${settingsResource.toString()}' because it resolves outside the configuration folder.`); | |
| return undefined; | |
| } | |
| return candidate; |
Ignore extends targets that cross scheme/authority boundaries or resolve outside the settings directory to prevent unsafe file traversal. Add a regression test for escaping the .vscode folder. Assisted-by: openai/gpt-5.3-codex on opencode Co-authored-by: chatgpt-codex-connector[bot] <199175422+chatgpt-codex-connector[bot]@users.noreply.github.com>
if (!this.uriIdentityService.extUri.isEqualOrParent(candidate, baseDir)) {
this.logService.trace(`Ignoring extends reference '${extendsRef}' from '${settingsResource.toString()}' because it resolves outside the configuration folder.`);
return undefined;
}If I understand correctly here, the current approach would not allow what most users including the original issue author in #15909 want. And with the current approach that would not work as the root is outside of project_A. But leaving it like it currently is, I think the feature wouldn't be useful to many users. |
Summary
extendsin folder.vscode/settings.jsonby resolving and merging inherited settings before parsingFixes #15909.
Testing
npm run compilenpm run test-node -- --run "src/vs/workbench/services/configuration/test/common/configurationModels.test.ts" --grep "FolderSettingsModelParser"configurationService.test.ts; blocked in this container due missing X server and missing Playwright host libraries