diff --git a/extensions/ql-vscode/CHANGELOG.md b/extensions/ql-vscode/CHANGELOG.md index f481fe913e8..2202d07710f 100644 --- a/extensions/ql-vscode/CHANGELOG.md +++ b/extensions/ql-vscode/CHANGELOG.md @@ -6,6 +6,7 @@ - Fix bug to ensure error messages have complete stack trace in message logs. [#2425](https://github.com/github/vscode-codeql/pull/2425) - Fix bug where the `CodeQL: Compare Query` command did not work for comparing quick-eval queries. [#2422](https://github.com/github/vscode-codeql/pull/2422) - Update text of copy and export buttons in variant analysis results view to clarify that they only copy/export the selected/filtered results. [#2427](https://github.com/github/vscode-codeql/pull/2427) +- Add warning when using unsupported CodeQL CLI version. [#2428](https://github.com/github/vscode-codeql/pull/2428) ## 1.8.4 - 3 May 2023 diff --git a/extensions/ql-vscode/src/codeql-cli/cli.ts b/extensions/ql-vscode/src/codeql-cli/cli.ts index d5ef116d465..969ba374b00 100644 --- a/extensions/ql-vscode/src/codeql-cli/cli.ts +++ b/extensions/ql-vscode/src/codeql-cli/cli.ts @@ -1737,6 +1737,10 @@ export function shouldDebugCliServer() { } export class CliVersionConstraint { + // The oldest version of the CLI that we support. This is used to determine + // whether to show a warning about the CLI being too old on startup. + public static OLDEST_SUPPORTED_CLI_VERSION = new SemVer("2.7.6"); + /** * CLI version where building QLX packs for remote queries is supported. * (The options were _accepted_ by a few earlier versions, but only from diff --git a/extensions/ql-vscode/src/extension.ts b/extensions/ql-vscode/src/extension.ts index aad6940f523..888884bdd5d 100644 --- a/extensions/ql-vscode/src/extension.ts +++ b/extensions/ql-vscode/src/extension.ts @@ -24,7 +24,7 @@ import { activate as archiveFilesystemProvider_activate, zipArchiveScheme, } from "./common/vscode/archive-filesystem-provider"; -import { CodeQLCliServer } from "./codeql-cli/cli"; +import { CliVersionConstraint, CodeQLCliServer } from "./codeql-cli/cli"; import { CliConfigListener, DistributionConfigListener, @@ -408,6 +408,28 @@ export async function activate( codeQlExtension.cliServer.addVersionChangedListener((ver) => { telemetryListener.cliVersion = ver; }); + + let unsupportedWarningShown = false; + codeQlExtension.cliServer.addVersionChangedListener((ver) => { + if (!ver) { + return; + } + + if (unsupportedWarningShown) { + return; + } + + if (CliVersionConstraint.OLDEST_SUPPORTED_CLI_VERSION.compare(ver) < 0) { + return; + } + + void showAndLogWarningMessage( + `You are using an unsupported version of the CodeQL CLI (${ver}). ` + + `The minimum supported version is ${CliVersionConstraint.OLDEST_SUPPORTED_CLI_VERSION}. ` + + `Please upgrade to a newer version of the CodeQL CLI.`, + ); + unsupportedWarningShown = true; + }); } return codeQlExtension;