mirror of
https://github.com/github/codeql-action.git
synced 2026-05-07 14:20:19 +00:00
Pass "--sarif-include-diagnostics" when feature flag on
This commit is contained in:
+13
-5
@@ -184,8 +184,8 @@ export interface CodeQL {
|
||||
*/
|
||||
databaseExportDiagnostics(
|
||||
databasePath: string,
|
||||
isCluster: boolean,
|
||||
sarifFile: string,
|
||||
exportDiagnosticsEnabled: boolean,
|
||||
automationDetailsId: string | undefined
|
||||
): Promise<void>;
|
||||
/**
|
||||
@@ -193,6 +193,7 @@ export interface CodeQL {
|
||||
*/
|
||||
diagnosticsExport(
|
||||
sarifFile: string,
|
||||
exportDiagnosticsEnabled: boolean,
|
||||
automationDetailsId: string | undefined
|
||||
): Promise<void>;
|
||||
}
|
||||
@@ -985,21 +986,24 @@ export async function getCodeQLForCmd(
|
||||
},
|
||||
async databaseExportDiagnostics(
|
||||
databasePath: string,
|
||||
isCluster: boolean,
|
||||
sarifFile: string,
|
||||
exportDiagnosticsEnabled: boolean,
|
||||
automationDetailsId: string | undefined
|
||||
): Promise<void> {
|
||||
const args = [
|
||||
"database",
|
||||
"export-diagnostics",
|
||||
"--db-cluster", // Database is always a cluster for CodeQL versions that support diagnostics.
|
||||
"--format=sarif-latest",
|
||||
`--output=${sarifFile}`,
|
||||
...getExtraOptionsFromEnv(["diagnostics", "export"]),
|
||||
];
|
||||
if (isCluster) {
|
||||
args.push("--db-cluster");
|
||||
}
|
||||
|
||||
args.push(databasePath);
|
||||
if (exportDiagnosticsEnabled === true) {
|
||||
args.push("--sarif-include-diagnostics");
|
||||
}
|
||||
|
||||
if (automationDetailsId !== undefined) {
|
||||
args.push("--sarif-category", automationDetailsId);
|
||||
}
|
||||
@@ -1007,6 +1011,7 @@ export async function getCodeQLForCmd(
|
||||
},
|
||||
async diagnosticsExport(
|
||||
sarifFile: string,
|
||||
exportDiagnosticsEnabled: boolean,
|
||||
automationDetailsId: string | undefined
|
||||
): Promise<void> {
|
||||
const args = [
|
||||
@@ -1016,6 +1021,9 @@ export async function getCodeQLForCmd(
|
||||
`--output=${sarifFile}`,
|
||||
...getExtraOptionsFromEnv(["diagnostics", "export"]),
|
||||
];
|
||||
if (exportDiagnosticsEnabled === true) {
|
||||
args.push("--sarif-include-diagnostics");
|
||||
}
|
||||
if (automationDetailsId !== undefined) {
|
||||
args.push("--sarif-category", automationDetailsId);
|
||||
}
|
||||
|
||||
@@ -75,21 +75,34 @@ async function maybeUploadFailedSarif(
|
||||
|
||||
const sarifFile = "../codeql-failed-run.sarif";
|
||||
|
||||
const exportDiagnosticsEnabled = await featureEnablement.getValue(
|
||||
Feature.ExportDiagnosticsEnabled,
|
||||
codeql
|
||||
);
|
||||
|
||||
// If there is no database, we run 'export diagnostics'
|
||||
if (databasePath === undefined) {
|
||||
await codeql.diagnosticsExport(sarifFile, category);
|
||||
await codeql.diagnosticsExport(
|
||||
sarifFile,
|
||||
exportDiagnosticsEnabled,
|
||||
category
|
||||
);
|
||||
} else {
|
||||
// We call 'database export-diagnostics' to find any per-database diagnostics.
|
||||
await codeql.databaseExportDiagnostics(
|
||||
databasePath,
|
||||
true, // Database is always a cluster for CodeQL versions that support diagnostics.
|
||||
sarifFile,
|
||||
exportDiagnosticsEnabled,
|
||||
category
|
||||
);
|
||||
|
||||
// If there was no SARIF file produced, then we fall back on 'export diagnostics'.
|
||||
if (!fs.existsSync(sarifFile)) {
|
||||
await codeql.diagnosticsExport(sarifFile, category);
|
||||
await codeql.diagnosticsExport(
|
||||
sarifFile,
|
||||
exportDiagnosticsEnabled,
|
||||
category
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user