mirror of
https://github.com/github/codeql-action.git
synced 2025-12-24 08:10:06 +08:00
Write processed SARIF files if post-process-output input is provided
This commit is contained in:
27
lib/upload-lib.js
generated
27
lib/upload-lib.js
generated
@@ -84858,7 +84858,8 @@ __export(upload_lib_exports, {
|
||||
uploadProcessedFiles: () => uploadProcessedFiles,
|
||||
validateSarifFileSchema: () => validateSarifFileSchema,
|
||||
validateUniqueCategory: () => validateUniqueCategory,
|
||||
waitForProcessing: () => waitForProcessing
|
||||
waitForProcessing: () => waitForProcessing,
|
||||
writeProcessedFiles: () => writeProcessedFiles
|
||||
});
|
||||
module.exports = __toCommonJS(upload_lib_exports);
|
||||
var fs13 = __toESM(require("fs"));
|
||||
@@ -92747,6 +92748,19 @@ async function postProcessSarifFiles(logger, features, checkoutPath, sarifPaths,
|
||||
);
|
||||
return { sarif, analysisKey, environment };
|
||||
}
|
||||
async function writeProcessedFiles(logger, pathInput, uploadTarget, processingResults) {
|
||||
const outputPath = pathInput || process.env["CODEQL_ACTION_SARIF_DUMP_DIR" /* SARIF_DUMP_DIR */];
|
||||
if (outputPath !== void 0) {
|
||||
dumpSarifFile(
|
||||
JSON.stringify(processingResults.sarif),
|
||||
outputPath,
|
||||
logger,
|
||||
uploadTarget
|
||||
);
|
||||
} else {
|
||||
logger.debug(`Not writing processed SARIF files.`);
|
||||
}
|
||||
}
|
||||
async function uploadFiles(inputSarifPath, checkoutPath, category, features, logger, uploadTarget) {
|
||||
const sarifPaths = getSarifFilePaths(
|
||||
inputSarifPath,
|
||||
@@ -92785,10 +92799,6 @@ async function uploadProcessedFiles(logger, checkoutPath, uploadTarget, processi
|
||||
validateUniqueCategory(sarif, uploadTarget.sentinelPrefix);
|
||||
logger.debug(`Serializing SARIF for upload`);
|
||||
const sarifPayload = JSON.stringify(sarif);
|
||||
const dumpDir = process.env["CODEQL_ACTION_SARIF_DUMP_DIR" /* SARIF_DUMP_DIR */];
|
||||
if (dumpDir) {
|
||||
dumpSarifFile(sarifPayload, dumpDir, logger, uploadTarget);
|
||||
}
|
||||
logger.debug(`Compressing serialized SARIF`);
|
||||
const zippedSarif = import_zlib.default.gzipSync(sarifPayload).toString("base64");
|
||||
const checkoutURI = url.pathToFileURL(checkoutPath).href;
|
||||
@@ -92832,14 +92842,14 @@ function dumpSarifFile(sarifPayload, outputDir, logger, uploadTarget) {
|
||||
fs13.mkdirSync(outputDir, { recursive: true });
|
||||
} else if (!fs13.lstatSync(outputDir).isDirectory()) {
|
||||
throw new ConfigurationError(
|
||||
`The path specified by the ${"CODEQL_ACTION_SARIF_DUMP_DIR" /* SARIF_DUMP_DIR */} environment variable exists and is not a directory: ${outputDir}`
|
||||
`The path that processed SARIF files should be written to exists, but is not a directory: ${outputDir}`
|
||||
);
|
||||
}
|
||||
const outputFile = path14.resolve(
|
||||
outputDir,
|
||||
`upload${uploadTarget.sarifExtension}`
|
||||
);
|
||||
logger.info(`Dumping processed SARIF file to ${outputFile}`);
|
||||
logger.info(`Writing processed SARIF file to ${outputFile}`);
|
||||
fs13.writeFileSync(outputFile, sarifPayload);
|
||||
}
|
||||
var STATUS_CHECK_FREQUENCY_MILLISECONDS = 5 * 1e3;
|
||||
@@ -93012,7 +93022,8 @@ function filterAlertsByDiffRange(logger, sarif) {
|
||||
uploadProcessedFiles,
|
||||
validateSarifFileSchema,
|
||||
validateUniqueCategory,
|
||||
waitForProcessing
|
||||
waitForProcessing,
|
||||
writeProcessedFiles
|
||||
});
|
||||
/*! Bundled license information:
|
||||
|
||||
|
||||
Reference in New Issue
Block a user