Skip to content

Commit 2c03704

Browse files
committedMar 31, 2022
Allow the version of the ML-powered pack to depend on the CLI version
1 parent dd6b592 commit 2c03704

9 files changed

+31
-26
lines changed
 

‎lib/codeql.js

+2-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎lib/codeql.js.map

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎lib/config-utils.js

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎lib/config-utils.js.map

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎lib/util.js

+8-6
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎lib/util.js.map

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎src/codeql.ts

+5-4
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import { Logger } from "./logging";
1818
import * as toolcache from "./toolcache";
1919
import { toolrunnerErrorCatcher } from "./toolrunner-error-catcher";
2020
import * as util from "./util";
21-
import { isGoodVersion, ML_POWERED_JS_QUERIES_PACK } from "./util";
21+
import { isGoodVersion } from "./util";
2222

2323
type Options = Array<string | number | boolean>;
2424

@@ -741,9 +741,10 @@ async function getCodeQLForCmd(
741741
if (config.injectedMlQueries) {
742742
// We need to inject the ML queries into the original user input before
743743
// we pass this on to the CLI, to make sure these get run.
744-
let packString = ML_POWERED_JS_QUERIES_PACK.packName;
745-
if (ML_POWERED_JS_QUERIES_PACK.version)
746-
packString = `${packString}@${ML_POWERED_JS_QUERIES_PACK.version}`;
744+
const pack = await util.getMlPoweredJsQueriesPack(codeql);
745+
const packString =
746+
pack.packName + (pack.version ? `@${pack.version}` : "");
747+
747748
if (augmentedConfig.packs === undefined) augmentedConfig.packs = [];
748749
if (Array.isArray(augmentedConfig.packs)) {
749750
augmentedConfig.packs.push(packString);

‎src/config-utils.ts

+4-3
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,9 @@ import { Logger } from "./logging";
1717
import { RepositoryNwo } from "./repository";
1818
import {
1919
codeQlVersionAbove,
20+
getMlPoweredJsQueriesPack,
2021
GitHubVersion,
21-
ML_POWERED_JS_QUERIES_PACK,
22+
ML_POWERED_JS_QUERIES_PACK_NAME,
2223
} from "./util";
2324

2425
// Property names from the user-supplied config file.
@@ -304,15 +305,15 @@ async function addBuiltinSuiteQueries(
304305
languages.includes("javascript") &&
305306
(found === "security-extended" || found === "security-and-quality") &&
306307
!packs.javascript?.some(
307-
(pack) => pack.packName === ML_POWERED_JS_QUERIES_PACK.packName
308+
(pack) => pack.packName === ML_POWERED_JS_QUERIES_PACK_NAME
308309
) &&
309310
(await featureFlags.getValue(FeatureFlag.MlPoweredQueriesEnabled)) &&
310311
(await codeQlVersionAbove(codeQL, CODEQL_VERSION_ML_POWERED_QUERIES))
311312
) {
312313
if (!packs.javascript) {
313314
packs.javascript = [];
314315
}
315-
packs.javascript.push(ML_POWERED_JS_QUERIES_PACK);
316+
packs.javascript.push(await getMlPoweredJsQueriesPack(codeQL));
316317
injectedMlQueries = true;
317318
}
318319

‎src/util.ts

+7-5
Original file line numberDiff line numberDiff line change
@@ -657,13 +657,15 @@ export const ML_POWERED_JS_QUERIES_PACK_NAME =
657657
"codeql/javascript-experimental-atm-queries";
658658

659659
/**
660-
* The ML-powered JS query pack to add to the analysis if a repo is opted into the ML-powered
660+
* Gets the ML-powered JS query pack to add to the analysis if a repo is opted into the ML-powered
661661
* queries beta.
662662
*/
663-
export const ML_POWERED_JS_QUERIES_PACK: PackWithVersion = {
664-
packName: "codeql/javascript-experimental-atm-queries",
665-
version: "~0.1.0",
666-
};
663+
export async function getMlPoweredJsQueriesPack(
664+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
665+
_codeQL: CodeQL
666+
): Promise<PackWithVersion> {
667+
return { packName: ML_POWERED_JS_QUERIES_PACK_NAME, version: "~0.1.0" };
668+
}
667669

668670
/**
669671
* Get information about ML-powered JS queries to populate status reports with.

0 commit comments

Comments
 (0)
Please sign in to comment.