Skip to content

Prepare for MRVA public beta #2144

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Mar 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 0 additions & 4 deletions docs/test-plan.md
Original file line number Diff line number Diff line change
Expand Up @@ -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).
Expand Down
2 changes: 2 additions & 0 deletions extensions/ql-vscode/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
12 changes: 5 additions & 7 deletions extensions/ql-vscode/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -1236,7 +1235,7 @@
},
{
"command": "codeQL.runVariantAnalysis",
"when": "config.codeQL.canary && editorLangId == ql && resourceExtname == .ql"
"when": "editorLangId == ql && resourceExtname == .ql"
},
{
"command": "codeQL.viewAst",
Expand Down Expand Up @@ -1281,8 +1280,7 @@
},
{
"id": "codeQLVariantAnalysisRepositories",
"name": "Variant Analysis Repositories",
"when": "config.codeQL.canary"
"name": "Variant Analysis Repositories"
},
{
"id": "codeQLQueryHistory",
Expand Down Expand Up @@ -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"
}
]
Expand Down
25 changes: 6 additions & 19 deletions extensions/ql-vscode/src/databases/db-module.ts
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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> {
Expand Down
28 changes: 11 additions & 17 deletions extensions/ql-vscode/src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -644,7 +644,7 @@ async function activateWithInstalledDistribution(
cliServer,
variantAnalysisStorageDir,
variantAnalysisResultsManager,
dbModule?.dbManager,
dbModule.dbManager,
);
ctx.subscriptions.push(variantAnalysisManager);
ctx.subscriptions.push(variantAnalysisResultsManager);
Expand Down Expand Up @@ -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",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { resolve } from "path";
import {
authentication,
commands,
ConfigurationTarget,
extensions,
TextDocument,
window,
Expand All @@ -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);

Expand All @@ -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({
Expand Down