Fix using resolve-environment Action with language aliases

This impacted default setup configurations that analyzed Go alongside at
least one of the following languages:
- C/C++
- Java/Kotlin
- JavaScript/TypeScript
This commit is contained in:
Henry Mercer 2023-10-05 14:54:24 +01:00
parent 517782a2a0
commit 0ac7669167
3 changed files with 22 additions and 15 deletions

15
lib/codeql.js generated
View file

@ -298,6 +298,7 @@ async function getCodeQLForCmd(cmd, checkVersion) {
"--db-cluster",
config.dbLocation,
`--source-root=${sourceRoot}`,
...(await getLanguageAliasingArguments(this)),
...extraArgs,
...getExtraOptionsFromEnv(["database", "init"]),
], { stdin: externalRepositoryToken });
@ -385,16 +386,12 @@ async function getCodeQLForCmd(cmd, checkVersion) {
}
},
async betterResolveLanguages() {
const extraArgs = [];
if (await util.codeQlVersionAbove(this, exports.CODEQL_VERSION_LANGUAGE_ALIASING)) {
extraArgs.push("--extractor-include-aliases");
}
const codeqlArgs = [
"resolve",
"languages",
"--format=betterjson",
"--extractor-options-verbosity=4",
...extraArgs,
...(await getLanguageAliasingArguments(this)),
...getExtraOptionsFromEnv(["resolve", "languages"]),
];
const output = await runTool(cmd, codeqlArgs);
@ -429,6 +426,7 @@ async function getCodeQLForCmd(cmd, checkVersion) {
"resolve",
"build-environment",
`--language=${language}`,
...(await getLanguageAliasingArguments(this)),
...getExtraOptionsFromEnv(["resolve", "build-environment"]),
];
if (workingDir !== undefined) {
@ -646,6 +644,7 @@ async function getCodeQLForCmd(cmd, checkVersion) {
"extractor",
"--format=json",
`--language=${language}`,
...(await getLanguageAliasingArguments(this)),
...getExtraOptionsFromEnv(["resolve", "extractor"]),
], {
silent: true,
@ -962,4 +961,10 @@ function isNoCodeFoundError(e) {
async function isDiagnosticsExportInvalidSarifFixed(codeql) {
return await util.codeQlVersionAbove(codeql, exports.CODEQL_VERSION_DIAGNOSTICS_EXPORT_FIXED);
}
async function getLanguageAliasingArguments(codeql) {
if (await util.codeQlVersionAbove(codeql, exports.CODEQL_VERSION_LANGUAGE_ALIASING)) {
return ["--extractor-include-aliases"];
}
return [];
}
//# sourceMappingURL=codeql.js.map

File diff suppressed because one or more lines are too long

View file

@ -624,6 +624,7 @@ export async function getCodeQLForCmd(
"--db-cluster",
config.dbLocation,
`--source-root=${sourceRoot}`,
...(await getLanguageAliasingArguments(this)),
...extraArgs,
...getExtraOptionsFromEnv(["database", "init"]),
],
@ -737,20 +738,12 @@ export async function getCodeQLForCmd(
}
},
async betterResolveLanguages() {
const extraArgs: string[] = [];
if (
await util.codeQlVersionAbove(this, CODEQL_VERSION_LANGUAGE_ALIASING)
) {
extraArgs.push("--extractor-include-aliases");
}
const codeqlArgs = [
"resolve",
"languages",
"--format=betterjson",
"--extractor-options-verbosity=4",
...extraArgs,
...(await getLanguageAliasingArguments(this)),
...getExtraOptionsFromEnv(["resolve", "languages"]),
];
const output = await runTool(cmd, codeqlArgs);
@ -793,6 +786,7 @@ export async function getCodeQLForCmd(
"resolve",
"build-environment",
`--language=${language}`,
...(await getLanguageAliasingArguments(this)),
...getExtraOptionsFromEnv(["resolve", "build-environment"]),
];
if (workingDir !== undefined) {
@ -1082,6 +1076,7 @@ export async function getCodeQLForCmd(
"extractor",
"--format=json",
`--language=${language}`,
...(await getLanguageAliasingArguments(this)),
...getExtraOptionsFromEnv(["resolve", "extractor"]),
],
{
@ -1470,3 +1465,10 @@ async function isDiagnosticsExportInvalidSarifFixed(
CODEQL_VERSION_DIAGNOSTICS_EXPORT_FIXED,
);
}
async function getLanguageAliasingArguments(codeql: CodeQL): Promise<string[]> {
if (await util.codeQlVersionAbove(codeql, CODEQL_VERSION_LANGUAGE_ALIASING)) {
return ["--extractor-include-aliases"];
}
return [];
}