Merge branch 'main' into robertbrignull/remoteResultsItemWithoutLogs

This commit is contained in:
Robert
2023-03-10 10:29:47 +00:00
committed by GitHub
12 changed files with 244 additions and 57 deletions

View File

@@ -2,6 +2,8 @@ name: "CodeQL config"
queries:
- name: Run standard queries
uses: security-and-quality
- name: Experimental queries
uses: security-experimental
- name: Run custom javascript queries
uses: ./.github/codeql/queries
paths:

View File

@@ -1,6 +1,8 @@
# CodeQL for Visual Studio Code: Changelog
## 1.8.0 - 8 March 2023
## [UNRELEASED]
## 1.8.0 - 9 March 2023
- Send telemetry about unhandled errors happening within the extension. [#2125](https://github.com/github/vscode-codeql/pull/2125)
- Enable multi-repository variant analysis. [#2144](https://github.com/github/vscode-codeql/pull/2144)

View File

@@ -93,12 +93,6 @@ export async function deployPackage(
);
await copyPackage(sourcePath, distPath);
// This is necessary for vsce to know the dependencies
await copyDirectory(
resolve(sourcePath, "node_modules"),
resolve(distPath, "node_modules"),
);
return {
distPath,
name: packageJson.name,

View File

@@ -17,6 +17,7 @@ export async function packageExtension(): Promise<void> {
"..",
`${deployedPackage.name}-${deployedPackage.version}.vsix`,
),
"--no-dependencies",
];
const proc = spawn(resolve(__dirname, "../node_modules/.bin/vsce"), args, {
cwd: deployedPackage.distPath,

View File

@@ -1,12 +1,12 @@
{
"name": "vscode-codeql",
"version": "1.8.0",
"version": "1.8.1",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"name": "vscode-codeql",
"version": "1.8.0",
"version": "1.8.1",
"hasInstallScript": true,
"license": "MIT",
"dependencies": {

View File

@@ -4,7 +4,7 @@
"description": "CodeQL for Visual Studio Code",
"author": "GitHub",
"private": true,
"version": "1.8.0",
"version": "1.8.1",
"publisher": "GitHub",
"license": "MIT",
"icon": "media/VS-marketplace-CodeQL-icon.png",
@@ -44,11 +44,6 @@
"onView:test-explorer",
"onCommand:codeQL.checkForUpdatesToCLI",
"onCommand:codeQL.authenticateToGitHub",
"onCommand:codeQLDatabases.chooseDatabaseFolder",
"onCommand:codeQLDatabases.chooseDatabaseArchive",
"onCommand:codeQLDatabases.chooseDatabaseInternet",
"onCommand:codeQLDatabases.chooseDatabaseGithub",
"onCommand:codeQL.setCurrentDatabase",
"onCommand:codeQL.viewAst",
"onCommand:codeQL.viewCfg",
"onCommand:codeQL.openReferencedFile",
@@ -57,16 +52,6 @@
"onCommand:codeQL.chooseDatabaseArchive",
"onCommand:codeQL.chooseDatabaseInternet",
"onCommand:codeQL.chooseDatabaseGithub",
"onCommand:codeQLDatabases.chooseDatabase",
"onCommand:codeQLDatabases.setCurrentDatabase",
"onCommand:codeQLVariantAnalysisRepositories.openConfigFile",
"onCommand:codeQLVariantAnalysisRepositories.addNewDatabase",
"onCommand:codeQLVariantAnalysisRepositories.addNewList",
"onCommand:codeQLVariantAnalysisRepositories.setSelectedItem",
"onCommand:codeQLVariantAnalysisRepositories.setSelectedItemContextMenu",
"onCommand:codeQLVariantAnalysisRepositories.renameItemContextMenu",
"onCommand:codeQLVariantAnalysisRepositories.openOnGitHubContextMenu",
"onCommand:codeQLVariantAnalysisRepositories.removeItemContextMenu",
"onCommand:codeQL.quickQuery",
"onCommand:codeQL.restartQueryServer",
"onWebviewPanel:resultsView",
@@ -322,6 +307,10 @@
"command": "codeQL.runVariantAnalysis",
"title": "CodeQL: Run Variant Analysis"
},
{
"command": "codeQL.runVariantAnalysisContextEditor",
"title": "CodeQL: Run Variant Analysis"
},
{
"command": "codeQL.exportSelectedVariantAnalysisResults",
"title": "CodeQL: Export Variant Analysis Results"
@@ -334,10 +323,22 @@
"command": "codeQL.quickEval",
"title": "CodeQL: Quick Evaluation"
},
{
"command": "codeQL.quickEvalContextEditor",
"title": "CodeQL: Quick Evaluation"
},
{
"command": "codeQL.openReferencedFile",
"title": "CodeQL: Open Referenced File"
},
{
"command": "codeQL.openReferencedFileContextEditor",
"title": "CodeQL: Open Referenced File"
},
{
"command": "codeQL.openReferencedFileContextExplorer",
"title": "CodeQL: Open Referenced File"
},
{
"command": "codeQL.previewQueryHelp",
"title": "CodeQL: Preview Query Help"
@@ -433,10 +434,26 @@
"command": "codeQL.viewAst",
"title": "CodeQL: View AST"
},
{
"command": "codeQL.viewAstContextExplorer",
"title": "CodeQL: View AST"
},
{
"command": "codeQL.viewAstContextEditor",
"title": "CodeQL: View AST"
},
{
"command": "codeQL.viewCfg",
"title": "CodeQL: View CFG"
},
{
"command": "codeQL.viewCfgContextExplorer",
"title": "CodeQL: View CFG"
},
{
"command": "codeQL.viewCfgContextEditor",
"title": "CodeQL: View CFG"
},
{
"command": "codeQL.upgradeCurrentDatabase",
"title": "CodeQL: Upgrade Current Database"
@@ -930,12 +947,12 @@
"when": "resourceScheme == codeql-zip-archive || explorerResourceIsFolder || resourceExtname == .zip"
},
{
"command": "codeQL.viewAst",
"command": "codeQL.viewAstContextExplorer",
"group": "9_qlCommands",
"when": "resourceScheme == codeql-zip-archive && !explorerResourceIsFolder && !listMultiSelection"
},
{
"command": "codeQL.viewCfg",
"command": "codeQL.viewCfgContextExplorer",
"group": "9_qlCommands",
"when": "resourceScheme == codeql-zip-archive && config.codeQL.canary"
},
@@ -945,7 +962,7 @@
"when": "resourceScheme != codeql-zip-archive"
},
{
"command": "codeQL.openReferencedFile",
"command": "codeQL.openReferencedFileContextExplorer",
"group": "9_qlCommands",
"when": "resourceExtname == .qlref"
},
@@ -981,7 +998,8 @@
"when": "editorLangId == ql && resourceExtname == .ql"
},
{
"command": "codeQL.exportSelectedVariantAnalysisResults"
"command": "codeQL.runVariantAnalysisContextEditor",
"when": "false"
},
{
"command": "codeQL.runQueries",
@@ -991,10 +1009,22 @@
"command": "codeQL.quickEval",
"when": "editorLangId == ql"
},
{
"command": "codeQL.quickEvalContextEditor",
"when": "false"
},
{
"command": "codeQL.openReferencedFile",
"when": "resourceExtname == .qlref"
},
{
"command": "codeQL.openReferencedFileContextEditor",
"when": "false"
},
{
"command": "codeQL.openReferencedFileContextExplorer",
"when": "false"
},
{
"command": "codeQL.previewQueryHelp",
"when": "resourceExtname == .qhelp && isWorkspaceTrusted"
@@ -1007,10 +1037,26 @@
"command": "codeQL.viewAst",
"when": "resourceScheme == codeql-zip-archive"
},
{
"command": "codeQL.viewAstContextEditor",
"when": "false"
},
{
"command": "codeQL.viewAstContextExplorer",
"when": "false"
},
{
"command": "codeQL.viewCfg",
"when": "resourceScheme == codeql-zip-archive && config.codeQL.canary"
},
{
"command": "codeQL.viewCfgContextExplorer",
"when": "false"
},
{
"command": "codeQL.viewCfgContextEditor",
"when": "false"
},
{
"command": "codeQLVariantAnalysisRepositories.openConfigFile",
"when": "false"
@@ -1234,23 +1280,23 @@
"when": "editorLangId == ql && resourceExtname == .ql"
},
{
"command": "codeQL.runVariantAnalysis",
"command": "codeQL.runVariantAnalysisContextEditor",
"when": "editorLangId == ql && resourceExtname == .ql"
},
{
"command": "codeQL.viewAst",
"command": "codeQL.viewAstContextEditor",
"when": "resourceScheme == codeql-zip-archive"
},
{
"command": "codeQL.viewCfg",
"command": "codeQL.viewCfgContextEditor",
"when": "resourceScheme == codeql-zip-archive && config.codeQL.canary"
},
{
"command": "codeQL.quickEval",
"command": "codeQL.quickEvalContextEditor",
"when": "editorLangId == ql"
},
{
"command": "codeQL.openReferencedFile",
"command": "codeQL.openReferencedFileContextEditor",
"when": "resourceExtname == .qlref"
},
{

View File

@@ -1074,6 +1074,7 @@ async function activateWithInstalledDistribution(
queryServerLogger,
),
);
ctx.subscriptions.push(
commandRunnerWithProgress(
"codeQL.quickEval",
@@ -1091,6 +1092,24 @@ async function activateWithInstalledDistribution(
),
);
// Since we are tracking extension usage through commands, this command mirrors the "codeQL.quickEval" command
ctx.subscriptions.push(
commandRunnerWithProgress(
"codeQL.quickEvalContextEditor",
async (
progress: ProgressCallback,
token: CancellationToken,
uri: Uri | undefined,
) => await compileAndRunQuery(true, uri, progress, token, undefined),
{
title: "Running query",
cancellable: true,
},
// Open the query server logger on error since that's usually where the interesting errors appear.
queryServerLogger,
),
);
ctx.subscriptions.push(
commandRunnerWithProgress(
"codeQL.codeLensQuickEval",
@@ -1125,7 +1144,24 @@ async function activateWithInstalledDistribution(
),
);
// The "runVariantAnalysis" command is internal-only.
async function runVariantAnalysis(
progress: ProgressCallback,
token: CancellationToken,
uri: Uri | undefined,
): Promise<void> {
progress({
maxStep: 5,
step: 0,
message: "Getting credentials",
});
await variantAnalysisManager.runVariantAnalysis(
uri || window.activeTextEditor?.document.uri,
progress,
token,
);
}
ctx.subscriptions.push(
commandRunnerWithProgress(
"codeQL.runVariantAnalysis",
@@ -1133,19 +1169,23 @@ async function activateWithInstalledDistribution(
progress: ProgressCallback,
token: CancellationToken,
uri: Uri | undefined,
) => {
progress({
maxStep: 5,
step: 0,
message: "Getting credentials",
});
await variantAnalysisManager.runVariantAnalysis(
uri || window.activeTextEditor?.document.uri,
progress,
token,
);
) => await runVariantAnalysis(progress, token, uri),
{
title: "Run Variant Analysis",
cancellable: true,
},
),
);
// Since we are tracking extension usage through commands, this command mirrors the "codeQL.runVariantAnalysis" command
ctx.subscriptions.push(
commandRunnerWithProgress(
"codeQL.runVariantAnalysisContextEditor",
async (
progress: ProgressCallback,
token: CancellationToken,
uri: Uri | undefined,
) => await runVariantAnalysis(progress, token, uri),
{
title: "Run Variant Analysis",
cancellable: true,
@@ -1290,6 +1330,19 @@ async function activateWithInstalledDistribution(
commandRunner("codeQL.openReferencedFile", openReferencedFile),
);
// Since we are tracking extension usage through commands, this command mirrors the "codeQL.openReferencedFile" command
ctx.subscriptions.push(
commandRunner("codeQL.openReferencedFileContextEditor", openReferencedFile),
);
// Since we are tracking extension usage through commands, this command mirrors the "codeQL.openReferencedFile" command
ctx.subscriptions.push(
commandRunner(
"codeQL.openReferencedFileContextExplorer",
openReferencedFile,
),
);
ctx.subscriptions.push(
commandRunner("codeQL.previewQueryHelp", previewQueryHelp),
);
@@ -1474,6 +1527,22 @@ async function activateWithInstalledDistribution(
const cfgTemplateProvider = new TemplatePrintCfgProvider(cliServer, dbm);
ctx.subscriptions.push(astViewer);
async function viewAst(
progress: ProgressCallback,
token: CancellationToken,
selectedFile: Uri,
): Promise<void> {
const ast = await printAstTemplateProvider.provideAst(
progress,
token,
selectedFile ?? window.activeTextEditor?.document.uri,
);
if (ast) {
astViewer.updateRoots(await ast.getRoots(), ast.db, ast.fileName);
}
}
ctx.subscriptions.push(
commandRunnerWithProgress(
"codeQL.viewAst",
@@ -1481,16 +1550,39 @@ async function activateWithInstalledDistribution(
progress: ProgressCallback,
token: CancellationToken,
selectedFile: Uri,
) => {
const ast = await printAstTemplateProvider.provideAst(
progress,
token,
selectedFile ?? window.activeTextEditor?.document.uri,
);
if (ast) {
astViewer.updateRoots(await ast.getRoots(), ast.db, ast.fileName);
}
) => await viewAst(progress, token, selectedFile),
{
cancellable: true,
title: "Calculate AST",
},
),
);
// Since we are tracking extension usage through commands, this command mirrors the "codeQL.viewAst" command
ctx.subscriptions.push(
commandRunnerWithProgress(
"codeQL.viewAstContextExplorer",
async (
progress: ProgressCallback,
token: CancellationToken,
selectedFile: Uri,
) => await viewAst(progress, token, selectedFile),
{
cancellable: true,
title: "Calculate AST",
},
),
);
// Since we are tracking extension usage through commands, this command mirrors the "codeQL.viewAst" command
ctx.subscriptions.push(
commandRunnerWithProgress(
"codeQL.viewAstContextEditor",
async (
progress: ProgressCallback,
token: CancellationToken,
selectedFile: Uri,
) => await viewAst(progress, token, selectedFile),
{
cancellable: true,
title: "Calculate AST",
@@ -1516,6 +1608,44 @@ async function activateWithInstalledDistribution(
),
);
// Since we are tracking extension usage through commands, this command mirrors the "codeQL.viewCfg" command
ctx.subscriptions.push(
commandRunnerWithProgress(
"codeQL.viewCfgContextExplorer",
async (progress: ProgressCallback, token: CancellationToken) => {
const res = await cfgTemplateProvider.provideCfgUri(
window.activeTextEditor?.document,
);
if (res) {
await compileAndRunQuery(false, res[0], progress, token, undefined);
}
},
{
title: "Calculating Control Flow Graph",
cancellable: true,
},
),
);
// Since we are tracking extension usage through commands, this command mirrors the "codeQL.viewCfg" command
ctx.subscriptions.push(
commandRunnerWithProgress(
"codeQL.viewCfgContextEditor",
async (progress: ProgressCallback, token: CancellationToken) => {
const res = await cfgTemplateProvider.provideCfgUri(
window.activeTextEditor?.document,
);
if (res) {
await compileAndRunQuery(false, res[0], progress, token, undefined);
}
},
{
title: "Calculating Control Flow Graph",
cancellable: true,
},
),
);
const mockServer = new VSCodeMockGitHubApiServer(ctx);
ctx.subscriptions.push(mockServer);
ctx.subscriptions.push(

View File

@@ -0,0 +1 @@
export class CommandManager {}

View File

@@ -0,0 +1 @@
export * from "./CommandManager";

View File

@@ -1,5 +1,5 @@
[
"v2.12.3",
"v2.12.4",
"v2.11.6",
"v2.7.6",
"v2.8.5",

View File

@@ -0,0 +1,8 @@
import { CommandManager } from "../../../../src/packages/commands";
describe(CommandManager.name, () => {
it("can create a command manager", () => {
const commandManager = new CommandManager();
expect(commandManager).not.toBeUndefined();
});
});

View File

@@ -61,6 +61,7 @@ describe("Packaging commands", () => {
);
await handleDownloadPacks(cli, progress);
expect(showAndLogExceptionWithTelemetrySpy).not.toHaveBeenCalled();
expect(showAndLogInformationMessageSpy).toHaveBeenCalledWith(
expect.stringContaining("Finished downloading packs."),
);
@@ -73,6 +74,7 @@ describe("Packaging commands", () => {
inputBoxSpy.mockResolvedValue("codeql/csharp-solorigate-queries");
await handleDownloadPacks(cli, progress);
expect(showAndLogExceptionWithTelemetrySpy).not.toHaveBeenCalled();
expect(showAndLogInformationMessageSpy).toHaveBeenCalledWith(
expect.stringContaining("Finished downloading packs."),
);