mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-14 03:58:33 -05:00
Merge from vscode bead496a613e475819f89f08e9e882b841bc1fe8 (#14883)
* Merge from vscode bead496a613e475819f89f08e9e882b841bc1fe8 * Bump distro * Upgrade GCC to 4.9 due to yarn install errors * Update build image * Fix bootstrap base url * Bump distro * Fix build errors * Update source map file * Disable checkbox for blocking migration issues (#15131) * disable checkbox for blocking issues * wip * disable checkbox fixes * fix strings * Remove duplicate tsec command * Default to off for tab color if settings not present * re-skip failing tests * Fix mocha error * Bump sqlite version & fix notebooks search view * Turn off esbuild warnings * Update esbuild log level * Fix overflowactionbar tests * Fix ts-ignore in dropdown tests * cleanup/fixes * Fix hygiene * Bundle in entire zone.js module * Remove extra constructor param * bump distro for web compile break * bump distro for web compile break v2 * Undo log level change * New distro * Fix integration test scripts * remove the "no yarn.lock changes" workflow * fix scripts v2 * Update unit test scripts * Ensure ads-kerberos2 updates in .vscodeignore * Try fix unit tests * Upload crash reports * remove nogpu * always upload crashes * Use bash script * Consolidate data/ext dir names * Create in tmp directory Co-authored-by: chlafreniere <hichise@gmail.com> Co-authored-by: Christopher Suh <chsuh@microsoft.com> Co-authored-by: chgagnon <chgagnon@microsoft.com>
This commit is contained in:
@@ -8,10 +8,38 @@ import { ExtensionActivationTimesBuilder } from 'vs/workbench/api/common/extHost
|
||||
import { AbstractExtHostExtensionService } from 'vs/workbench/api/common/extHostExtensionService';
|
||||
import { URI } from 'vs/base/common/uri';
|
||||
import { RequireInterceptor } from 'vs/workbench/api/common/extHostRequireInterceptor';
|
||||
import { IExtensionDescription } from 'vs/platform/extensions/common/extensions';
|
||||
import { ExtensionIdentifier, IExtensionDescription } from 'vs/platform/extensions/common/extensions';
|
||||
import { ExtensionRuntime } from 'vs/workbench/api/common/extHostTypes';
|
||||
import { timeout } from 'vs/base/common/async';
|
||||
|
||||
namespace TrustedFunction {
|
||||
|
||||
// workaround a chrome issue not allowing to create new functions
|
||||
// see https://github.com/w3c/webappsec-trusted-types/wiki/Trusted-Types-for-function-constructor
|
||||
const ttpTrustedFunction = self.trustedTypes?.createPolicy('TrustedFunctionWorkaround', {
|
||||
createScript: (_, ...args: string[]) => {
|
||||
args.forEach((arg) => {
|
||||
if (!self.trustedTypes?.isScript(arg)) {
|
||||
throw new Error('TrustedScripts only, please');
|
||||
}
|
||||
});
|
||||
// NOTE: This is insecure without parsing the arguments and body,
|
||||
// Malicious inputs can escape the function body and execute immediately!
|
||||
const fnArgs = args.slice(0, -1).join(',');
|
||||
const fnBody = args.pop()!.toString();
|
||||
const body = `(function anonymous(${fnArgs}) {\n${fnBody}\n})`;
|
||||
return body;
|
||||
}
|
||||
});
|
||||
|
||||
export function create(...args: string[]): Function {
|
||||
if (!ttpTrustedFunction) {
|
||||
return new Function(...args);
|
||||
}
|
||||
return self.eval(ttpTrustedFunction.createScript('', ...args) as unknown as string);
|
||||
}
|
||||
}
|
||||
|
||||
class WorkerRequireInterceptor extends RequireInterceptor {
|
||||
|
||||
_installInterceptor() { }
|
||||
@@ -35,6 +63,8 @@ class WorkerRequireInterceptor extends RequireInterceptor {
|
||||
export class ExtHostExtensionService extends AbstractExtHostExtensionService {
|
||||
readonly extensionRuntime = ExtensionRuntime.Webworker;
|
||||
|
||||
private static _ttpExtensionScripts = self.trustedTypes?.createPolicy('ExtensionScripts', { createScript: source => source });
|
||||
|
||||
private _fakeModules?: WorkerRequireInterceptor;
|
||||
|
||||
protected async _beforeAlmostReadyToRunExtensions(): Promise<void> {
|
||||
@@ -42,6 +72,8 @@ export class ExtHostExtensionService extends AbstractExtHostExtensionService {
|
||||
const apiFactory = this._instaService.invokeFunction(createApiFactoryAndRegisterActors);
|
||||
this._fakeModules = this._instaService.createInstance(WorkerRequireInterceptor, apiFactory, this._registry);
|
||||
await this._fakeModules.install();
|
||||
performance.mark('code/extHost/didInitAPI');
|
||||
|
||||
await this._waitForDebuggerAttachment();
|
||||
}
|
||||
|
||||
@@ -49,10 +81,16 @@ export class ExtHostExtensionService extends AbstractExtHostExtensionService {
|
||||
return extensionDescription.browser;
|
||||
}
|
||||
|
||||
protected async _loadCommonJSModule<T>(module: URI, activationTimesBuilder: ExtensionActivationTimesBuilder): Promise<T> {
|
||||
protected async _loadCommonJSModule<T>(extensionId: ExtensionIdentifier | null, module: URI, activationTimesBuilder: ExtensionActivationTimesBuilder): Promise<T> {
|
||||
|
||||
module = module.with({ path: ensureSuffix(module.path, '.js') });
|
||||
if (extensionId) {
|
||||
performance.mark(`code/extHost/willFetchExtensionCode/${extensionId.value}`);
|
||||
}
|
||||
const response = await fetch(module.toString(true));
|
||||
if (extensionId) {
|
||||
performance.mark(`code/extHost/didFetchExtensionCode/${extensionId.value}`);
|
||||
}
|
||||
|
||||
if (response.status !== 200) {
|
||||
throw new Error(response.statusText);
|
||||
@@ -63,7 +101,25 @@ export class ExtHostExtensionService extends AbstractExtHostExtensionService {
|
||||
// Here we append #vscode-extension to serve as a marker, such that source maps
|
||||
// can be adjusted for the extra wrapping function.
|
||||
const sourceURL = `${module.toString(true)}#vscode-extension`;
|
||||
const initFn = new Function('module', 'exports', 'require', `${source}\n//# sourceURL=${sourceURL}`);
|
||||
const fullSource = `${source}\n//# sourceURL=${sourceURL}`;
|
||||
let initFn: Function;
|
||||
try {
|
||||
initFn = TrustedFunction.create(
|
||||
ExtHostExtensionService._ttpExtensionScripts?.createScript('module') as unknown as string ?? 'module',
|
||||
ExtHostExtensionService._ttpExtensionScripts?.createScript('exports') as unknown as string ?? 'exports',
|
||||
ExtHostExtensionService._ttpExtensionScripts?.createScript('require') as unknown as string ?? 'require',
|
||||
ExtHostExtensionService._ttpExtensionScripts?.createScript(fullSource) as unknown as string ?? fullSource
|
||||
);
|
||||
} catch (err) {
|
||||
if (extensionId) {
|
||||
console.error(`Loading code for extension ${extensionId.value} failed: ${err.message}`);
|
||||
} else {
|
||||
console.error(`Loading code failed: ${err.message}`);
|
||||
}
|
||||
console.error(`${module.toString(true)}${typeof err.line === 'number' ? ` line ${err.line}` : ''}${typeof err.column === 'number' ? ` column ${err.column}` : ''}`);
|
||||
console.error(err);
|
||||
throw err;
|
||||
}
|
||||
|
||||
// define commonjs globals: `module`, `exports`, and `require`
|
||||
const _exports = {};
|
||||
@@ -78,9 +134,15 @@ export class ExtHostExtensionService extends AbstractExtHostExtensionService {
|
||||
|
||||
try {
|
||||
activationTimesBuilder.codeLoadingStart();
|
||||
if (extensionId) {
|
||||
performance.mark(`code/extHost/willLoadExtensionCode/${extensionId.value}`);
|
||||
}
|
||||
initFn(_module, _exports, _require);
|
||||
return <T>(_module.exports !== _exports ? _module.exports : _exports);
|
||||
} finally {
|
||||
if (extensionId) {
|
||||
performance.mark(`code/extHost/didLoadExtensionCode/${extensionId.value}`);
|
||||
}
|
||||
activationTimesBuilder.codeLoadingStop();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user