Ensure qlconfig file is created when config parsing in cli is on

Previously, with the config parsing in the cli feature flag turned on,
the CLI was not able to download packs from other registries. This PR
adds the codeql-action changes required for this. The CLI changes will
be in a separate, internal PR.
This commit is contained in:
Andrew Eisenberg
2023-02-07 10:40:49 -08:00
parent 4369dda4ae
commit bbe8d375fd
20 changed files with 480 additions and 138 deletions

View File

@@ -91,6 +91,7 @@ export interface CodeQL {
sourceRoot: string,
processName: string | undefined,
featureEnablement: FeatureEnablement,
qlconfigFile: string | undefined,
logger: Logger
): Promise<void>;
/**
@@ -283,6 +284,11 @@ export const CODEQL_VERSION_BETTER_RESOLVE_LANGUAGES = "2.10.3";
*/
export const CODEQL_VERSION_SECURITY_EXPERIMENTAL_SUITE = "2.12.1";
/**
* Versions 2.12.2+ of the CodeQL CLI support the `--qlconfig` flag in calls to `database init`.
*/
export const CODEQL_VERSION_INIT_WITH_QLCONFIG = "2.12.3";
/**
* Set up CodeQL CLI access.
*
@@ -562,6 +568,7 @@ export async function getCodeQLForCmd(
sourceRoot: string,
processName: string | undefined,
featureEnablement: FeatureEnablement,
qlconfigFile: string | undefined,
logger: Logger
) {
const extraArgs = config.languages.map(
@@ -601,13 +608,18 @@ export async function getCodeQLForCmd(
// Only pass external repository token if a config file is going to be parsed by the CLI.
let externalRepositoryToken: string | undefined;
if (configLocation) {
extraArgs.push(`--codescanning-config=${configLocation}`);
externalRepositoryToken = getOptionalInput("external-repository-token");
extraArgs.push(`--codescanning-config=${configLocation}`);
if (externalRepositoryToken) {
extraArgs.push("--external-repository-token-stdin");
}
}
if (
await util.codeQlVersionAbove(this, CODEQL_VERSION_INIT_WITH_QLCONFIG)
) {
extraArgs.push(`--qlconfig=${qlconfigFile}`);
}
await runTool(
cmd,
[