mirror of
https://github.com/github/codeql-action.git
synced 2026-01-06 22:50:17 +08:00
Merge pull request #1824 from github/henrymercer/cli-notifications-fix
Only workaround invalid notifications for CodeQL CLI 2.13.0 and earlier
This commit is contained in:
@@ -315,6 +315,11 @@ export const CODEQL_VERSION_INIT_WITH_QLCONFIG = "2.12.4";
|
||||
*/
|
||||
export const CODEQL_VERSION_BETTER_NO_CODE_ERROR_MESSAGE = "2.12.4";
|
||||
|
||||
/**
|
||||
* Versions 2.13.1+ of the CodeQL CLI fix a bug where diagnostics export could produce invalid SARIF.
|
||||
*/
|
||||
export const CODEQL_VERSION_DIAGNOSTICS_EXPORT_FIXED = "2.13.1";
|
||||
|
||||
/**
|
||||
* Versions 2.13.4+ of the CodeQL CLI support the `resolve build-environment` command.
|
||||
*/
|
||||
@@ -814,8 +819,9 @@ export async function getCodeQLForCmd(
|
||||
Feature.ExportDiagnosticsEnabled,
|
||||
this,
|
||||
);
|
||||
// Update this to take into account the CodeQL version when we have a version with the fix.
|
||||
const shouldWorkaroundInvalidNotifications = shouldExportDiagnostics;
|
||||
const shouldWorkaroundInvalidNotifications =
|
||||
shouldExportDiagnostics &&
|
||||
!(await isDiagnosticsExportInvalidSarifFixed(this));
|
||||
const codeqlOutputFile = shouldWorkaroundInvalidNotifications
|
||||
? path.join(config.tempDir, "codeql-intermediate-results.sarif")
|
||||
: sarifFile;
|
||||
@@ -970,8 +976,8 @@ export async function getCodeQLForCmd(
|
||||
tempDir: string,
|
||||
logger: Logger,
|
||||
): Promise<void> {
|
||||
// Update this to take into account the CodeQL version when we have a version with the fix.
|
||||
const shouldWorkaroundInvalidNotifications = true;
|
||||
const shouldWorkaroundInvalidNotifications =
|
||||
!(await isDiagnosticsExportInvalidSarifFixed(this));
|
||||
const codeqlOutputFile = shouldWorkaroundInvalidNotifications
|
||||
? path.join(tempDir, "codeql-intermediate-results.sarif")
|
||||
: sarifFile;
|
||||
@@ -1413,3 +1419,12 @@ function isNoCodeFoundError(e: CommandInvocationError): boolean {
|
||||
"No JavaScript or TypeScript code found.";
|
||||
return e.exitCode === 32 || e.error.includes(javascriptNoCodeFoundWarning);
|
||||
}
|
||||
|
||||
async function isDiagnosticsExportInvalidSarifFixed(
|
||||
codeql: CodeQL,
|
||||
): Promise<boolean> {
|
||||
return await util.codeQlVersionAbove(
|
||||
codeql,
|
||||
CODEQL_VERSION_DIAGNOSTICS_EXPORT_FIXED,
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user