Revert "Move MRVA out of canary "

This commit is contained in:
Charis Kyriakou
2023-03-01 17:02:11 +00:00
committed by GitHub
parent 56d283f6d5
commit dd2e79477f
10 changed files with 56 additions and 28 deletions

View File

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

View File

@@ -2,7 +2,6 @@
## [UNRELEASED]
- Enable multi-repository variant analysis. [#2121](https://github.com/github/vscode-codeql/pull/2121)
- Enable collection of telemetry concerning interactions with UI elements, including buttons, links, and other inputs. [#2114](https://github.com/github/vscode-codeql/pull/2114)
# 1.7.10 - 23 February 2023

View File

@@ -16,6 +16,10 @@ choose to go through some of the Optional Test Cases.
## Required Test Cases
### Pre-requisites
- Flip the `codeQL.canary` flag. This will enable MRVA in the extension.
### Test Case 1: MRVA - Running a problem path query and viewing results
1. Open the [UnsafeJQueryPlugin query](https://github.com/github/codeql/blob/main/javascript/ql/src/Security/CWE-079/UnsafeJQueryPlugin.ql).

View File

@@ -978,10 +978,11 @@
},
{
"command": "codeQL.runVariantAnalysis",
"when": "editorLangId == ql && resourceExtname == .ql"
"when": "config.codeQL.canary && editorLangId == ql && resourceExtname == .ql"
},
{
"command": "codeQL.exportSelectedVariantAnalysisResults"
"command": "codeQL.exportSelectedVariantAnalysisResults",
"when": "config.codeQL.canary"
},
{
"command": "codeQL.runQueries",
@@ -1235,7 +1236,7 @@
},
{
"command": "codeQL.runVariantAnalysis",
"when": "editorLangId == ql && resourceExtname == .ql"
"when": "config.codeQL.canary && editorLangId == ql && resourceExtname == .ql"
},
{
"command": "codeQL.viewAst",
@@ -1280,7 +1281,8 @@
},
{
"id": "codeQLVariantAnalysisRepositories",
"name": "Variant Analysis Repositories"
"name": "Variant Analysis Repositories",
"when": "config.codeQL.canary"
},
{
"id": "codeQLQueryHistory",

View File

@@ -1,11 +1,12 @@
import { window } from "vscode";
import { App } from "../common/app";
import { App, AppMode } from "../common/app";
import { extLogger } from "../common";
import { DisposableObject } from "../pure/disposable-object";
import { DbConfigStore } from "./config/db-config-store";
import { DbManager } from "./db-manager";
import { DbPanel } from "./ui/db-panel";
import { DbSelectionDecorationProvider } from "./ui/db-selection-decoration-provider";
import { isCanary } from "../config";
export class DbModule extends DisposableObject {
public readonly dbManager: DbManager;
@@ -18,12 +19,24 @@ export class DbModule extends DisposableObject {
this.dbManager = new DbManager(app, this.dbConfigStore);
}
public static async initialize(app: App): Promise<DbModule> {
const dbModule = new DbModule(app);
app.subscriptions.push(dbModule);
public static async initialize(app: App): Promise<DbModule | undefined> {
if (DbModule.shouldEnableModule(app.mode)) {
const dbModule = new DbModule(app);
app.subscriptions.push(dbModule);
await dbModule.initialize(app);
return dbModule;
await dbModule.initialize(app);
return dbModule;
}
return undefined;
}
private static shouldEnableModule(app: AppMode): boolean {
if (app === AppMode.Development || app === AppMode.Test) {
return true;
}
return isCanary();
}
private async initialize(app: App): Promise<void> {

View File

@@ -637,7 +637,7 @@ async function activateWithInstalledDistribution(
cliServer,
variantAnalysisStorageDir,
variantAnalysisResultsManager,
dbModule.dbManager,
dbModule?.dbManager,
);
ctx.subscriptions.push(variantAnalysisManager);
ctx.subscriptions.push(variantAnalysisResultsManager);
@@ -1121,17 +1121,23 @@ async function activateWithInstalledDistribution(
token: CancellationToken,
uri: Uri | undefined,
) => {
progress({
maxStep: 5,
step: 0,
message: "Getting credentials",
});
if (isCanary()) {
progress({
maxStep: 5,
step: 0,
message: "Getting credentials",
});
await variantAnalysisManager.runVariantAnalysis(
uri || window.activeTextEditor?.document.uri,
progress,
token,
);
await variantAnalysisManager.runVariantAnalysis(
uri || window.activeTextEditor?.document.uri,
progress,
token,
);
} else {
throw new Error(
"Variant analysis requires the CodeQL Canary version to run.",
);
}
},
{
title: "Run Variant Analysis",

View File

@@ -13,9 +13,9 @@ export interface RepositorySelection {
* @returns The user selection.
*/
export async function getRepositorySelection(
dbManager: DbManager,
dbManager?: DbManager,
): Promise<RepositorySelection> {
const selectedDbItem = dbManager.getSelectedDbItem();
const selectedDbItem = dbManager?.getSelectedDbItem();
if (selectedDbItem) {
switch (selectedDbItem.kind) {
case DbItemKind.LocalDatabase || DbItemKind.LocalList:

View File

@@ -223,7 +223,7 @@ export async function prepareRemoteQueryRun(
uri: Uri | undefined,
progress: ProgressCallback,
token: CancellationToken,
dbManager: DbManager,
dbManager?: DbManager,
): Promise<PreparedRemoteQuery> {
if (!uri?.fsPath.endsWith(".ql")) {
throw new UserCancellationException("Not a CodeQL query file.");

View File

@@ -105,7 +105,7 @@ export class VariantAnalysisManager
private readonly cliServer: CodeQLCliServer,
private readonly storagePath: string,
private readonly variantAnalysisResultsManager: VariantAnalysisResultsManager,
private readonly dbManager: DbManager,
private readonly dbManager?: DbManager,
) {
super();
this.variantAnalysisMonitor = this.push(

View File

@@ -3,6 +3,7 @@ import { resolve } from "path";
import {
authentication,
commands,
ConfigurationTarget,
extensions,
QuickPickItem,
TextDocument,
@@ -12,7 +13,10 @@ import {
import { CodeQLExtensionInterface } from "../../../../src/extension";
import { MockGitHubApiServer } from "../../../../src/mocks/mock-gh-api-server";
import { setRemoteControllerRepo } from "../../../../src/config";
import {
CANARY_FEATURES,
setRemoteControllerRepo,
} from "../../../../src/config";
jest.setTimeout(30_000);
@@ -35,6 +39,7 @@ describe("Variant Analysis Submission Integration", () => {
let showErrorMessageSpy: jest.SpiedFunction<typeof window.showErrorMessage>;
beforeEach(async () => {
await CANARY_FEATURES.updateValue(true, ConfigurationTarget.Global);
await setRemoteControllerRepo("github/vscode-codeql");
jest.spyOn(authentication, "getSession").mockResolvedValue({