Merge pull request #2144 from github/charisk/mrva-public-beta

Prepare for MRVA public beta
This commit is contained in:
Charis Kyriakou
2023-03-08 12:21:40 +00:00
committed by GitHub
10 changed files with 30 additions and 57 deletions

View File

@@ -15,6 +15,7 @@ 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

@@ -18,10 +18,6 @@ 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

@@ -3,6 +3,8 @@
## [UNRELEASED]
- Send telemetry about unhandled errors happening within the extension. [#2125](https://github.com/github/vscode-codeql/pull/2125)
- 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.11 - 1 March 2023

View File

@@ -978,11 +978,10 @@
},
{
"command": "codeQL.runVariantAnalysis",
"when": "config.codeQL.canary && editorLangId == ql && resourceExtname == .ql"
"when": "editorLangId == ql && resourceExtname == .ql"
},
{
"command": "codeQL.exportSelectedVariantAnalysisResults",
"when": "config.codeQL.canary"
"command": "codeQL.exportSelectedVariantAnalysisResults"
},
{
"command": "codeQL.runQueries",
@@ -1236,7 +1235,7 @@
},
{
"command": "codeQL.runVariantAnalysis",
"when": "config.codeQL.canary && editorLangId == ql && resourceExtname == .ql"
"when": "editorLangId == ql && resourceExtname == .ql"
},
{
"command": "codeQL.viewAst",
@@ -1281,8 +1280,7 @@
},
{
"id": "codeQLVariantAnalysisRepositories",
"name": "Variant Analysis Repositories",
"when": "config.codeQL.canary"
"name": "Variant Analysis Repositories"
},
{
"id": "codeQLQueryHistory",
@@ -1318,7 +1316,7 @@
},
{
"view": "codeQLVariantAnalysisRepositories",
"contents": "Set up a controller repository to start using variant analysis.\n[Set up controller repository](command:codeQLVariantAnalysisRepositories.setupControllerRepository)",
"contents": "Set up a controller repository to start using variant analysis. [Learn more](https://codeql.github.com/docs/codeql-for-visual-studio-code/running-codeql-queries-at-scale-with-mrva#controller-repository) about controller repositories. \n[Set up controller repository](command:codeQLVariantAnalysisRepositories.setupControllerRepository)",
"when": "!config.codeQL.variantAnalysis.controllerRepo"
}
]

View File

@@ -1,12 +1,11 @@
import { window } from "vscode";
import { App, AppMode } from "../common/app";
import { App } 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;
@@ -19,24 +18,12 @@ export class DbModule extends DisposableObject {
this.dbManager = new DbManager(app, this.dbConfigStore);
}
public static async initialize(app: App): Promise<DbModule | undefined> {
if (DbModule.shouldEnableModule(app.mode)) {
const dbModule = new DbModule(app);
app.subscriptions.push(dbModule);
public static async initialize(app: App): Promise<DbModule> {
const dbModule = new DbModule(app);
app.subscriptions.push(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();
await dbModule.initialize(app);
return dbModule;
}
private async initialize(app: App): Promise<void> {

View File

@@ -644,7 +644,7 @@ async function activateWithInstalledDistribution(
cliServer,
variantAnalysisStorageDir,
variantAnalysisResultsManager,
dbModule?.dbManager,
dbModule.dbManager,
);
ctx.subscriptions.push(variantAnalysisManager);
ctx.subscriptions.push(variantAnalysisResultsManager);
@@ -1134,23 +1134,17 @@ async function activateWithInstalledDistribution(
token: CancellationToken,
uri: Uri | undefined,
) => {
if (isCanary()) {
progress({
maxStep: 5,
step: 0,
message: "Getting credentials",
});
progress({
maxStep: 5,
step: 0,
message: "Getting credentials",
});
await variantAnalysisManager.runVariantAnalysis(
uri || window.activeTextEditor?.document.uri,
progress,
token,
);
} else {
throw new Error(
"Variant analysis requires the CodeQL Canary version to run.",
);
}
await variantAnalysisManager.runVariantAnalysis(
uri || window.activeTextEditor?.document.uri,
progress,
token,
);
},
{
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,7 +3,6 @@ import { resolve } from "path";
import {
authentication,
commands,
ConfigurationTarget,
extensions,
TextDocument,
window,
@@ -13,10 +12,7 @@ import {
import { CodeQLExtensionInterface } from "../../../../src/extension";
import { MockGitHubApiServer } from "../../../../src/mocks/mock-gh-api-server";
import { mockedQuickPickItem } from "../../utils/mocking.helpers";
import {
CANARY_FEATURES,
setRemoteControllerRepo,
} from "../../../../src/config";
import { setRemoteControllerRepo } from "../../../../src/config";
jest.setTimeout(30_000);
@@ -39,7 +35,6 @@ 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({