Skip to content

Commit dd2e794

Browse files
authored
Revert "Move MRVA out of canary "
1 parent 56d283f commit dd2e794

File tree

10 files changed

+56
-28
lines changed

10 files changed

+56
-28
lines changed

README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ To see what has changed in the last few versions of the extension, see the [Chan
1515
* Shows the flow of data through the results of path queries, which is essential for triaging security results.
1616
* Provides an easy way to run queries from the large, open source repository of [CodeQL security queries](https://github.com/github/codeql).
1717
* Adds IntelliSense to support you writing and editing your own CodeQL query and library files.
18-
* Supports you running CodeQL queries against thousands of repositories on GitHub using multi-repository variant analysis.
1918

2019
## Project goals and scope
2120

extensions/ql-vscode/CHANGELOG.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
## [UNRELEASED]
44

5-
- Enable multi-repository variant analysis. [#2121](https://github.com/github/vscode-codeql/pull/2121)
65
- Enable collection of telemetry concerning interactions with UI elements, including buttons, links, and other inputs. [#2114](https://github.com/github/vscode-codeql/pull/2114)
76

87
# 1.7.10 - 23 February 2023

extensions/ql-vscode/docs/test-plan.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@ choose to go through some of the Optional Test Cases.
1616

1717
## Required Test Cases
1818

19+
### Pre-requisites
20+
21+
- Flip the `codeQL.canary` flag. This will enable MRVA in the extension.
22+
1923
### Test Case 1: MRVA - Running a problem path query and viewing results
2024

2125
1. Open the [UnsafeJQueryPlugin query](https://github.com/github/codeql/blob/main/javascript/ql/src/Security/CWE-079/UnsafeJQueryPlugin.ql).

extensions/ql-vscode/package.json

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -978,10 +978,11 @@
978978
},
979979
{
980980
"command": "codeQL.runVariantAnalysis",
981-
"when": "editorLangId == ql && resourceExtname == .ql"
981+
"when": "config.codeQL.canary && editorLangId == ql && resourceExtname == .ql"
982982
},
983983
{
984-
"command": "codeQL.exportSelectedVariantAnalysisResults"
984+
"command": "codeQL.exportSelectedVariantAnalysisResults",
985+
"when": "config.codeQL.canary"
985986
},
986987
{
987988
"command": "codeQL.runQueries",
@@ -1235,7 +1236,7 @@
12351236
},
12361237
{
12371238
"command": "codeQL.runVariantAnalysis",
1238-
"when": "editorLangId == ql && resourceExtname == .ql"
1239+
"when": "config.codeQL.canary && editorLangId == ql && resourceExtname == .ql"
12391240
},
12401241
{
12411242
"command": "codeQL.viewAst",
@@ -1280,7 +1281,8 @@
12801281
},
12811282
{
12821283
"id": "codeQLVariantAnalysisRepositories",
1283-
"name": "Variant Analysis Repositories"
1284+
"name": "Variant Analysis Repositories",
1285+
"when": "config.codeQL.canary"
12841286
},
12851287
{
12861288
"id": "codeQLQueryHistory",

extensions/ql-vscode/src/databases/db-module.ts

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
import { window } from "vscode";
2-
import { App } from "../common/app";
2+
import { App, AppMode } from "../common/app";
33
import { extLogger } from "../common";
44
import { DisposableObject } from "../pure/disposable-object";
55
import { DbConfigStore } from "./config/db-config-store";
66
import { DbManager } from "./db-manager";
77
import { DbPanel } from "./ui/db-panel";
88
import { DbSelectionDecorationProvider } from "./ui/db-selection-decoration-provider";
9+
import { isCanary } from "../config";
910

1011
export class DbModule extends DisposableObject {
1112
public readonly dbManager: DbManager;
@@ -18,12 +19,24 @@ export class DbModule extends DisposableObject {
1819
this.dbManager = new DbManager(app, this.dbConfigStore);
1920
}
2021

21-
public static async initialize(app: App): Promise<DbModule> {
22-
const dbModule = new DbModule(app);
23-
app.subscriptions.push(dbModule);
22+
public static async initialize(app: App): Promise<DbModule | undefined> {
23+
if (DbModule.shouldEnableModule(app.mode)) {
24+
const dbModule = new DbModule(app);
25+
app.subscriptions.push(dbModule);
2426

25-
await dbModule.initialize(app);
26-
return dbModule;
27+
await dbModule.initialize(app);
28+
return dbModule;
29+
}
30+
31+
return undefined;
32+
}
33+
34+
private static shouldEnableModule(app: AppMode): boolean {
35+
if (app === AppMode.Development || app === AppMode.Test) {
36+
return true;
37+
}
38+
39+
return isCanary();
2740
}
2841

2942
private async initialize(app: App): Promise<void> {

extensions/ql-vscode/src/extension.ts

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -637,7 +637,7 @@ async function activateWithInstalledDistribution(
637637
cliServer,
638638
variantAnalysisStorageDir,
639639
variantAnalysisResultsManager,
640-
dbModule.dbManager,
640+
dbModule?.dbManager,
641641
);
642642
ctx.subscriptions.push(variantAnalysisManager);
643643
ctx.subscriptions.push(variantAnalysisResultsManager);
@@ -1121,17 +1121,23 @@ async function activateWithInstalledDistribution(
11211121
token: CancellationToken,
11221122
uri: Uri | undefined,
11231123
) => {
1124-
progress({
1125-
maxStep: 5,
1126-
step: 0,
1127-
message: "Getting credentials",
1128-
});
1124+
if (isCanary()) {
1125+
progress({
1126+
maxStep: 5,
1127+
step: 0,
1128+
message: "Getting credentials",
1129+
});
11291130

1130-
await variantAnalysisManager.runVariantAnalysis(
1131-
uri || window.activeTextEditor?.document.uri,
1132-
progress,
1133-
token,
1134-
);
1131+
await variantAnalysisManager.runVariantAnalysis(
1132+
uri || window.activeTextEditor?.document.uri,
1133+
progress,
1134+
token,
1135+
);
1136+
} else {
1137+
throw new Error(
1138+
"Variant analysis requires the CodeQL Canary version to run.",
1139+
);
1140+
}
11351141
},
11361142
{
11371143
title: "Run Variant Analysis",

extensions/ql-vscode/src/variant-analysis/repository-selection.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@ export interface RepositorySelection {
1313
* @returns The user selection.
1414
*/
1515
export async function getRepositorySelection(
16-
dbManager: DbManager,
16+
dbManager?: DbManager,
1717
): Promise<RepositorySelection> {
18-
const selectedDbItem = dbManager.getSelectedDbItem();
18+
const selectedDbItem = dbManager?.getSelectedDbItem();
1919
if (selectedDbItem) {
2020
switch (selectedDbItem.kind) {
2121
case DbItemKind.LocalDatabase || DbItemKind.LocalList:

extensions/ql-vscode/src/variant-analysis/run-remote-query.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ export async function prepareRemoteQueryRun(
223223
uri: Uri | undefined,
224224
progress: ProgressCallback,
225225
token: CancellationToken,
226-
dbManager: DbManager,
226+
dbManager?: DbManager,
227227
): Promise<PreparedRemoteQuery> {
228228
if (!uri?.fsPath.endsWith(".ql")) {
229229
throw new UserCancellationException("Not a CodeQL query file.");

extensions/ql-vscode/src/variant-analysis/variant-analysis-manager.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ export class VariantAnalysisManager
105105
private readonly cliServer: CodeQLCliServer,
106106
private readonly storagePath: string,
107107
private readonly variantAnalysisResultsManager: VariantAnalysisResultsManager,
108-
private readonly dbManager: DbManager,
108+
private readonly dbManager?: DbManager,
109109
) {
110110
super();
111111
this.variantAnalysisMonitor = this.push(

extensions/ql-vscode/test/vscode-tests/cli-integration/variant-analysis/variant-analysis-submission-integration.test.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { resolve } from "path";
33
import {
44
authentication,
55
commands,
6+
ConfigurationTarget,
67
extensions,
78
QuickPickItem,
89
TextDocument,
@@ -12,7 +13,10 @@ import {
1213

1314
import { CodeQLExtensionInterface } from "../../../../src/extension";
1415
import { MockGitHubApiServer } from "../../../../src/mocks/mock-gh-api-server";
15-
import { setRemoteControllerRepo } from "../../../../src/config";
16+
import {
17+
CANARY_FEATURES,
18+
setRemoteControllerRepo,
19+
} from "../../../../src/config";
1620

1721
jest.setTimeout(30_000);
1822

@@ -35,6 +39,7 @@ describe("Variant Analysis Submission Integration", () => {
3539
let showErrorMessageSpy: jest.SpiedFunction<typeof window.showErrorMessage>;
3640

3741
beforeEach(async () => {
42+
await CANARY_FEATURES.updateValue(true, ConfigurationTarget.Global);
3843
await setRemoteControllerRepo("github/vscode-codeql");
3944

4045
jest.spyOn(authentication, "getSession").mockResolvedValue({

0 commit comments

Comments
 (0)