mirror of
https://github.com/github/codeql-action.git
synced 2026-10-21 02:01:27 +00:00
Use temporary diagnostic dir in generateFailedSarif
This commit is contained in:
11
lib/entry-points.js
generated
11
lib/entry-points.js
generated
@@ -177370,7 +177370,7 @@ async function getCodeQLForCmd(logger2, cmd, checkVersion) {
|
||||
}
|
||||
await new toolrunner3.ToolRunner(cmd, args).exec();
|
||||
},
|
||||
async diagnosticsExport(sarifFile, automationDetailsId, config) {
|
||||
async diagnosticsExport(sarifFile, automationDetailsId, config, diagnosticDir) {
|
||||
const args = [
|
||||
"diagnostics",
|
||||
"export",
|
||||
@@ -177379,6 +177379,7 @@ async function getCodeQLForCmd(logger2, cmd, checkVersion) {
|
||||
`--sarif-codescanning-config=${getGeneratedCodeScanningConfigPath(
|
||||
config
|
||||
)}`,
|
||||
...diagnosticDir !== void 0 ? [`--diagnostic-dir=${diagnosticDir}`] : [],
|
||||
...getExtraOptionsFromEnv(["diagnostics", "export"])
|
||||
];
|
||||
if (automationDetailsId !== void 0) {
|
||||
@@ -186909,7 +186910,13 @@ async function generateFailedSarif(logger2, features, config, category, checkout
|
||||
sarifFile = "../codeql-failed-run.sarif";
|
||||
}
|
||||
if (databasePath === void 0 || !await features.getValue("export_diagnostics_enabled" /* ExportDiagnosticsEnabled */, codeql)) {
|
||||
await codeql.diagnosticsExport(sarifFile, category, config);
|
||||
let diagnosticDir = getTempDiagnosticPath(
|
||||
config.tempDir
|
||||
);
|
||||
if (!fs31.existsSync(diagnosticDir)) {
|
||||
diagnosticDir = void 0;
|
||||
}
|
||||
await codeql.diagnosticsExport(sarifFile, category, config, diagnosticDir);
|
||||
} else {
|
||||
await codeql.databaseExportDiagnostics(databasePath, sarifFile, category);
|
||||
}
|
||||
|
||||
@@ -199,6 +199,7 @@ export interface CodeQL {
|
||||
sarifFile: string,
|
||||
automationDetailsId: string | undefined,
|
||||
config: ActionConfig<"tempDir">,
|
||||
diagnosticDir: string | undefined,
|
||||
): Promise<void>;
|
||||
/** Get the location of an extractor for the specified language. */
|
||||
resolveExtractor(language: Language): Promise<string>;
|
||||
@@ -915,6 +916,7 @@ async function getCodeQLForCmd(
|
||||
sarifFile: string,
|
||||
automationDetailsId: string | undefined,
|
||||
config: ActionConfig<"tempDir">,
|
||||
diagnosticDir: string | undefined,
|
||||
): Promise<void> {
|
||||
const args = [
|
||||
"diagnostics",
|
||||
@@ -924,6 +926,9 @@ async function getCodeQLForCmd(
|
||||
`--sarif-codescanning-config=${getGeneratedCodeScanningConfigPath(
|
||||
config,
|
||||
)}`,
|
||||
...(diagnosticDir !== undefined
|
||||
? [`--diagnostic-dir=${diagnosticDir}`]
|
||||
: []),
|
||||
...getExtraOptionsFromEnv(["diagnostics", "export"]),
|
||||
];
|
||||
if (automationDetailsId !== undefined) {
|
||||
|
||||
@@ -24,6 +24,7 @@ import {
|
||||
type UploadDebugArtifactsConfig,
|
||||
} from "./debug-artifacts";
|
||||
import * as dependencyCaching from "./dependency-caching";
|
||||
import { getTempDiagnosticPath } from "./diagnostics";
|
||||
import { EnvVar, ReadOnlyEnv } from "./environment";
|
||||
import { Feature, FeatureEnablement } from "./feature-flags";
|
||||
import { Logger } from "./logging";
|
||||
@@ -189,7 +190,19 @@ async function generateFailedSarif(
|
||||
databasePath === undefined ||
|
||||
!(await features.getValue(Feature.ExportDiagnosticsEnabled, codeql))
|
||||
) {
|
||||
await codeql.diagnosticsExport(sarifFile, category, config);
|
||||
// If we don't have a database path, then we may have diagnostics that were written to a
|
||||
// temporary location. Get the path that they would have been written to and check whether
|
||||
// it exists. If so, pass it on to the CLI. The CLI will not complain if we give it a
|
||||
// path that doesn't exist, so we are just being extra defensive here.
|
||||
let diagnosticDir: string | undefined = getTempDiagnosticPath(
|
||||
config.tempDir,
|
||||
);
|
||||
|
||||
if (!fs.existsSync(diagnosticDir)) {
|
||||
diagnosticDir = undefined;
|
||||
}
|
||||
|
||||
await codeql.diagnosticsExport(sarifFile, category, config, diagnosticDir);
|
||||
} else {
|
||||
// We call 'database export-diagnostics' to find any per-database diagnostics.
|
||||
await codeql.databaseExportDiagnostics(databasePath, sarifFile, category);
|
||||
|
||||
Reference in New Issue
Block a user