mirror of
https://github.com/github/codeql-action.git
synced 2026-04-27 01:08:46 +00:00
Gate uploadSarif behind FF, use old implementation otherwise
This commit is contained in:
Generated
+62
-7
@@ -95738,6 +95738,23 @@ function findSarifFilesInDir(sarifPath, isSarif) {
|
||||
walkSarifFiles(sarifPath);
|
||||
return sarifFiles;
|
||||
}
|
||||
function getSarifFilePaths(sarifPath, isSarif) {
|
||||
if (!fs18.existsSync(sarifPath)) {
|
||||
throw new ConfigurationError(`Path does not exist: ${sarifPath}`);
|
||||
}
|
||||
let sarifFiles;
|
||||
if (fs18.lstatSync(sarifPath).isDirectory()) {
|
||||
sarifFiles = findSarifFilesInDir(sarifPath, isSarif);
|
||||
if (sarifFiles.length === 0) {
|
||||
throw new ConfigurationError(
|
||||
`No SARIF files found to upload in "${sarifPath}".`
|
||||
);
|
||||
}
|
||||
} else {
|
||||
sarifFiles = [sarifPath];
|
||||
}
|
||||
return sarifFiles;
|
||||
}
|
||||
async function getGroupedSarifFilePaths(logger, sarifPath) {
|
||||
const stats = fs18.statSync(sarifPath, { throwIfNoEntry: false });
|
||||
if (stats === void 0) {
|
||||
@@ -95881,6 +95898,20 @@ 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`);
|
||||
logger.info(`Processing sarif files: ${JSON.stringify(sarifPaths)}`);
|
||||
@@ -96349,13 +96380,37 @@ async function run() {
|
||||
if (runStats && getUploadValue(uploadInput) === "always") {
|
||||
const checkoutPath = getRequiredInput("checkout_path");
|
||||
const category = getOptionalInput("category");
|
||||
uploadResults = await uploadSarif(
|
||||
logger,
|
||||
features,
|
||||
checkoutPath,
|
||||
outputDir,
|
||||
category
|
||||
);
|
||||
if (await features.getValue("analyze_use_new_upload" /* AnalyzeUseNewUpload */)) {
|
||||
uploadResults = await uploadSarif(
|
||||
logger,
|
||||
features,
|
||||
checkoutPath,
|
||||
outputDir,
|
||||
category
|
||||
);
|
||||
} else {
|
||||
uploadResults = {};
|
||||
if (isCodeScanningEnabled(config)) {
|
||||
uploadResults["code-scanning" /* CodeScanning */] = await uploadFiles(
|
||||
outputDir,
|
||||
getRequiredInput("checkout_path"),
|
||||
getOptionalInput("category"),
|
||||
features,
|
||||
logger,
|
||||
CodeScanning
|
||||
);
|
||||
}
|
||||
if (isCodeQualityEnabled(config)) {
|
||||
uploadResults["code-quality" /* CodeQuality */] = await uploadFiles(
|
||||
outputDir,
|
||||
getRequiredInput("checkout_path"),
|
||||
getOptionalInput("category"),
|
||||
features,
|
||||
logger,
|
||||
CodeQuality
|
||||
);
|
||||
}
|
||||
}
|
||||
core14.setOutput(
|
||||
"sarif-id",
|
||||
uploadResults["code-scanning" /* CodeScanning */]?.sarifID
|
||||
|
||||
+41
-8
@@ -19,7 +19,12 @@ import { getApiDetails, getGitHubVersion } from "./api-client";
|
||||
import { runAutobuild } from "./autobuild";
|
||||
import { getTotalCacheSize, shouldStoreCache } from "./caching-utils";
|
||||
import { getCodeQL } from "./codeql";
|
||||
import { Config, getConfig } from "./config-utils";
|
||||
import {
|
||||
Config,
|
||||
getConfig,
|
||||
isCodeQualityEnabled,
|
||||
isCodeScanningEnabled,
|
||||
} from "./config-utils";
|
||||
import { uploadDatabases } from "./database-upload";
|
||||
import {
|
||||
DependencyCacheUploadStatusReport,
|
||||
@@ -344,13 +349,41 @@ async function run() {
|
||||
const checkoutPath = actionsUtil.getRequiredInput("checkout_path");
|
||||
const category = actionsUtil.getOptionalInput("category");
|
||||
|
||||
uploadResults = await uploadSarif(
|
||||
logger,
|
||||
features,
|
||||
checkoutPath,
|
||||
outputDir,
|
||||
category,
|
||||
);
|
||||
if (await features.getValue(Feature.AnalyzeUseNewUpload)) {
|
||||
uploadResults = await uploadSarif(
|
||||
logger,
|
||||
features,
|
||||
checkoutPath,
|
||||
outputDir,
|
||||
category,
|
||||
);
|
||||
} else {
|
||||
uploadResults = {};
|
||||
|
||||
if (isCodeScanningEnabled(config)) {
|
||||
uploadResults[analyses.AnalysisKind.CodeScanning] =
|
||||
await uploadLib.uploadFiles(
|
||||
outputDir,
|
||||
actionsUtil.getRequiredInput("checkout_path"),
|
||||
actionsUtil.getOptionalInput("category"),
|
||||
features,
|
||||
logger,
|
||||
analyses.CodeScanning,
|
||||
);
|
||||
}
|
||||
|
||||
if (isCodeQualityEnabled(config)) {
|
||||
uploadResults[analyses.AnalysisKind.CodeQuality] =
|
||||
await uploadLib.uploadFiles(
|
||||
outputDir,
|
||||
actionsUtil.getRequiredInput("checkout_path"),
|
||||
actionsUtil.getOptionalInput("category"),
|
||||
features,
|
||||
logger,
|
||||
analyses.CodeQuality,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
core.setOutput(
|
||||
"sarif-id",
|
||||
|
||||
Reference in New Issue
Block a user