Add ML-powered queries enablement to init status report

We report this information in the `init` status report rather than the
`analyze` status report so we can gather data about timeouts.
This commit is contained in:
Henry Mercer
2022-02-03 16:29:28 +00:00
parent a005206838
commit 1cddec9558
12 changed files with 161 additions and 8 deletions

View File

@@ -627,3 +627,28 @@ export function checkNotWindows11() {
);
}
}
export const ML_POWERED_JS_QUERIES_PACK_NAME =
"codeql/javascript-experimental-atm-queries";
/** Get information about ML-powered JS queries to populate status reports with.
*
* This will be:
*
* - The version string if the analysis will use a specific version of the pack
* - "latest" if the analysis will use the latest version of the pack
* - "false" if the analysis won't run any ML-powered JS queries, or if the analysis will run
* multiple ML-powered JS query packs
*
* This function lives here rather than in `init-action.ts` so it's easier to test, since tests for
* `init-action.ts` would each need to live in their own file. See `analyze-action-env.ts` for an
* explanation as to why this is.
*/
export function getMlPoweredJsQueriesStatus(config: Config) {
const mlPoweredJsQueryPacks = (config.packs.javascript || []).filter(
(pack) => pack.packName === ML_POWERED_JS_QUERIES_PACK_NAME
);
return mlPoweredJsQueryPacks.length === 1
? mlPoweredJsQueryPacks[0].version || "latest"
: "false";
}