Merge pull request #3064 from github/mbg/cq/allow-cq-only-analysis

Allow Code Quality only analysis
This commit is contained in:
Michael B. Gale
2025-09-08 16:13:19 +01:00
committed by GitHub
28 changed files with 929 additions and 470 deletions

63
lib/upload-lib.js generated
View File

@@ -21585,7 +21585,7 @@ var require_dist_node2 = __commonJS({
return value;
}
}
function isDefined(value) {
function isDefined2(value) {
return value !== void 0 && value !== null;
}
function isKeyOperator(operator) {
@@ -21593,7 +21593,7 @@ var require_dist_node2 = __commonJS({
}
function getValues(context2, operator, key, modifier) {
var value = context2[key], result = [];
if (isDefined(value) && value !== "") {
if (isDefined2(value) && value !== "") {
if (typeof value === "string" || typeof value === "number" || typeof value === "boolean") {
value = value.toString();
if (modifier && modifier !== "*") {
@@ -21605,14 +21605,14 @@ var require_dist_node2 = __commonJS({
} else {
if (modifier === "*") {
if (Array.isArray(value)) {
value.filter(isDefined).forEach(function(value2) {
value.filter(isDefined2).forEach(function(value2) {
result.push(
encodeValue(operator, value2, isKeyOperator(operator) ? key : "")
);
});
} else {
Object.keys(value).forEach(function(k) {
if (isDefined(value[k])) {
if (isDefined2(value[k])) {
result.push(encodeValue(operator, value[k], k));
}
});
@@ -21620,12 +21620,12 @@ var require_dist_node2 = __commonJS({
} else {
const tmp = [];
if (Array.isArray(value)) {
value.filter(isDefined).forEach(function(value2) {
value.filter(isDefined2).forEach(function(value2) {
tmp.push(encodeValue(operator, value2));
});
} else {
Object.keys(value).forEach(function(k) {
if (isDefined(value[k])) {
if (isDefined2(value[k])) {
tmp.push(encodeUnreserved(k));
tmp.push(encodeValue(operator, value[k].toString()));
}
@@ -21640,7 +21640,7 @@ var require_dist_node2 = __commonJS({
}
} else {
if (operator === ";") {
if (isDefined(value)) {
if (isDefined2(value)) {
result.push(encodeUnreserved(key));
}
} else if (value === "" && (operator === "&" || operator === "?")) {
@@ -22325,7 +22325,7 @@ var require_dist_node6 = __commonJS({
return value;
}
}
function isDefined(value) {
function isDefined2(value) {
return value !== void 0 && value !== null;
}
function isKeyOperator(operator) {
@@ -22333,7 +22333,7 @@ var require_dist_node6 = __commonJS({
}
function getValues(context2, operator, key, modifier) {
var value = context2[key], result = [];
if (isDefined(value) && value !== "") {
if (isDefined2(value) && value !== "") {
if (typeof value === "string" || typeof value === "number" || typeof value === "boolean") {
value = value.toString();
if (modifier && modifier !== "*") {
@@ -22345,14 +22345,14 @@ var require_dist_node6 = __commonJS({
} else {
if (modifier === "*") {
if (Array.isArray(value)) {
value.filter(isDefined).forEach(function(value2) {
value.filter(isDefined2).forEach(function(value2) {
result.push(
encodeValue(operator, value2, isKeyOperator(operator) ? key : "")
);
});
} else {
Object.keys(value).forEach(function(k) {
if (isDefined(value[k])) {
if (isDefined2(value[k])) {
result.push(encodeValue(operator, value[k], k));
}
});
@@ -22360,12 +22360,12 @@ var require_dist_node6 = __commonJS({
} else {
const tmp = [];
if (Array.isArray(value)) {
value.filter(isDefined).forEach(function(value2) {
value.filter(isDefined2).forEach(function(value2) {
tmp.push(encodeValue(operator, value2));
});
} else {
Object.keys(value).forEach(function(k) {
if (isDefined(value[k])) {
if (isDefined2(value[k])) {
tmp.push(encodeUnreserved(k));
tmp.push(encodeValue(operator, value[k].toString()));
}
@@ -22380,7 +22380,7 @@ var require_dist_node6 = __commonJS({
}
} else {
if (operator === ";") {
if (isDefined(value)) {
if (isDefined2(value)) {
result.push(encodeUnreserved(key));
}
} else if (value === "" && (operator === "&" || operator === "?")) {
@@ -38967,14 +38967,14 @@ var require_typeGuards = __commonJS({
"node_modules/@azure/core-util/dist/commonjs/typeGuards.js"(exports2) {
"use strict";
Object.defineProperty(exports2, "__esModule", { value: true });
exports2.isDefined = isDefined;
exports2.isDefined = isDefined2;
exports2.isObjectWithProperties = isObjectWithProperties;
exports2.objectHasProperty = objectHasProperty;
function isDefined(thing) {
function isDefined2(thing) {
return typeof thing !== "undefined" && thing !== null;
}
function isObjectWithProperties(thing, properties) {
if (!isDefined(thing) || typeof thing !== "object") {
if (!isDefined2(thing) || typeof thing !== "object") {
return false;
}
for (const property of properties) {
@@ -38985,7 +38985,7 @@ var require_typeGuards = __commonJS({
return true;
}
function objectHasProperty(thing, property) {
return isDefined(thing) && typeof thing === "object" && property in thing;
return isDefined2(thing) && typeof thing === "object" && property in thing;
}
}
});
@@ -84778,10 +84778,7 @@ var require_sarif_schema_2_1_0 = __commonJS({
// src/upload-lib.ts
var upload_lib_exports = {};
__export(upload_lib_exports, {
CodeQualityTarget: () => CodeQualityTarget,
CodeScanningTarget: () => CodeScanningTarget,
InvalidSarifUploadError: () => InvalidSarifUploadError,
SARIF_UPLOAD_ENDPOINT: () => SARIF_UPLOAD_ENDPOINT,
buildPayload: () => buildPayload,
findSarifFilesInDir: () => findSarifFilesInDir,
getSarifFilePaths: () => getSarifFilePaths,
@@ -92203,11 +92200,6 @@ function getAutomationID2(category, analysis_key, environment) {
}
return computeAutomationID(analysis_key, environment);
}
var SARIF_UPLOAD_ENDPOINT = /* @__PURE__ */ ((SARIF_UPLOAD_ENDPOINT2) => {
SARIF_UPLOAD_ENDPOINT2["CODE_SCANNING"] = "PUT /repos/:owner/:repo/code-scanning/analysis";
SARIF_UPLOAD_ENDPOINT2["CODE_QUALITY"] = "PUT /repos/:owner/:repo/code-quality/analysis";
return SARIF_UPLOAD_ENDPOINT2;
})(SARIF_UPLOAD_ENDPOINT || {});
async function uploadPayload(payload, repositoryNwo, logger, target) {
logger.info("Uploading results");
if (isInTestMode()) {
@@ -92376,18 +92368,6 @@ function buildPayload(commitOid, ref, analysisKey, analysisName, zippedSarif, wo
}
return payloadObj;
}
var CodeScanningTarget = {
name: "code scanning",
target: "PUT /repos/:owner/:repo/code-scanning/analysis" /* CODE_SCANNING */,
sarifPredicate: (name) => name.endsWith(".sarif") && !CodeQualityTarget.sarifPredicate(name),
sentinelPrefix: "CODEQL_UPLOAD_SARIF_"
};
var CodeQualityTarget = {
name: "code quality",
target: "PUT /repos/:owner/:repo/code-quality/analysis" /* CODE_QUALITY */,
sarifPredicate: (name) => name.endsWith(".quality.sarif"),
sentinelPrefix: "CODEQL_UPLOAD_QUALITY_SARIF_"
};
async function uploadFiles(inputSarifPath, checkoutPath, category, features, logger, uploadTarget) {
const sarifPaths = getSarifFilePaths(
inputSarifPath,
@@ -92402,7 +92382,7 @@ async function uploadFiles(inputSarifPath, checkoutPath, category, features, log
uploadTarget
);
}
async function uploadSpecifiedFiles(sarifPaths, checkoutPath, category, features, logger, uploadTarget = CodeScanningTarget) {
async function uploadSpecifiedFiles(sarifPaths, checkoutPath, category, features, logger, uploadTarget) {
logger.startGroup(`Uploading ${uploadTarget.name} results`);
logger.info(`Processing sarif files: ${JSON.stringify(sarifPaths)}`);
const gitHubVersion = await getGitHubVersion();
@@ -92573,7 +92553,7 @@ function handleProcessingResultForUnsuccessfulExecution(response, status, logger
assertNever(status);
}
}
function validateUniqueCategory(sarif, sentinelPrefix = CodeScanningTarget.sentinelPrefix) {
function validateUniqueCategory(sarif, sentinelPrefix) {
const categories = {};
for (const run of sarif.runs) {
const id = run?.automationDetails?.id;
@@ -92630,10 +92610,7 @@ function filterAlertsByDiffRange(logger, sarif) {
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
CodeQualityTarget,
CodeScanningTarget,
InvalidSarifUploadError,
SARIF_UPLOAD_ENDPOINT,
buildPayload,
findSarifFilesInDir,
getSarifFilePaths,