Remove support for CodeQL CLI versions older than v2.16.6

This commit is contained in:
Nora
2024-09-25 09:47:26 +00:00
parent b6b707e7fe
commit 515132fe94
4 changed files with 2 additions and 52 deletions

View File

@@ -1909,38 +1909,12 @@ function shouldDebugCliServer() {
export class CliVersionConstraint { export class CliVersionConstraint {
// The oldest version of the CLI that we support. This is used to determine // 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. // whether to show a warning about the CLI being too old on startup.
public static OLDEST_SUPPORTED_CLI_VERSION = new SemVer("v2.15.5"); public static OLDEST_SUPPORTED_CLI_VERSION = new SemVer("2.16.6");
public static CLI_VERSION_WITHOUT_MRVA_EXTENSIBLE_PREDICATE_HACK = new SemVer(
"2.16.1",
);
/**
* CLI version where there is support for multiple queries on the pack create command.
*/
public static CLI_VERSION_WITH_MULTI_QUERY_PACK_CREATE = new SemVer("2.16.1");
constructor(private readonly cli: CodeQLCliServer) { constructor(private readonly cli: CodeQLCliServer) {
/**/ /**/
} }
private async isVersionAtLeast(v: SemVer) {
return (await this.cli.getVersion()).compare(v) >= 0;
}
async preservesExtensiblePredicatesInMrvaPack() {
// Negated, because we _stopped_ preserving these in 2.16.1.
return !(await this.isVersionAtLeast(
CliVersionConstraint.CLI_VERSION_WITHOUT_MRVA_EXTENSIBLE_PREDICATE_HACK,
));
}
async supportsPackCreateWithMultipleQueries() {
return this.isVersionAtLeast(
CliVersionConstraint.CLI_VERSION_WITH_MULTI_QUERY_PACK_CREATE,
);
}
async supportsMrvaPackCreate(): Promise<boolean> { async supportsMrvaPackCreate(): Promise<boolean> {
return (await this.cli.getFeatures()).mrvaPackCreate === true; return (await this.cli.getFeatures()).mrvaPackCreate === true;
} }

View File

@@ -116,15 +116,6 @@ async function generateQueryPack(
let precompilationOpts: string[]; let precompilationOpts: string[];
if (cliSupportsMrvaPackCreate) { if (cliSupportsMrvaPackCreate) {
if (
qlPackDetails.queryFiles.length > 1 &&
!(await cliServer.cliConstraints.supportsPackCreateWithMultipleQueries())
) {
throw new Error(
`Installed CLI version does not allow creating a MRVA pack with multiple queries`,
);
}
const queryOpts = qlPackDetails.queryFiles.flatMap((q) => [ const queryOpts = qlPackDetails.queryFiles.flatMap((q) => [
"--query", "--query",
join(targetPackPath, relative(qlPackDetails.qlPackRootPath, q)), join(targetPackPath, relative(qlPackDetails.qlPackRootPath, q)),

View File

@@ -3,6 +3,5 @@
"v2.18.4", "v2.18.4",
"v2.17.6", "v2.17.6",
"v2.16.6", "v2.16.6",
"v2.15.5",
"nightly" "nightly"
] ]

View File

@@ -347,13 +347,6 @@ describe("Variant Analysis Manager", () => {
const queryToRun = const queryToRun =
"Security/CWE/CWE-020/ExternalAPIsUsedWithUntrustedData.ql"; "Security/CWE/CWE-020/ExternalAPIsUsedWithUntrustedData.ql";
// Recent versions of the CLI don't preserve queries with extensible predicates in MRVA packs,
// because all the necessary info is in the `.packinfo` file.
const extraQueries =
(await cli.cliConstraints.preservesExtensiblePredicatesInMrvaPack())
? ["Telemetry/ExtractorInformation.ql"]
: [];
const qlPackRootPath = join(process.env.TEST_CODEQL_PATH, "java/ql/src"); const qlPackRootPath = join(process.env.TEST_CODEQL_PATH, "java/ql/src");
const queryPath = join(qlPackRootPath, queryToRun); const queryPath = join(qlPackRootPath, queryToRun);
const qlPackFilePath = join(qlPackRootPath, "qlpack.yml"); const qlPackFilePath = join(qlPackRootPath, "qlpack.yml");
@@ -362,7 +355,7 @@ describe("Variant Analysis Manager", () => {
qlPackRootPath, qlPackRootPath,
qlPackFilePath, qlPackFilePath,
expectedPackName: "codeql/java-queries", expectedPackName: "codeql/java-queries",
filesThatExist: [queryToRun, ...extraQueries], filesThatExist: [queryToRun, ...["Telemetry/ExtractorInformation.ql"]],
filesThatDoNotExist: [], filesThatDoNotExist: [],
qlxFilesThatExist: [], qlxFilesThatExist: [],
dependenciesToCheck: ["codeql/java-all"], dependenciesToCheck: ["codeql/java-all"],
@@ -372,13 +365,6 @@ describe("Variant Analysis Manager", () => {
}); });
it("should run multiple queries that are part of the same pack", async () => { it("should run multiple queries that are part of the same pack", async () => {
if (!(await cli.cliConstraints.supportsPackCreateWithMultipleQueries())) {
console.log(
`Skipping test because MRVA with multiple queries is only suppported in CLI version ${CliVersionConstraint.CLI_VERSION_WITH_MULTI_QUERY_PACK_CREATE} or later.`,
);
return;
}
await doVariantAnalysisTest({ await doVariantAnalysisTest({
queryPaths: [ queryPaths: [
"data-qlpack-multiple-queries/query1.ql", "data-qlpack-multiple-queries/query1.ql",