Skip to content

Commit d3e6453

Browse files
committed
Only allow WASM execution in results view
1 parent bc51e74 commit d3e6453

File tree

3 files changed

+10
-1
lines changed

3 files changed

+10
-1
lines changed

extensions/ql-vscode/src/abstract-webview.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ export type WebviewPanelConfig = {
2424
view: WebviewView;
2525
preserveFocus?: boolean;
2626
additionalOptions?: WebviewPanelOptions & WebviewOptions;
27+
allowWasmEval?: boolean;
2728
};
2829

2930
export abstract class AbstractWebview<
@@ -116,6 +117,7 @@ export abstract class AbstractWebview<
116117
config.view,
117118
{
118119
allowInlineStyles: true,
120+
allowWasmEval: config.allowWasmEval ?? false,
119121
},
120122
);
121123
this.push(

extensions/ql-vscode/src/interface-utils.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,10 +129,13 @@ export function getHtmlForWebview(
129129
view: WebviewView,
130130
{
131131
allowInlineStyles,
132+
allowWasmEval,
132133
}: {
133134
allowInlineStyles?: boolean;
135+
allowWasmEval?: boolean;
134136
} = {
135137
allowInlineStyles: false,
138+
allowWasmEval: false,
136139
},
137140
): string {
138141
const scriptUriOnDisk = Uri.file(ctx.asAbsolutePath("out/webview.js"));
@@ -172,7 +175,9 @@ export function getHtmlForWebview(
172175
<html>
173176
<head>
174177
<meta http-equiv="Content-Security-Policy"
175-
content="default-src 'none'; script-src 'nonce-${nonce}' 'wasm-unsafe-eval'; font-src ${fontSrc}; style-src ${styleSrc}; connect-src ${
178+
content="default-src 'none'; script-src 'nonce-${nonce}'${
179+
allowWasmEval ? " 'wasm-unsafe-eval'" : ""
180+
}; font-src ${fontSrc}; style-src ${styleSrc}; connect-src ${
176181
webview.cspSource
177182
};">
178183
${stylesheetsHtmlLines.join(` ${EOL}`)}

extensions/ql-vscode/src/interface.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,8 @@ export class ResultsView extends AbstractWebview<
221221
viewColumn: this.chooseColumnForWebview(),
222222
preserveFocus: true,
223223
view: "results",
224+
// Required for the graph viewer which is using d3-graphviz WASM module
225+
allowWasmEval: true,
224226
};
225227
}
226228

0 commit comments

Comments
 (0)