Rename SARIF_UPLOAD_TARGET

This commit is contained in:
Michael B. Gale 2025-06-26 11:38:45 +01:00
parent 27db6cb5d6
commit 71dd63398f
No known key found for this signature in database
GPG key ID: FF5E2765BD00628F
3 changed files with 15 additions and 15 deletions

18
lib/upload-lib.js generated
View file

@ -36,7 +36,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod }; return (mod && mod.__esModule) ? mod : { "default": mod };
}; };
Object.defineProperty(exports, "__esModule", { value: true }); Object.defineProperty(exports, "__esModule", { value: true });
exports.InvalidSarifUploadError = exports.CodeQualityTarget = exports.CodeScanningTarget = exports.defaultIsSarif = exports.qualityIsSarif = exports.SARIF_UPLOAD_TARGET = void 0; exports.InvalidSarifUploadError = exports.CodeQualityTarget = exports.CodeScanningTarget = exports.defaultIsSarif = exports.qualityIsSarif = exports.SARIF_UPLOAD_ENDPOINT = void 0;
exports.shouldShowCombineSarifFilesDeprecationWarning = shouldShowCombineSarifFilesDeprecationWarning; exports.shouldShowCombineSarifFilesDeprecationWarning = shouldShowCombineSarifFilesDeprecationWarning;
exports.populateRunAutomationDetails = populateRunAutomationDetails; exports.populateRunAutomationDetails = populateRunAutomationDetails;
exports.findSarifFilesInDir = findSarifFilesInDir; exports.findSarifFilesInDir = findSarifFilesInDir;
@ -237,14 +237,14 @@ function getAutomationID(category, analysis_key, environment) {
return api.computeAutomationID(analysis_key, environment); return api.computeAutomationID(analysis_key, environment);
} }
// Enumerates API endpoints that accept SARIF files. // Enumerates API endpoints that accept SARIF files.
var SARIF_UPLOAD_TARGET; var SARIF_UPLOAD_ENDPOINT;
(function (SARIF_UPLOAD_TARGET) { (function (SARIF_UPLOAD_ENDPOINT) {
SARIF_UPLOAD_TARGET["CODE_SCANNING_UPLOAD_TARGET"] = "PUT /repos/:owner/:repo/code-scanning/analysis"; SARIF_UPLOAD_ENDPOINT["CODE_SCANNING_UPLOAD_TARGET"] = "PUT /repos/:owner/:repo/code-scanning/analysis";
SARIF_UPLOAD_TARGET["CODE_QUALITY_UPLOAD_TARGET"] = "PUT /repos/:owner/:repo/code-quality/analysis"; SARIF_UPLOAD_ENDPOINT["CODE_QUALITY_UPLOAD_TARGET"] = "PUT /repos/:owner/:repo/code-quality/analysis";
})(SARIF_UPLOAD_TARGET || (exports.SARIF_UPLOAD_TARGET = SARIF_UPLOAD_TARGET = {})); })(SARIF_UPLOAD_ENDPOINT || (exports.SARIF_UPLOAD_ENDPOINT = SARIF_UPLOAD_ENDPOINT = {}));
// Upload the given payload. // Upload the given payload.
// If the request fails then this will retry a small number of times. // If the request fails then this will retry a small number of times.
async function uploadPayload(payload, repositoryNwo, logger, target = SARIF_UPLOAD_TARGET.CODE_SCANNING_UPLOAD_TARGET) { async function uploadPayload(payload, repositoryNwo, logger, target = SARIF_UPLOAD_ENDPOINT.CODE_SCANNING_UPLOAD_TARGET) {
logger.info("Uploading results"); logger.info("Uploading results");
// If in test mode we don't want to upload the results // If in test mode we don't want to upload the results
if (util.isInTestMode()) { if (util.isInTestMode()) {
@ -424,14 +424,14 @@ function buildPayload(commitOid, ref, analysisKey, analysisName, zippedSarif, wo
// Represents the Code Scanning upload target. // Represents the Code Scanning upload target.
exports.CodeScanningTarget = { exports.CodeScanningTarget = {
name: "code scanning", name: "code scanning",
target: SARIF_UPLOAD_TARGET.CODE_SCANNING_UPLOAD_TARGET, target: SARIF_UPLOAD_ENDPOINT.CODE_SCANNING_UPLOAD_TARGET,
sarifFilter: exports.defaultIsSarif, sarifFilter: exports.defaultIsSarif,
sentinelPrefix: "CODEQL_UPLOAD_SARIF_", sentinelPrefix: "CODEQL_UPLOAD_SARIF_",
}; };
// Represents the Code Quality upload target. // Represents the Code Quality upload target.
exports.CodeQualityTarget = { exports.CodeQualityTarget = {
name: "code quality", name: "code quality",
target: SARIF_UPLOAD_TARGET.CODE_QUALITY_UPLOAD_TARGET, target: SARIF_UPLOAD_ENDPOINT.CODE_QUALITY_UPLOAD_TARGET,
sarifFilter: exports.qualityIsSarif, sarifFilter: exports.qualityIsSarif,
sentinelPrefix: "CODEQL_UPLOAD_QUALITY_SARIF_", sentinelPrefix: "CODEQL_UPLOAD_QUALITY_SARIF_",
}; };

File diff suppressed because one or more lines are too long

View file

@ -307,7 +307,7 @@ function getAutomationID(
} }
// Enumerates API endpoints that accept SARIF files. // Enumerates API endpoints that accept SARIF files.
export enum SARIF_UPLOAD_TARGET { export enum SARIF_UPLOAD_ENDPOINT {
CODE_SCANNING_UPLOAD_TARGET = "PUT /repos/:owner/:repo/code-scanning/analysis", CODE_SCANNING_UPLOAD_TARGET = "PUT /repos/:owner/:repo/code-scanning/analysis",
CODE_QUALITY_UPLOAD_TARGET = "PUT /repos/:owner/:repo/code-quality/analysis", CODE_QUALITY_UPLOAD_TARGET = "PUT /repos/:owner/:repo/code-quality/analysis",
} }
@ -318,7 +318,7 @@ async function uploadPayload(
payload: any, payload: any,
repositoryNwo: RepositoryNwo, repositoryNwo: RepositoryNwo,
logger: Logger, logger: Logger,
target: SARIF_UPLOAD_TARGET = SARIF_UPLOAD_TARGET.CODE_SCANNING_UPLOAD_TARGET, target: SARIF_UPLOAD_ENDPOINT = SARIF_UPLOAD_ENDPOINT.CODE_SCANNING_UPLOAD_TARGET,
): Promise<string> { ): Promise<string> {
logger.info("Uploading results"); logger.info("Uploading results");
@ -584,7 +584,7 @@ export function buildPayload(
// Represents configurations for different services that we can upload SARIF to. // Represents configurations for different services that we can upload SARIF to.
export interface UploadTarget { export interface UploadTarget {
name: string; name: string;
target: SARIF_UPLOAD_TARGET; target: SARIF_UPLOAD_ENDPOINT;
sarifFilter: (name: string) => boolean; sarifFilter: (name: string) => boolean;
sentinelPrefix: string; sentinelPrefix: string;
} }
@ -592,7 +592,7 @@ export interface UploadTarget {
// Represents the Code Scanning upload target. // Represents the Code Scanning upload target.
export const CodeScanningTarget: UploadTarget = { export const CodeScanningTarget: UploadTarget = {
name: "code scanning", name: "code scanning",
target: SARIF_UPLOAD_TARGET.CODE_SCANNING_UPLOAD_TARGET, target: SARIF_UPLOAD_ENDPOINT.CODE_SCANNING_UPLOAD_TARGET,
sarifFilter: defaultIsSarif, sarifFilter: defaultIsSarif,
sentinelPrefix: "CODEQL_UPLOAD_SARIF_", sentinelPrefix: "CODEQL_UPLOAD_SARIF_",
}; };
@ -600,7 +600,7 @@ export const CodeScanningTarget: UploadTarget = {
// Represents the Code Quality upload target. // Represents the Code Quality upload target.
export const CodeQualityTarget: UploadTarget = { export const CodeQualityTarget: UploadTarget = {
name: "code quality", name: "code quality",
target: SARIF_UPLOAD_TARGET.CODE_QUALITY_UPLOAD_TARGET, target: SARIF_UPLOAD_ENDPOINT.CODE_QUALITY_UPLOAD_TARGET,
sarifFilter: qualityIsSarif, sarifFilter: qualityIsSarif,
sentinelPrefix: "CODEQL_UPLOAD_QUALITY_SARIF_", sentinelPrefix: "CODEQL_UPLOAD_QUALITY_SARIF_",
}; };