src/vs/base/common/managedSettings.ts
72 LOC · 66 covered · 6 uncovered · 8 ranges · 1363 concepts · 4 introducers · 766 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.
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.
/*---------------------------------------------------------------------------------------------
managedSettings.ts ×2
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
/**
* A single enterprise-managed marketplace entry, preserving the marketplace
* name (used as `displayLabel`) and the original `source` discriminator.
*/
export type IExtraKnownMarketplaceEntry =
| { readonly name: string; readonly source: { readonly source: 'github'; readonly repo: string; readonly ref?: string } }
| { readonly name: string; readonly source: { readonly source: 'git'; readonly url: string; readonly ref?: string } };
/**
* A single entry in the enterprise-managed `strictKnownMarketplaces` allowlist
* (the `chat.plugins.strictMarketplaces` setting), a discriminated union on
* `source`. Delivered as JSON via managed settings (the server endpoint or
* native MDM) and validated at match time, so the optional fields are only
* meaningful for their corresponding `source`.
*/
export interface IStrictMarketplaceSource {
readonly source: 'github' | 'git' | 'url' | 'npm' | 'file' | 'directory' | 'hostPattern' | 'pathPattern';
readonly repo?: string;
readonly url?: string;
readonly ref?: string;
readonly path?: string;
readonly package?: string;
readonly hostPattern?: string;
readonly pathPattern?: string;
readonly headers?: Readonly<Record<string, string>>;
}
/**
* Converts an {@link IExtraKnownMarketplaceEntry} array into the
* `{ [name]: url-or-shorthand }` dict stored on the `chat.plugins.extraMarketplaces`
* setting (and carried as the canonical JSON value of the `extraKnownMarketplaces`
* managed setting across both the server endpoint and native MDM delivery).
*
* Plain-string entries (allowed by the policy schema but unnamed) are stored with
* the value used as both key and value so they survive the round-trip intact.
*
* Marketplace names come from managed settings (untrusted input) and are written as object keys,
* so `__proto__` / `constructor` / `prototype` keys are skipped to avoid prototype pollution
* (mirroring the guard in the managed-settings normalizer's string-map encoder).
*/
export function extraKnownMarketplacesToConfigDict(entries: readonly (string | IExtraKnownMarketplaceEntry)[] | undefined): Record<string, string> | undefined {
}
for (const entry of entries) {
if (typeof entry === 'string') {
if (isUnsafeMarketplaceKey(entry)) {
continue;
}
obj[entry] = entry;
if (isUnsafeMarketplaceKey(entry.name)) {
continue;
}
const base = s.source === 'github' ? s.repo : s.url;
obj[entry.name] = s.ref ? `${base}#${s.ref}` : base;
}
}
return obj;
}
/** Whether a marketplace name would pollute the prototype chain if used as an object key. */
return key === '__proto__' || key === 'constructor' || key === 'prototype';
}