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
1 change: 1 addition & 0 deletions extensions/ql-vscode/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

- Rename command "CodeQL: Trim Overlay Base Cache" to "CodeQL: Trim Cache to Overlay-Base" for consistency with "CodeQL: Warm Overlay-Base Cache for [...]" commands. [#4204](https://github.com/github/vscode-codeql/pull/4204)
- Deprecate the setting (`codeQL.runningQueries.saveCache`) that aggressively saved intermediate results to the disk cache. [#4210](https://github.com/github/vscode-codeql/pull/4210)
- The CodeQL CLI's `bqrs diff` command is now used in the "Compare Results" view. This makes the view faster, more accurate, and fixes a bug where it would error when comparing a large amount of results. [#4194](https://github.com/github/vscode-codeql/pull/4194) & [#4211](https://github.com/github/vscode-codeql/pull/4211)

## 1.17.6 - 24 October 2025

Expand Down
1 change: 1 addition & 0 deletions extensions/ql-vscode/src/codeql-cli/cli-version.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ interface VersionResult {

export interface CliFeatures {
queryServerRunQueries?: boolean;
bqrsDiffResultSets?: boolean;
}

export interface VersionAndFeatures {
Expand Down
34 changes: 18 additions & 16 deletions extensions/ql-vscode/src/codeql-cli/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,12 @@ import { ExitCodeError, getCliError } from "./cli-errors";
import { UserCancellationException } from "../common/vscode/progress";
import type { LanguageClient } from "vscode-languageclient/node";

/**
* 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.
*/
export const OLDEST_SUPPORTED_CLI_VERSION = new SemVer("2.20.7");

/**
* The version of the SARIF format that we are using.
*/
Expand Down Expand Up @@ -205,6 +211,7 @@ interface BqrsDecodeOptions {

interface BqrsDiffOptions {
retainResultSets?: string[];
resultSets?: Array<[string, string]>;
}

type OnLineCallback = (line: string) => Promise<string | undefined>;
Expand Down Expand Up @@ -273,8 +280,6 @@ export class CodeQLCliServer implements Disposable {
/** Path to current codeQL executable, or undefined if not running yet. */
codeQlPath: string | undefined;

cliConstraints = new CliVersionConstraint(this);

/**
* When set to true, ignore some modal popups and assume user has clicked "yes".
*/
Expand Down Expand Up @@ -1279,6 +1284,12 @@ export class CodeQLCliServer implements Disposable {
...(options?.retainResultSets
? ["--retain-result-sets", options.retainResultSets.join(",")]
: []),
...(options?.resultSets
? options.resultSets.flatMap(([left, right]) => [
"--result-sets",
`${left},${right}`,
])
: []),
bqrsPath1,
bqrsPath2,
],
Expand Down Expand Up @@ -1816,6 +1827,11 @@ export class CodeQLCliServer implements Disposable {
public async setUseExtensionPacks(useExtensionPacks: boolean) {
await this.cliConfig.setUseExtensionPacks(useExtensionPacks);
}

/** Checks if the CLI supports a specific feature. */
public async supportsFeature(feature: keyof CliFeatures): Promise<boolean> {
return (await this.getFeatures())[feature] === true;
}
}

/**
Expand Down Expand Up @@ -1922,17 +1938,3 @@ export function shouldDebugQueryServer() {
function shouldDebugCliServer() {
return isEnvTrue("CLI_SERVER_JAVA_DEBUG");
}

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.20.7");

constructor(private readonly cli: CodeQLCliServer) {
/**/
}

async supportsQueryServerRunQueries(): Promise<boolean> {
return (await this.cli.getFeatures()).queryServerRunQueries === true;
}
}
17 changes: 13 additions & 4 deletions extensions/ql-vscode/src/compare/compare-view.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import type { CodeQLCliServer } from "../codeql-cli/cli";
import type { DatabaseManager } from "../databases/local-databases";
import { jumpToLocation } from "../databases/local-databases/locations";
import type { BqrsInfo, BqrsResultSetSchema } from "../common/bqrs-cli-types";
// eslint-disable-next-line import/no-deprecated
import resultsDiff from "./resultsDiff";
import type { CompletedLocalQueryInfo } from "../query-results";
import { assertNever, getErrorMessage } from "../common/helpers-pure";
Expand Down Expand Up @@ -403,13 +404,18 @@ export class CompareView extends AbstractWebview<
toResultSetName,
);

// If the result set names are the same, we use `bqrs diff`. This is more
// efficient, but we can't use it in general as it does not support
// comparing different result sets.
if (fromResultSetName === toResultSetName) {
// We use `bqrs diff` when the `--result-sets` option is supported, or when
// the result set names are the same (in which case we don't need the
// option).
const supportsBqrsDiffResultSets =
await this.cliServer.supportsFeature("bqrsDiffResultSets");
if (supportsBqrsDiffResultSets || fromResultSetName === toResultSetName) {
const { uniquePath1, uniquePath2, cleanup } =
await this.cliServer.bqrsDiff(fromPath, toPath, {
retainResultSets: [],
resultSets: supportsBqrsDiffResultSets
? [[fromResultSetName, toResultSetName]]
: [],
});
try {
const uniqueInfo1 = await this.cliServer.bqrsInfo(uniquePath1);
Expand Down Expand Up @@ -443,10 +449,13 @@ export class CompareView extends AbstractWebview<
await cleanup();
}
} else {
// Legacy code path: Perform the diff directly in the extension when we
// can't use `bqrs diff`.
const [fromResultSet, toResultSet] = await Promise.all([
this.getResultSet(fromInfo.schemas, fromResultSetName, fromPath),
this.getResultSet(toInfo.schemas, toResultSetName, toPath),
]);
// eslint-disable-next-line import/no-deprecated
return resultsDiff(fromResultSet, toResultSet);
}
}
Expand Down
4 changes: 4 additions & 0 deletions extensions/ql-vscode/src/compare/resultsDiff.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ import type { RawResultSet } from "../common/raw-result-types";
* 1. number of columns do not match
* 2. If either query is empty
* 3. If the queries are 100% disjoint
*
* @deprecated This function is only used when the `bqrs diff` command does not
* support `--result-sets`. It should be removed when all supported CLI versions
* support this option.
*/
export default function resultsDiff(
fromResults: RawResultSet,
Expand Down
35 changes: 14 additions & 21 deletions extensions/ql-vscode/src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,10 @@ import {
activate as archiveFilesystemProvider_activate,
zipArchiveScheme,
} from "./common/vscode/archive-filesystem-provider";
import { CliVersionConstraint, CodeQLCliServer } from "./codeql-cli/cli";
import {
CodeQLCliServer,
OLDEST_SUPPORTED_CLI_VERSION,
} from "./codeql-cli/cli";
import {
ADD_DATABASE_SOURCE_TO_WORKSPACE_SETTING,
addDatabaseSourceToWorkspace,
Expand Down Expand Up @@ -451,29 +454,19 @@ export async function activate(

let unsupportedWarningShown = false;
codeQlExtension.cliServer.addVersionChangedListener((ver) => {
if (!ver) {
return;
}

if (unsupportedWarningShown) {
return;
}

if (
CliVersionConstraint.OLDEST_SUPPORTED_CLI_VERSION.compare(
ver.version,
) <= 0
ver &&
!unsupportedWarningShown &&
OLDEST_SUPPORTED_CLI_VERSION.compare(ver.version) === 1
) {
return;
void showAndLogWarningMessage(
extLogger,
`You are using an unsupported version of the CodeQL CLI (${ver.version.toString()}). ` +
`The minimum supported version is ${OLDEST_SUPPORTED_CLI_VERSION.toString()}. ` +
`Please upgrade to a newer version of the CodeQL CLI.`,
);
unsupportedWarningShown = true;
}

void showAndLogWarningMessage(
extLogger,
`You are using an unsupported version of the CodeQL CLI (${ver.version.toString()}). ` +
`The minimum supported version is ${CliVersionConstraint.OLDEST_SUPPORTED_CLI_VERSION.toString()}. ` +
`Please upgrade to a newer version of the CodeQL CLI.`,
);
unsupportedWarningShown = true;
});

// Expose the CodeQL CLI features to the extension context under `codeQL.cliFeatures.*`.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ export class QueryServerClient extends DisposableObject {
* queries at once.
*/
async supportsRunQueriesMethod(): Promise<boolean> {
return await this.cliServer.cliConstraints.supportsQueryServerRunQueries();
return await this.cliServer.supportsFeature("queryServerRunQueries");
}

/** Stops the query server by disposing of the current server process. */
Expand Down