mirror of
https://github.com/github/codeql-action.git
synced 2025-12-24 08:10:06 +08:00
Remove support for combining SARIF runs with non-unique categories
This commit is contained in:
27
lib/upload-lib.js
generated
27
lib/upload-lib.js
generated
@@ -38,6 +38,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.InvalidSarifUploadError = exports.CodeQualityTarget = exports.CodeScanningTarget = exports.SARIF_UPLOAD_ENDPOINT = void 0;
|
||||
exports.shouldShowCombineSarifFilesDeprecationWarning = shouldShowCombineSarifFilesDeprecationWarning;
|
||||
exports.throwIfCombineSarifFilesDisabled = throwIfCombineSarifFilesDisabled;
|
||||
exports.populateRunAutomationDetails = populateRunAutomationDetails;
|
||||
exports.findSarifFilesInDir = findSarifFilesInDir;
|
||||
exports.getSarifFilePaths = getSarifFilePaths;
|
||||
@@ -65,6 +66,7 @@ const codeql_1 = require("./codeql");
|
||||
const config_utils_1 = require("./config-utils");
|
||||
const diff_informed_analysis_utils_1 = require("./diff-informed-analysis-utils");
|
||||
const environment_1 = require("./environment");
|
||||
const feature_flags_1 = require("./feature-flags");
|
||||
const fingerprints = __importStar(require("./fingerprints"));
|
||||
const gitUtils = __importStar(require("./git-utils"));
|
||||
const init_1 = require("./init");
|
||||
@@ -146,6 +148,27 @@ async function shouldShowCombineSarifFilesDeprecationWarning(sarifObjects, githu
|
||||
return (!areAllRunsUnique(sarifObjects) &&
|
||||
!process.env.CODEQL_MERGE_SARIF_DEPRECATION_WARNING);
|
||||
}
|
||||
async function throwIfCombineSarifFilesDisabled(sarifObjects, features, githubVersion) {
|
||||
if (!(await shouldDisableCombineSarifFiles(sarifObjects, features, githubVersion))) {
|
||||
return;
|
||||
}
|
||||
// TODO: Update this changelog URL to the correct one when it's published.
|
||||
const deprecationMoreInformationMessage = "For more information, see https://github.blog/changelog/2024-05-06-code-scanning-will-stop-combining-runs-from-a-single-upload";
|
||||
throw new util_1.ConfigurationError(`The CodeQL Action does not support uploading multiple SARIF runs with the same category. Please update your workflow to upload a single run per category. ${deprecationMoreInformationMessage}`);
|
||||
}
|
||||
// Checks whether combining SARIF files should be disabled.
|
||||
async function shouldDisableCombineSarifFiles(sarifObjects, features, githubVersion) {
|
||||
// Never block on GHES versions before 3.18.0
|
||||
if (githubVersion.type === util_1.GitHubVariant.GHES &&
|
||||
semver.lt(githubVersion.version, "3.18.0")) {
|
||||
return false;
|
||||
}
|
||||
if (areAllRunsUnique(sarifObjects)) {
|
||||
// If all runs are unique, we can safely combine them.
|
||||
return false;
|
||||
}
|
||||
return features.getValue(feature_flags_1.Feature.DisableCombineSarifFiles);
|
||||
}
|
||||
// Takes a list of paths to sarif files and combines them together using the
|
||||
// CLI `github merge-results` command when all SARIF files are produced by
|
||||
// CodeQL. Otherwise, it will fall back to combining the files in the action.
|
||||
@@ -160,9 +183,10 @@ async function combineSarifFilesUsingCLI(sarifFiles, gitHubVersion, features, lo
|
||||
});
|
||||
const deprecationWarningMessage = gitHubVersion.type === util_1.GitHubVariant.GHES
|
||||
? "and will be removed in GitHub Enterprise Server 3.18"
|
||||
: "and will be removed on June 4, 2025";
|
||||
: "and will be removed in July 2025";
|
||||
const deprecationMoreInformationMessage = "For more information, see https://github.blog/changelog/2024-05-06-code-scanning-will-stop-combining-runs-from-a-single-upload";
|
||||
if (!areAllRunsProducedByCodeQL(sarifObjects)) {
|
||||
await throwIfCombineSarifFilesDisabled(sarifObjects, features, gitHubVersion);
|
||||
logger.debug("Not all SARIF files were produced by CodeQL. Merging files in the action.");
|
||||
if (await shouldShowCombineSarifFilesDeprecationWarning(sarifObjects, gitHubVersion)) {
|
||||
logger.warning(`Uploading multiple SARIF runs with the same category is deprecated ${deprecationWarningMessage}. Please update your workflow to upload a single run per category. ${deprecationMoreInformationMessage}`);
|
||||
@@ -194,6 +218,7 @@ async function combineSarifFilesUsingCLI(sarifFiles, gitHubVersion, features, lo
|
||||
codeQL = initCodeQLResult.codeql;
|
||||
}
|
||||
if (!(await codeQL.supportsFeature(tools_features_1.ToolsFeature.SarifMergeRunsFromEqualCategory))) {
|
||||
await throwIfCombineSarifFilesDisabled(sarifObjects, features, gitHubVersion);
|
||||
logger.warning("The CodeQL CLI does not support merging SARIF files. Merging files in the action.");
|
||||
if (await shouldShowCombineSarifFilesDeprecationWarning(sarifObjects, gitHubVersion)) {
|
||||
logger.warning(`Uploading multiple CodeQL runs with the same category is deprecated ${deprecationWarningMessage} for CodeQL CLI 2.16.6 and earlier. Please update your CodeQL CLI version or update your workflow to set a distinct category for each CodeQL run. ${deprecationMoreInformationMessage}`);
|
||||
|
||||
Reference in New Issue
Block a user