mirror of
https://github.com/github/codeql-action.git
synced 2025-12-24 08:10:06 +08:00
Merge branch 'main' into mario-campos/node24
This commit is contained in:
121
lib/upload-lib.js
generated
121
lib/upload-lib.js
generated
@@ -29446,11 +29446,11 @@ var require_out = __commonJS({
|
||||
async.read(path15, getSettings(optionsOrSettingsOrCallback), callback);
|
||||
}
|
||||
exports2.stat = stat;
|
||||
function statSync2(path15, optionsOrSettings) {
|
||||
function statSync3(path15, optionsOrSettings) {
|
||||
const settings = getSettings(optionsOrSettings);
|
||||
return sync.read(path15, settings);
|
||||
}
|
||||
exports2.statSync = statSync2;
|
||||
exports2.statSync = statSync3;
|
||||
function getSettings(settingsOrOptions = {}) {
|
||||
if (settingsOrOptions instanceof settings_1.default) {
|
||||
return settingsOrOptions;
|
||||
@@ -84821,6 +84821,7 @@ __export(upload_lib_exports, {
|
||||
InvalidSarifUploadError: () => InvalidSarifUploadError,
|
||||
buildPayload: () => buildPayload,
|
||||
findSarifFilesInDir: () => findSarifFilesInDir,
|
||||
getGroupedSarifFilePaths: () => getGroupedSarifFilePaths,
|
||||
getSarifFilePaths: () => getSarifFilePaths,
|
||||
populateRunAutomationDetails: () => populateRunAutomationDetails,
|
||||
readSarifFile: () => readSarifFile,
|
||||
@@ -88473,6 +88474,9 @@ function getWorkflowRunAttempt() {
|
||||
}
|
||||
return workflowRunAttempt;
|
||||
}
|
||||
function isDefaultSetup() {
|
||||
return getWorkflowEventName() === "dynamic";
|
||||
}
|
||||
function prettyPrintInvocation(cmd, args) {
|
||||
return [cmd, ...args].map((x) => x.includes(" ") ? `'${x}'` : x).join(" ");
|
||||
}
|
||||
@@ -88529,6 +88533,57 @@ async function runTool(cmd, args = [], opts = {}) {
|
||||
}
|
||||
return stdout;
|
||||
}
|
||||
var qualityCategoryMapping = {
|
||||
"c#": "csharp",
|
||||
cpp: "c-cpp",
|
||||
c: "c-cpp",
|
||||
"c++": "c-cpp",
|
||||
java: "java-kotlin",
|
||||
javascript: "javascript-typescript",
|
||||
typescript: "javascript-typescript",
|
||||
kotlin: "java-kotlin"
|
||||
};
|
||||
function fixCodeQualityCategory(logger, category) {
|
||||
if (category !== void 0 && isDefaultSetup() && category.startsWith("/language:")) {
|
||||
const language = category.substring("/language:".length);
|
||||
const mappedLanguage = qualityCategoryMapping[language];
|
||||
if (mappedLanguage) {
|
||||
const newCategory = `/language:${mappedLanguage}`;
|
||||
logger.info(
|
||||
`Adjusted category for Code Quality from '${category}' to '${newCategory}'.`
|
||||
);
|
||||
return newCategory;
|
||||
}
|
||||
}
|
||||
return category;
|
||||
}
|
||||
|
||||
// src/analyses.ts
|
||||
var AnalysisKind = /* @__PURE__ */ ((AnalysisKind2) => {
|
||||
AnalysisKind2["CodeScanning"] = "code-scanning";
|
||||
AnalysisKind2["CodeQuality"] = "code-quality";
|
||||
return AnalysisKind2;
|
||||
})(AnalysisKind || {});
|
||||
var supportedAnalysisKinds = new Set(Object.values(AnalysisKind));
|
||||
var CodeScanning = {
|
||||
kind: "code-scanning" /* CodeScanning */,
|
||||
name: "code scanning",
|
||||
target: "PUT /repos/:owner/:repo/code-scanning/analysis" /* CODE_SCANNING */,
|
||||
sarifExtension: ".sarif",
|
||||
sarifPredicate: (name) => name.endsWith(CodeScanning.sarifExtension) && !CodeQuality.sarifPredicate(name),
|
||||
fixCategory: (_, category) => category,
|
||||
sentinelPrefix: "CODEQL_UPLOAD_SARIF_"
|
||||
};
|
||||
var CodeQuality = {
|
||||
kind: "code-quality" /* CodeQuality */,
|
||||
name: "code quality",
|
||||
target: "PUT /repos/:owner/:repo/code-quality/analysis" /* CODE_QUALITY */,
|
||||
sarifExtension: ".quality.sarif",
|
||||
sarifPredicate: (name) => name.endsWith(CodeQuality.sarifExtension),
|
||||
fixCategory: fixCodeQualityCategory,
|
||||
sentinelPrefix: "CODEQL_UPLOAD_QUALITY_SARIF_"
|
||||
};
|
||||
var SarifScanOrder = [CodeQuality, CodeScanning];
|
||||
|
||||
// src/api-client.ts
|
||||
var core5 = __toESM(require_core());
|
||||
@@ -88921,14 +88976,6 @@ function wrapCliConfigurationError(cliError) {
|
||||
var fs7 = __toESM(require("fs"));
|
||||
var path9 = __toESM(require("path"));
|
||||
|
||||
// src/analyses.ts
|
||||
var AnalysisKind = /* @__PURE__ */ ((AnalysisKind2) => {
|
||||
AnalysisKind2["CodeScanning"] = "code-scanning";
|
||||
AnalysisKind2["CodeQuality"] = "code-quality";
|
||||
return AnalysisKind2;
|
||||
})(AnalysisKind || {});
|
||||
var supportedAnalysisKinds = new Set(Object.values(AnalysisKind));
|
||||
|
||||
// src/caching-utils.ts
|
||||
var core6 = __toESM(require_core());
|
||||
|
||||
@@ -88949,8 +88996,8 @@ var path8 = __toESM(require("path"));
|
||||
var semver4 = __toESM(require_semver2());
|
||||
|
||||
// src/defaults.json
|
||||
var bundleVersion = "codeql-bundle-v2.23.1";
|
||||
var cliVersion = "2.23.1";
|
||||
var bundleVersion = "codeql-bundle-v2.23.2";
|
||||
var cliVersion = "2.23.2";
|
||||
|
||||
// src/overlay-database-utils.ts
|
||||
var fs5 = __toESM(require("fs"));
|
||||
@@ -92391,6 +92438,54 @@ function getSarifFilePaths(sarifPath, isSarif) {
|
||||
}
|
||||
return sarifFiles;
|
||||
}
|
||||
async function getGroupedSarifFilePaths(logger, sarifPath) {
|
||||
const stats = fs13.statSync(sarifPath, { throwIfNoEntry: false });
|
||||
if (stats === void 0) {
|
||||
throw new ConfigurationError(`Path does not exist: ${sarifPath}`);
|
||||
}
|
||||
const results = {};
|
||||
if (stats.isDirectory()) {
|
||||
let unassignedSarifFiles = findSarifFilesInDir(
|
||||
sarifPath,
|
||||
(name) => path14.extname(name) === ".sarif"
|
||||
);
|
||||
logger.debug(
|
||||
`Found the following .sarif files in ${sarifPath}: ${unassignedSarifFiles.join(", ")}`
|
||||
);
|
||||
for (const analysisConfig of SarifScanOrder) {
|
||||
const filesForCurrentAnalysis = unassignedSarifFiles.filter(
|
||||
analysisConfig.sarifPredicate
|
||||
);
|
||||
if (filesForCurrentAnalysis.length > 0) {
|
||||
logger.debug(
|
||||
`The following SARIF files are for ${analysisConfig.name}: ${filesForCurrentAnalysis.join(", ")}`
|
||||
);
|
||||
unassignedSarifFiles = unassignedSarifFiles.filter(
|
||||
(name) => !analysisConfig.sarifPredicate(name)
|
||||
);
|
||||
results[analysisConfig.kind] = filesForCurrentAnalysis;
|
||||
} else {
|
||||
logger.debug(`Found no SARIF files for ${analysisConfig.name}`);
|
||||
}
|
||||
}
|
||||
if (unassignedSarifFiles.length !== 0) {
|
||||
logger.warning(
|
||||
`Found files in ${sarifPath} which do not belong to any analysis: ${unassignedSarifFiles.join(", ")}`
|
||||
);
|
||||
}
|
||||
} else {
|
||||
for (const analysisConfig of SarifScanOrder) {
|
||||
if (analysisConfig.kind === "code-scanning" /* CodeScanning */ || analysisConfig.sarifPredicate(sarifPath)) {
|
||||
logger.debug(
|
||||
`Using '${sarifPath}' as a SARIF file for ${analysisConfig.name}.`
|
||||
);
|
||||
results[analysisConfig.kind] = [sarifPath];
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return results;
|
||||
}
|
||||
function countResultsInSarif(sarif) {
|
||||
let numResults = 0;
|
||||
const parsedSarif = JSON.parse(sarif);
|
||||
@@ -92505,6 +92600,7 @@ async function uploadSpecifiedFiles(sarifPaths, checkoutPath, category, features
|
||||
logger.info(`Processing sarif files: ${JSON.stringify(sarifPaths)}`);
|
||||
const gitHubVersion = await getGitHubVersion();
|
||||
let sarif;
|
||||
category = uploadTarget.fixCategory(logger, category);
|
||||
if (sarifPaths.length > 1) {
|
||||
for (const sarifPath of sarifPaths) {
|
||||
const parsedSarif = readSarifFile(sarifPath);
|
||||
@@ -92750,6 +92846,7 @@ function filterAlertsByDiffRange(logger, sarif) {
|
||||
InvalidSarifUploadError,
|
||||
buildPayload,
|
||||
findSarifFilesInDir,
|
||||
getGroupedSarifFilePaths,
|
||||
getSarifFilePaths,
|
||||
populateRunAutomationDetails,
|
||||
readSarifFile,
|
||||
|
||||
Reference in New Issue
Block a user