src/vs/platform/policy/common/fileManagedSettingsService.ts

92 LOC · 92 covered · 0 uncovered · 18 ranges · 28 concepts · 9 introducers · 16 tests

File neighbourhood

The centred file is linked to every concept that introduces one of its ranges, every test that runs code from the file, and the gray connector concepts standing between those tests and the file's own introducer concepts. Undirected links join concepts to every file where they introduce source and concepts to the tests they introduce; arrows show specialization between the displayed concepts and bridge only concepts omitted from this view. Concept colors match the source ranges below; connector concepts have no source color and are shown in gray.

Focused file, its introducer and connector concepts, their introduced files, and tests that run code from the file

In the embedded map, ordinary wheel input scrolls the page; use the visible controls to zoom and drag to pan. Open the full-screen map for canvas navigation: wheel pans, Ctrl/Command plus wheel zooms, and arrow keys pan when this region is focused. On touch screens, open the full-screen map to pan or pinch. If JavaScript or WebGL is unavailable, use the related-file, concept, and source links on this page.

Focused file, its introducer and connector concepts, their introduced files, and tests that run code from the filesrc/vs/platform/policy/common/fileManagedSettingsIpc.ts · 99 LOCcommon/fileManagedSettin…fileManagedSettingsService.test|title=FileManagedSettingsService clears managed settings and fires when the file is deleted|occurrence=1 · 0 introduced LOCfileManagedSettingsServi…fileManagedSettingsService.test|title=FileManagedSettingsService fires event when file changes|occurrence=1 · 0 introduced LOCfileManagedSettingsServi…copilotManagedSettings.ts ×1 · 2 introduced LOCcopilotManagedSettings.t…fileManagedSettingsService.test|title=FileManagedSettingsService reads managed-settings.json on startup|occurrence=1 · 0 introduced LOCfileManagedSettingsServi…fileManagedSettingsService.ts ×1 · 2 introduced LOCfileManagedSettingsServi…fileManagedSettingsService.ts ×2 · 5 introduced LOCfileManagedSettingsServi…fileManagedSettingsService.ts ×1 · 4 introduced LOCfileManagedSettingsServi…fileManagedSettingsService.ts ×1 · 2 introduced LOCfileManagedSettingsServi…fileManagedSettingsService.ts ×1 · 1 introduced LOCfileManagedSettingsServi…fileManagedSettingsService.ts ×1 · 3 introduced LOCfileManagedSettingsServi…fileManagedSettingsService.test|title=FileManagedSettingsService returns empty object when file does not exist|occurrence=1 · 0 introduced LOCfileManagedSettingsServi…fileManagedSettingsService.ts ×2 · 4 introduced LOCfileManagedSettingsServi…fileManagedSettingsService.ts ×6 · 25 introduced LOCfileManagedSettingsServi…fileManagedSettingsIpc.ts ×7 · 26 introduced LOCfileManagedSettingsIpc.t…copilotManagedSettings.ts ×1 · 2 introduced LOCcopilotManagedSettings.t…copilotManagedSettings.ts ×1 · 3 introduced LOCcopilotManagedSettings.t…copilotManagedSettings.ts ×3 · 16 introduced LOCcopilotManagedSettings.t…copilotManagedSettings.ts ×1 · 9 introduced LOCcopilotManagedSettings.t…fileManagedSettingsService.test|title=normalizeManagedSettings handles mixed scalar and structured keys|occurrence=1 · 0 introduced LOCfileManagedSettingsServi…fileManagedSettingsService.test|title=normalizeManagedSettings flattens scalar leaves to dot-paths|occurrence=1 · 0 introduced LOCfileManagedSettingsServi…fileManagedSettingsService.test|title=normalizeManagedSettings JSON-stringifies structured keys (enabledPlugins)|occurrence=1 · 0 introduced LOCfileManagedSettingsServi…fileManagedSettingsService.test|title=normalizeManagedSettings handles empty object|occurrence=1, fileManagedSettingsService.test|title=normalizeManagedSettings drops a structured key whose value is not an object|occurrence=1 · 0 introduced LOCfileManagedSettingsServi…copilotManagedSettings.ts ×1 · 5 introduced LOCcopilotManagedSettings.t…copilotManagedSettings.ts ×1 · 2 introduced LOCcopilotManagedSettings.t…copilotManagedSettings.ts ×1 · 2 introduced LOCcopilotManagedSettings.t…copilotManagedSettings.ts ×1 · 2 introduced LOCcopilotManagedSettings.t…copilotManagedSettings.ts ×15 · 70 introduced LOCcopilotManagedSettings.t…fileManagedSettingsIpc.ts ×7 · 95 introduced LOCfileManagedSettingsIpc.t…fileManagedSettingsService.test|title=FileManagedSettingsChannelClient keeps newer event state when the initial snapshot resolves later|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/platform/policy/test/common/fileManagedSettingsService.test|title=FileManagedSettingsChannelClient keeps newer event state when the initial snapshot resolves later|occurrence=1fileManagedSettingsServi…fileManagedSettingsService.test|title=FileManagedSettingsService clears managed settings and fires when the file is deleted|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/platform/policy/test/common/fileManagedSettingsService.test|title=FileManagedSettingsService clears managed settings and fires when the file is deleted|occurrence=1fileManagedSettingsServi…fileManagedSettingsService.test|title=FileManagedSettingsService fires event when file changes|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/platform/policy/test/common/fileManagedSettingsService.test|title=FileManagedSettingsService fires event when file changes|occurrence=1fileManagedSettingsServi…fileManagedSettingsService.test|title=FileManagedSettingsService reads managed-settings.json on startup|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/platform/policy/test/common/fileManagedSettingsService.test|title=FileManagedSettingsService reads managed-settings.json on startup|occurrence=1fileManagedSettingsServi…fileManagedSettingsService.test|title=FileManagedSettingsService retains raw settings that are absent from the normalized bag|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/platform/policy/test/common/fileManagedSettingsService.test|title=FileManagedSettingsService retains raw settings that are absent from the normalized bag|occurrence=1fileManagedSettingsServi…fileManagedSettingsService.test|title=FileManagedSettingsService returns empty object when file does not exist|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/platform/policy/test/common/fileManagedSettingsService.test|title=FileManagedSettingsService returns empty object when file does not exist|occurrence=1fileManagedSettingsServi…fileManagedSettingsService.test|title=FileManagedSettingsService returns empty object when the file is malformed JSON|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/platform/policy/test/common/fileManagedSettingsService.test|title=FileManagedSettingsService returns empty object when the file is malformed JSON|occurrence=1fileManagedSettingsServi…fileManagedSettingsService.test|title=FileManagedSettingsService returns empty object when the file is not a JSON object|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/platform/policy/test/common/fileManagedSettingsService.test|title=FileManagedSettingsService returns empty object when the file is not a JSON object|occurrence=1fileManagedSettingsServi…fileManagedSettingsService.test|title=normalizeManagedSettings JSON-stringifies structured keys (enabledPlugins)|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/platform/policy/test/common/fileManagedSettingsService.test|title=normalizeManagedSettings JSON-stringifies structured keys (enabledPlugins)|occurrence=1fileManagedSettingsServi…fileManagedSettingsService.test|title=normalizeManagedSettings drops a structured key whose value is not an object|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/platform/policy/test/common/fileManagedSettingsService.test|title=normalizeManagedSettings drops a structured key whose value is not an object|occurrence=1fileManagedSettingsServi…fileManagedSettingsService.test|title=normalizeManagedSettings drops malformed marketplace entries with warning|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/platform/policy/test/common/fileManagedSettingsService.test|title=normalizeManagedSettings drops malformed marketplace entries with warning|occurrence=1fileManagedSettingsServi…fileManagedSettingsService.test|title=normalizeManagedSettings flattens scalar leaves to dot-paths|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/platform/policy/test/common/fileManagedSettingsService.test|title=normalizeManagedSettings flattens scalar leaves to dot-paths|occurrence=1fileManagedSettingsServi…fileManagedSettingsService.test|title=normalizeManagedSettings flattens the model setting nested under permissions|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/platform/policy/test/common/fileManagedSettingsService.test|title=normalizeManagedSettings flattens the model setting nested under permissions|occurrence=1fileManagedSettingsServi…fileManagedSettingsService.test|title=normalizeManagedSettings handles empty object|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/platform/policy/test/common/fileManagedSettingsService.test|title=normalizeManagedSettings handles empty object|occurrence=1fileManagedSettingsServi…fileManagedSettingsService.test|title=normalizeManagedSettings handles mixed scalar and structured keys|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/platform/policy/test/common/fileManagedSettingsService.test|title=normalizeManagedSettings handles mixed scalar and structured keys|occurrence=1fileManagedSettingsServi…fileManagedSettingsService.test|title=normalizeManagedSettings normalizes extraKnownMarketplaces from schema format to config dict|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/platform/policy/test/common/fileManagedSettingsService.test|title=normalizeManagedSettings normalizes extraKnownMarketplaces from schema format to config dict|occurrence=1fileManagedSettingsServi…Focused file · src/vs/platform/policy/common/fileManagedSettingsService.ts · 92 LOCcommon/fileManagedSettin…

Graph controls are ready.

Interactive rendering requires JavaScript and WebGL. Use the related-file, concept, and source links on this page while the interactive map is unavailable.

1 > /*--------------------------------------------------------------------------------------------- fileManagedSettingsIpc.ts ×7
2 > * Copyright (c) Microsoft Corporation. All rights reserved.
3 > * Licensed under the MIT License. See License.txt in the project root for license information.
4 > *--------------------------------------------------------------------------------------------*/
5 >
6 > import { ThrottledDelayer } from '../../../base/common/async.js';
7 > import { Emitter, Event } from '../../../base/common/event.js';
8 > import { Disposable } from '../../../base/common/lifecycle.js';
9 > import { equals } from '../../../base/common/objects.js';
10 > import { ManagedSettingsData } from '../../../base/common/policy.js';
11 > import { isObject } from '../../../base/common/types.js';
12 > import { URI } from '../../../base/common/uri.js';
13 > import { FileOperationError, FileOperationResult, IFileService } from '../../files/common/files.js';
14 > import { ILogService } from '../../log/common/log.js';
15 > import { IFileManagedSettingsService, normalizeManagedSettings, RawManagedSettingsData } from './copilotManagedSettings.js';
16 >
17 > /**
18 > * Upper bound on the size of `managed-settings.json` we will read into the main process. A
19 > * legitimate settings file is a few KB; capping the read keeps a malformed or hostile file on the
20 > * (externally writable, privileged) well-known path from OOM-ing the main process. `readFile`
21 > * throws `FILE_TOO_LARGE` past this, which `refresh()` treats like any other read failure.
22 > */
23 > const MANAGED_SETTINGS_MAX_FILE_SIZE = 1024 * 1024; // 1 MB
24 >
25 > export class FileManagedSettingsService extends Disposable implements IFileManagedSettingsService {
26 >
27 > readonly _serviceBrand: undefined;
28 >
29 > private _rawManagedSettings: RawManagedSettingsData = {};
30 > get rawManagedSettings(): RawManagedSettingsData { return this._rawManagedSettings; }
31 >
32 > private _managedSettings: ManagedSettingsData = {};
33 > get managedSettings(): ManagedSettingsData { return this._managedSettings; }
34 >
35 > private readonly _onDidChangeRawManagedSettings = this._register(new Emitter<RawManagedSettingsData>());
36 > readonly onDidChangeRawManagedSettings = this._onDidChangeRawManagedSettings.event;
37 >
38 > private readonly _onDidChangeManagedSettings = this._register(new Emitter<ManagedSettingsData>());
39 > readonly onDidChangeManagedSettings = this._onDidChangeManagedSettings.event;
40 >
41 > private readonly throttledDelayer = this._register(new ThrottledDelayer(500));
42 >
43 > constructor(
44 > private readonly file: URI, fileManagedSettingsService.ts ×6
45 > @IFileService private readonly fileService: IFileService,
46 > @ILogService private readonly logService: ILogService,
47 > ) {
48 > super();
49 >
50 > const onDidChangeFile = Event.filter(fileService.onDidFilesChange, e => e.affects(file));
51 > this._register(fileService.watch(file));
52 > this._register(onDidChangeFile(() => this.throttledDelayer.trigger(() => this.refresh())));
53 >
54 > // Initial read — routed through the same delayer (with no delay) so it is serialized
55 > // against change-triggered refreshes and can't be clobbered by a racing read. Non-blocking;
56 > // IPC clients handle eventual data arrival.
57 > this.throttledDelayer.trigger(() => this.refresh(), 0);
58 > }
60 > private async refresh(): Promise<void> {
61 > const previousRaw = this._rawManagedSettings; fileManagedSettingsService.ts ×6
62 > const previous = this._managedSettings;
63 >
64 > try {
65 > const content = await this.fileService.readFile(this.file, { limits: { size: MANAGED_SETTINGS_MAX_FILE_SIZE } });
66 > const parsed = JSON.parse(content.value.toString()); fileManagedSettingsService.ts ×1
67 >
68 > if (isObject(parsed)) {
69 > this._rawManagedSettings = parsed as Record<string, unknown>; fileManagedSettingsService.ts ×2
70 > this._managedSettings = normalizeManagedSettings(parsed as Record<string, unknown>,
71 > msg => this.logService.warn(`[FileManagedSettingsService] ${msg}`));
73 > this.logService.warn('[FileManagedSettingsService] managed-settings.json is not a JSON object'); fileManagedSettingsService.ts ×1
74 > this._rawManagedSettings = {};
75 > this._managedSettings = {};
76 > }
77 > } catch (error) { fileManagedSettingsService.ts ×6
78 > if ((<FileOperationError>error).fileOperationResult !== FileOperationResult.FILE_NOT_FOUND) { fileManagedSettingsService.ts ×2
79 > this.logService.error('[FileManagedSettingsService] Failed to read managed-settings.json', error); fileManagedSettingsService.ts ×1
80 > }
81 > this._rawManagedSettings = {}; fileManagedSettingsService.ts ×2
82 > this._managedSettings = {};
83 > }
85 > if (!equals(previousRaw, this._rawManagedSettings)) {
86 > this._onDidChangeRawManagedSettings.fire(this._rawManagedSettings); fileManagedSettingsService.ts ×2
87 > }
88 > if (!equals(previous, this._managedSettings)) { fileManagedSettingsService.ts ×6
89 > this._onDidChangeManagedSettings.fire(this._managedSettings); fileManagedSettingsService.ts ×1
90 > }