Skip to content

Commit

Permalink
- CSP: force https only when outer page is on https too
Browse files Browse the repository at this point in the history
- bring back wrapping the web worker in an `<iframe>` by default
  • Loading branch information
alexdima committed Sep 29, 2020
1 parent 8348d2f commit 0580328
Showing 1 changed file with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,11 @@ export class WebWorkerExtensionHost extends Disposable implements IExtensionHost
}

private _wrapInIframe(): boolean {
return false;
if (this._environmentService.options && typeof this._environmentService.options._wrapWebWorkerExtHostInIframe === 'boolean') {
return this._environmentService.options._wrapWebWorkerExtHostInIframe;
}
// wrap in <iframe> by default
return true;
}

public async start(): Promise<IMessagePassingProtocol> {
Expand Down Expand Up @@ -102,11 +106,11 @@ export class WebWorkerExtensionHost extends Disposable implements IExtensionHost
const escapeAttribute = (value: string): string => {
return value.replace(/"/g, '&quot;');
};
const isBuilt = this._environmentService.isBuilt;
const forceHTTPS = (location.protocol === 'https:');
const html = `<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Security-Policy" content="default-src 'none'; script-src 'unsafe-eval' '${WEB_WORKER_IFRAME.sha}' ${isBuilt ? 'https:' : 'http: https:'}; worker-src data:; connect-src ${isBuilt ? 'https:' : 'http: https:'}" />
<meta http-equiv="Content-Security-Policy" content="default-src 'none'; script-src 'unsafe-eval' '${WEB_WORKER_IFRAME.sha}' ${forceHTTPS ? 'https:' : 'http: https:'}; worker-src data:; connect-src ${forceHTTPS ? 'https:' : 'http: https:'}" />
<meta id="vscode-worker-src" data-value="${escapeAttribute(workerSrc)}" />
<meta id="vscode-web-worker-ext-host-id" data-value="${escapeAttribute(vscodeWebWorkerExtHostId)}" />
</head>
Expand Down

0 comments on commit 0580328

Please sign in to comment.