mirror of
https://github.com/github/codeql-action.git
synced 2025-12-21 06:40:20 +08:00
Split SARIF post-processing steps from uploadSpecifiedFiles into a function
This commit is contained in:
52
lib/upload-lib.js
generated
52
lib/upload-lib.js
generated
@@ -84847,6 +84847,7 @@ __export(upload_lib_exports, {
|
||||
getGroupedSarifFilePaths: () => getGroupedSarifFilePaths,
|
||||
getSarifFilePaths: () => getSarifFilePaths,
|
||||
populateRunAutomationDetails: () => populateRunAutomationDetails,
|
||||
postProcessSarifFiles: () => postProcessSarifFiles,
|
||||
readSarifFile: () => readSarifFile,
|
||||
shouldConsiderConfigurationError: () => shouldConsiderConfigurationError,
|
||||
shouldConsiderInvalidRequest: () => shouldConsiderInvalidRequest,
|
||||
@@ -92712,26 +92713,11 @@ function buildPayload(commitOid, ref, analysisKey, analysisName, zippedSarif, wo
|
||||
}
|
||||
return payloadObj;
|
||||
}
|
||||
async function uploadFiles(inputSarifPath, checkoutPath, category, features, logger, uploadTarget) {
|
||||
const sarifPaths = getSarifFilePaths(
|
||||
inputSarifPath,
|
||||
uploadTarget.sarifPredicate
|
||||
);
|
||||
return uploadSpecifiedFiles(
|
||||
sarifPaths,
|
||||
checkoutPath,
|
||||
category,
|
||||
features,
|
||||
logger,
|
||||
uploadTarget
|
||||
);
|
||||
}
|
||||
async function uploadSpecifiedFiles(sarifPaths, checkoutPath, category, features, logger, uploadTarget) {
|
||||
logger.startGroup(`Uploading ${uploadTarget.name} results`);
|
||||
async function postProcessSarifFiles(logger, features, checkoutPath, sarifPaths, category, analysis) {
|
||||
logger.info(`Processing sarif files: ${JSON.stringify(sarifPaths)}`);
|
||||
const gitHubVersion = await getGitHubVersion();
|
||||
let sarif;
|
||||
category = uploadTarget.fixCategory(logger, category);
|
||||
category = analysis.fixCategory(logger, category);
|
||||
if (sarifPaths.length > 1) {
|
||||
for (const sarifPath of sarifPaths) {
|
||||
const parsedSarif = readSarifFile(sarifPath);
|
||||
@@ -92759,6 +92745,33 @@ async function uploadSpecifiedFiles(sarifPaths, checkoutPath, category, features
|
||||
analysisKey,
|
||||
environment
|
||||
);
|
||||
return { sarif, analysisKey, environment };
|
||||
}
|
||||
async function uploadFiles(inputSarifPath, checkoutPath, category, features, logger, uploadTarget) {
|
||||
const sarifPaths = getSarifFilePaths(
|
||||
inputSarifPath,
|
||||
uploadTarget.sarifPredicate
|
||||
);
|
||||
return uploadSpecifiedFiles(
|
||||
sarifPaths,
|
||||
checkoutPath,
|
||||
category,
|
||||
features,
|
||||
logger,
|
||||
uploadTarget
|
||||
);
|
||||
}
|
||||
async function uploadSpecifiedFiles(sarifPaths, checkoutPath, category, features, logger, uploadTarget) {
|
||||
logger.startGroup(`Uploading ${uploadTarget.name} results`);
|
||||
const processingResults = await postProcessSarifFiles(
|
||||
logger,
|
||||
features,
|
||||
checkoutPath,
|
||||
sarifPaths,
|
||||
category,
|
||||
uploadTarget
|
||||
);
|
||||
const sarif = processingResults.sarif;
|
||||
const toolNames = getToolNames(sarif);
|
||||
logger.debug(`Validating that each SARIF run has a unique category`);
|
||||
validateUniqueCategory(sarif, uploadTarget.sentinelPrefix);
|
||||
@@ -92774,13 +92787,13 @@ async function uploadSpecifiedFiles(sarifPaths, checkoutPath, category, features
|
||||
const payload = buildPayload(
|
||||
await getCommitOid(checkoutPath),
|
||||
await getRef(),
|
||||
analysisKey,
|
||||
processingResults.analysisKey,
|
||||
getRequiredEnvParam("GITHUB_WORKFLOW"),
|
||||
zippedSarif,
|
||||
getWorkflowRunID(),
|
||||
getWorkflowRunAttempt(),
|
||||
checkoutURI,
|
||||
environment,
|
||||
processingResults.environment,
|
||||
toolNames,
|
||||
await determineBaseBranchHeadCommitOid()
|
||||
);
|
||||
@@ -92980,6 +92993,7 @@ function filterAlertsByDiffRange(logger, sarif) {
|
||||
getGroupedSarifFilePaths,
|
||||
getSarifFilePaths,
|
||||
populateRunAutomationDetails,
|
||||
postProcessSarifFiles,
|
||||
readSarifFile,
|
||||
shouldConsiderConfigurationError,
|
||||
shouldConsiderInvalidRequest,
|
||||
|
||||
Reference in New Issue
Block a user