Skip to content
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
2 changes: 2 additions & 0 deletions extensions/ql-vscode/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

## [UNRELEASED]

- Remove support for CodeQL CLI versions older than 2.13.5. [#3371](https://github.com/github/vscode-codeql/pull/3371)

## 1.12.2 - 14 February 2024

- Stop allowing running variant analyses with a query outside of the workspace. [#3302](https://github.com/github/vscode-codeql/pull/3302)
Expand Down
2 changes: 1 addition & 1 deletion extensions/ql-vscode/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -1432,7 +1432,7 @@
},
{
"command": "codeQL.quickEvalCount",
"when": "editorLangId == ql && codeql.supportsQuickEvalCount"
"when": "editorLangId == ql"
},
{
"command": "codeQL.quickEvalContextEditor",
Expand Down
80 changes: 10 additions & 70 deletions extensions/ql-vscode/src/codeql-cli/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1271,12 +1271,6 @@ export class CodeQLCliServer implements Disposable {
): Promise<QlpacksInfo> {
const args = this.getAdditionalPacksArg(additionalPacks);
if (extensionPacksOnly) {
if (!(await this.cliConstraints.supportsQlpacksKind())) {
void this.logger.log(
"Warning: Running with extension packs is only supported by CodeQL CLI v2.12.3 or later.",
);
return {};
}
args.push("--kind", "extension", "--no-recursive");
} else if (kind) {
args.push("--kind", kind);
Expand Down Expand Up @@ -1412,15 +1406,13 @@ export class CodeQLCliServer implements Disposable {
args.push("--mode", "update");
}
if (workspaceFolders?.length > 0) {
if (await this.cliConstraints.supportsAdditionalPacksInstall()) {
args.push(
// Allow prerelease packs from the ql submodule.
"--allow-prerelease",
// Allow the use of --additional-packs argument without issueing a warning
"--no-strict-mode",
...this.getAdditionalPacksArg(workspaceFolders),
);
}
args.push(
// Allow prerelease packs from the ql submodule.
"--allow-prerelease",
// Allow the use of --additional-packs argument without issueing a warning
"--no-strict-mode",
...this.getAdditionalPacksArg(workspaceFolders),
);
}
return this.runJsonCodeQlCliCommandWithAuthentication(
["pack", "install"],
Expand Down Expand Up @@ -1521,15 +1513,7 @@ export class CodeQLCliServer implements Disposable {
this._versionChangedListeners.forEach((listener) =>
listener(newVersionAndFeatures),
);

// this._version is only undefined upon config change, so we reset CLI-based context key only when necessary.
await this.app.commands.execute(
"setContext",
"codeql.supportsQuickEvalCount",
newVersionAndFeatures.version.compare(
CliVersionConstraint.CLI_VERSION_WITH_QUICK_EVAL_COUNT,
) >= 0,
);
await this.app.commands.execute(
"setContext",
"codeql.supportsTrimCache",
Expand Down Expand Up @@ -1573,11 +1557,8 @@ export class CodeQLCliServer implements Disposable {
return paths.length ? ["--additional-packs", paths.join(delimiter)] : [];
}

public async useExtensionPacks(): Promise<boolean> {
return (
this.cliConfig.useExtensionPacks &&
(await this.cliConstraints.supportsQlpacksKind())
);
public useExtensionPacks(): boolean {
return this.cliConfig.useExtensionPacks;
}

public async setUseExtensionPacks(useExtensionPacks: boolean) {
Expand Down Expand Up @@ -1694,26 +1675,7 @@ 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.11.6");

/**
* CLI version that supports the `--kind` option for the `resolve qlpacks` command.
*/
public static CLI_VERSION_WITH_QLPACKS_KIND = new SemVer("2.12.3");

/**
* CLI version that supports the `--additional-packs` option for the `pack install` command.
*/
public static CLI_VERSION_WITH_ADDITIONAL_PACKS_INSTALL = new SemVer(
"2.12.4",
);

public static CLI_VERSION_GLOBAL_CACHE = new SemVer("2.12.4");

/**
* CLI version where the query server supports quick-eval count mode.
*/
public static CLI_VERSION_WITH_QUICK_EVAL_COUNT = new SemVer("2.13.3");
public static OLDEST_SUPPORTED_CLI_VERSION = new SemVer("2.13.5");

/**
* CLI version where the `generate extensible-predicate-metadata`
Expand Down Expand Up @@ -1753,34 +1715,12 @@ export class CliVersionConstraint {
return (await this.cli.getVersion()).compare(v) >= 0;
}

async supportsQlpacksKind() {
return this.isVersionAtLeast(
CliVersionConstraint.CLI_VERSION_WITH_QLPACKS_KIND,
);
}

async supportsAdditionalPacksInstall() {
return this.isVersionAtLeast(
CliVersionConstraint.CLI_VERSION_WITH_ADDITIONAL_PACKS_INSTALL,
);
}

async usesGlobalCompilationCache() {
return this.isVersionAtLeast(CliVersionConstraint.CLI_VERSION_GLOBAL_CACHE);
}

async supportsVisibilityNotifications() {
return this.isVersionAtLeast(
CliVersionConstraint.CLI_VERSION_WITH_VISIBILITY_NOTIFICATIONS,
);
}

async supportsQuickEvalCount() {
return this.isVersionAtLeast(
CliVersionConstraint.CLI_VERSION_WITH_QUICK_EVAL_COUNT,
);
}

async supportsGenerateExtensiblePredicateMetadata() {
return this.isVersionAtLeast(
CliVersionConstraint.CLI_VERSION_WITH_EXTENSIBLE_PREDICATE_METADATA,
Expand Down
8 changes: 1 addition & 7 deletions extensions/ql-vscode/src/local-queries/local-queries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ import { LocalQueryInfo } from "../query-results";
import type { WebviewReveal } from "./webview";
import { asError, getErrorMessage } from "../common/helpers-pure";
import type { CodeQLCliServer } from "../codeql-cli/cli";
import { CliVersionConstraint } from "../codeql-cli/cli";
import type { LocalQueryCommands } from "../common/commands";
import { DisposableObject } from "../common/disposable-object";
import { SkeletonQueryWizard } from "./skeleton-query-wizard";
Expand Down Expand Up @@ -256,11 +255,6 @@ export class LocalQueries extends DisposableObject {
private async quickEvalCount(uri: Uri): Promise<void> {
await withProgress(
async (progress, token) => {
if (!(await this.cliServer.cliConstraints.supportsQuickEvalCount())) {
throw new Error(
`Quick evaluation count is only supported by CodeQL CLI v${CliVersionConstraint.CLI_VERSION_WITH_QUICK_EVAL_COUNT} or later.`,
);
}
await this.compileAndRunQuery(
QuickEvalType.QuickEvalCount,
uri,
Expand Down Expand Up @@ -594,7 +588,7 @@ export class LocalQueries extends DisposableObject {
public async getDefaultExtensionPacks(
additionalPacks: string[],
): Promise<string[]> {
return (await this.cliServer.useExtensionPacks())
return this.cliServer.useExtensionPacks()
? Object.keys(await this.cliServer.resolveQlpacks(additionalPacks, true))
: [];
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { ModelEditorView } from "./model-editor-view";
import type { ModelEditorCommands } from "../common/commands";
import type { CodeQLCliServer } from "../codeql-cli/cli";
import { CliVersionConstraint } from "../codeql-cli/cli";
import type { QueryRunner } from "../query-server";
import type {
DatabaseItem,
Expand Down Expand Up @@ -169,14 +168,6 @@ export class ModelEditorModule extends DisposableObject {
async (progress, token) => {
const maxStep = 4;

if (!(await this.cliServer.cliConstraints.supportsQlpacksKind())) {
void showAndLogErrorMessage(
this.app.logger,
`This feature requires CodeQL CLI version ${CliVersionConstraint.CLI_VERSION_WITH_QLPACKS_KIND.format()} or later.`,
);
return;
}

const modelFile = await pickExtensionPack(
this.cliServer,
db,
Expand Down
13 changes: 2 additions & 11 deletions extensions/ql-vscode/src/variant-analysis/run-remote-query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -131,16 +131,7 @@ async function generateQueryPack(
...extensionPacks.map((p) => `--extension-pack=${p}@*`),
];
} else {
if (await cliServer.cliConstraints.usesGlobalCompilationCache()) {
precompilationOpts = ["--qlx"];
} else {
const cache = join(qlPackDetails.qlPackRootPath, ".cache");
precompilationOpts = [
"--qlx",
"--no-default-compilation-cache",
`--compilation-cache=${cache}`,
];
}
precompilationOpts = ["--qlx"];

if (extensionPacks.length > 0) {
await addExtensionPacksAsDependencies(targetPackPath, extensionPacks);
Expand Down Expand Up @@ -408,7 +399,7 @@ async function getExtensionPacksToInject(
workspaceFolders: string[],
): Promise<string[]> {
const result: string[] = [];
if (await cliServer.useExtensionPacks()) {
if (cliServer.useExtensionPacks()) {
const extensionPacks = await cliServer.resolveQlpacks(
workspaceFolders,
true,
Expand Down
2 changes: 0 additions & 2 deletions extensions/ql-vscode/supported_cli_versions.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,5 @@
"v2.15.5",
"v2.14.6",
"v2.13.5",
"v2.12.7",
"v2.11.6",
"nightly"
]
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import {
getActivatedExtension,
} from "../global.helper";
import type { CodeQLCliServer } from "../../../src/codeql-cli/cli";
import { CliVersionConstraint } from "../../../src/codeql-cli/cli";
import { describeWithCodeQL } from "../cli";
import type {
CoreCompletedQuery,
Expand Down Expand Up @@ -151,23 +150,12 @@ describeWithCodeQL()("Queries", () => {
);

it("should run a query that has an extension without looking for extensions in the workspace", async () => {
if (!(await supportsExtensionPacks())) {
console.log(
`Skipping test because it is only supported for CodeQL CLI versions >= ${CliVersionConstraint.CLI_VERSION_WITH_QLPACKS_KIND}`,
);
return;
}

await cli.setUseExtensionPacks(false);
const parsedResults = await runQueryWithExtensions();
expect(parsedResults).toEqual([1]);
});

it("should run a query that has an extension and look for extensions in the workspace", async () => {
if (!(await supportsExtensionPacks())) {
return;
}

console.log(`Starting 'extensions' ${mode}`);
console.log("Setting useExtensionPacks to true");
await cli.setUseExtensionPacks(true);
Expand All @@ -176,16 +164,6 @@ describeWithCodeQL()("Queries", () => {
expect(parsedResults).toEqual([1, 2, 3, 4]);
});

async function supportsExtensionPacks(): Promise<boolean> {
if (await qs.cliServer.cliConstraints.supportsQlpacksKind()) {
return true;
}
console.log(
`Skipping test because it is only supported for CodeQL CLI versions >= ${CliVersionConstraint.CLI_VERSION_WITH_QLPACKS_KIND}`,
);
return false;
}

async function runQueryWithExtensions() {
console.log("Calling compileAndRunQuery");
const result = await compileAndRunQuery(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -271,12 +271,6 @@ describe("Variant Analysis Manager", () => {
});

it("should run a remote query with extension packs inside a qlpack", async () => {
if (!(await cli.cliConstraints.supportsQlpacksKind())) {
console.log(
`Skipping test because qlpacks kind is only suppported in CLI version ${CliVersionConstraint.CLI_VERSION_WITH_QLPACKS_KIND} or later.`,
);
return;
}
await cli.setUseExtensionPacks(true);
await doVariantAnalysisTest({
queryPaths: ["data-remote-qlpack-nested/subfolder/in-pack.ql"],
Expand Down