diff --git a/lib/init-action-post.js b/lib/init-action-post.js index 781e8975a..8c223911c 100644 --- a/lib/init-action-post.js +++ b/lib/init-action-post.js @@ -169806,13 +169806,15 @@ async function prepareFailedSarif(logger, features, config) { upload_failed_run_skipped_because: "Unexpectedly, the configuration is not for a single language." }); } - const category = `/language:${config.languages[0]}`; + const language = config.languages[0]; + const category = `/language:${language}`; const checkoutPath = "."; const result = await generateFailedSarif( features, config, category, - checkoutPath + checkoutPath, + `../codeql-failed-sarif-${language}${RiskAssessment.sarifExtension}` ); return new Success(result); } else { @@ -169836,10 +169838,12 @@ async function prepareFailedSarif(logger, features, config) { return new Success(result); } } -async function generateFailedSarif(features, config, category, checkoutPath) { +async function generateFailedSarif(features, config, category, checkoutPath, sarifFile) { const databasePath = config.dbLocation; const codeql = await getCodeQL(config.codeQLCmd); - const sarifFile = "../codeql-failed-run.sarif"; + if (sarifFile === void 0) { + sarifFile = "../codeql-failed-run.sarif"; + } if (databasePath === void 0 || !await features.getValue("export_diagnostics_enabled" /* ExportDiagnosticsEnabled */, codeql)) { await codeql.diagnosticsExport(sarifFile, category, config); } else { diff --git a/src/init-action-post-helper.ts b/src/init-action-post-helper.ts index b1789aaba..6fe38f3bb 100644 --- a/src/init-action-post-helper.ts +++ b/src/init-action-post-helper.ts @@ -4,7 +4,7 @@ import path from "path"; import * as github from "@actions/github"; import * as actionsUtil from "./actions-util"; -import { CodeScanning } from "./analyses"; +import { CodeScanning, RiskAssessment } from "./analyses"; import { getApiClient, getGitHubVersion } from "./api-client"; import { CodeQL, getCodeQL } from "./codeql"; import { @@ -115,13 +115,15 @@ async function prepareFailedSarif( } // We can make these assumptions for risk assessments. - const category = `/language:${config.languages[0]}`; + const language = config.languages[0]; + const category = `/language:${language}`; const checkoutPath = "."; const result = await generateFailedSarif( features, config, category, checkoutPath, + `../codeql-failed-sarif-${language}${RiskAssessment.sarifExtension}`, ); return new Success(result); } else { @@ -154,11 +156,15 @@ async function generateFailedSarif( config: Config, category: string | undefined, checkoutPath: string, + sarifFile?: string, ) { const databasePath = config.dbLocation; - const codeql = await getCodeQL(config.codeQLCmd); - const sarifFile = "../codeql-failed-run.sarif"; + + // Set the filename for the SARIF file if not already set. + if (sarifFile === undefined) { + sarifFile = "../codeql-failed-run.sarif"; + } // If there is no database or the feature flag is off, we run 'export diagnostics' if (