mirror of
https://github.com/github/codeql-action.git
synced 2026-10-03 17:41:28 +00:00
Determine CodeQL version from feature flags on GHEC-DR
This commit is contained in:
12
lib/analyze-action-post.js
generated
12
lib/analyze-action-post.js
generated
@@ -119256,7 +119256,7 @@ function parseGitHubUrl(inputUrl) {
|
||||
var CODEQL_ACTION_WARNED_ABOUT_VERSION_ENV_VAR = "CODEQL_ACTION_WARNED_ABOUT_VERSION";
|
||||
var hasBeenWarnedAboutVersion = false;
|
||||
function checkGitHubVersionInRange(version, logger) {
|
||||
if (hasBeenWarnedAboutVersion || version.type !== 1 /* GHES */) {
|
||||
if (hasBeenWarnedAboutVersion || version.type !== "GHES" /* GHES */) {
|
||||
return;
|
||||
}
|
||||
const disallowedAPIVersionReason = apiVersionInRange(
|
||||
@@ -119458,17 +119458,17 @@ function getApiClient() {
|
||||
var cachedGitHubVersion = void 0;
|
||||
async function getGitHubVersionFromApi(apiClient, apiDetails) {
|
||||
if (parseGitHubUrl(apiDetails.url) === GITHUB_DOTCOM_URL) {
|
||||
return { type: 0 /* DOTCOM */ };
|
||||
return { type: "GitHub.com" /* DOTCOM */ };
|
||||
}
|
||||
const response = await apiClient.rest.meta.get();
|
||||
if (response.headers[GITHUB_ENTERPRISE_VERSION_HEADER] === void 0) {
|
||||
return { type: 0 /* DOTCOM */ };
|
||||
return { type: "GitHub.com" /* DOTCOM */ };
|
||||
}
|
||||
if (response.headers[GITHUB_ENTERPRISE_VERSION_HEADER] === "ghe.com") {
|
||||
return { type: 2 /* GHE_DOTCOM */ };
|
||||
return { type: "GHEC-DR" /* GHE_DOTCOM */ };
|
||||
}
|
||||
const version = response.headers[GITHUB_ENTERPRISE_VERSION_HEADER];
|
||||
return { type: 1 /* GHES */, version };
|
||||
return { type: "GHES" /* GHES */, version };
|
||||
}
|
||||
async function getGitHubVersion() {
|
||||
if (cachedGitHubVersion === void 0) {
|
||||
@@ -120965,7 +120965,7 @@ async function uploadDebugArtifacts(logger, toUpload, rootDir, artifactName, ghV
|
||||
}
|
||||
}
|
||||
async function getArtifactUploaderClient(logger, ghVariant) {
|
||||
if (ghVariant === 1 /* GHES */) {
|
||||
if (ghVariant === "GHES" /* GHES */) {
|
||||
logger.info(
|
||||
"Debug artifacts can be consumed with `actions/download-artifact@v3` because the `v4` version is not yet compatible on GHES."
|
||||
);
|
||||
|
||||
33
lib/analyze-action.js
generated
33
lib/analyze-action.js
generated
@@ -87417,7 +87417,7 @@ async function checkDiskUsage(logger) {
|
||||
function checkActionVersion(version, githubVersion) {
|
||||
if (!semver.satisfies(version, ">=4") && // do not log error if the customer is already running v4
|
||||
!process.env["CODEQL_ACTION_DID_LOG_VERSION_DEPRECATION" /* LOG_VERSION_DEPRECATION */]) {
|
||||
if (githubVersion.type === 0 /* DOTCOM */ || githubVersion.type === 2 /* GHE_DOTCOM */ || githubVersion.type === 1 /* GHES */ && semver.satisfies(
|
||||
if (githubVersion.type === "GitHub.com" /* DOTCOM */ || githubVersion.type === "GHEC-DR" /* GHE_DOTCOM */ || githubVersion.type === "GHES" /* GHES */ && semver.satisfies(
|
||||
semver.coerce(githubVersion.version) ?? "0.0.0",
|
||||
">=3.20"
|
||||
)) {
|
||||
@@ -87793,17 +87793,17 @@ function getAuthorizationHeaderFor(logger, apiDetails, url2) {
|
||||
var cachedGitHubVersion = void 0;
|
||||
async function getGitHubVersionFromApi(apiClient, apiDetails) {
|
||||
if (parseGitHubUrl(apiDetails.url) === GITHUB_DOTCOM_URL) {
|
||||
return { type: 0 /* DOTCOM */ };
|
||||
return { type: "GitHub.com" /* DOTCOM */ };
|
||||
}
|
||||
const response = await apiClient.rest.meta.get();
|
||||
if (response.headers[GITHUB_ENTERPRISE_VERSION_HEADER] === void 0) {
|
||||
return { type: 0 /* DOTCOM */ };
|
||||
return { type: "GitHub.com" /* DOTCOM */ };
|
||||
}
|
||||
if (response.headers[GITHUB_ENTERPRISE_VERSION_HEADER] === "ghe.com") {
|
||||
return { type: 2 /* GHE_DOTCOM */ };
|
||||
return { type: "GHEC-DR" /* GHE_DOTCOM */ };
|
||||
}
|
||||
const version = response.headers[GITHUB_ENTERPRISE_VERSION_HEADER];
|
||||
return { type: 1 /* GHES */, version };
|
||||
return { type: "GHES" /* GHES */, version };
|
||||
}
|
||||
async function getGitHubVersion() {
|
||||
if (cachedGitHubVersion === void 0) {
|
||||
@@ -88945,15 +88945,15 @@ var GitHubFeatureFlags = class {
|
||||
return version;
|
||||
}
|
||||
async getDefaultCliVersion(variant) {
|
||||
if (variant === 0 /* DOTCOM */) {
|
||||
return await this.getDefaultDotcomCliVersion();
|
||||
if (supportsFeatureFlags(variant)) {
|
||||
return await this.getDefaultCliVersionFromFlags();
|
||||
}
|
||||
return {
|
||||
cliVersion,
|
||||
tagName: bundleVersion
|
||||
};
|
||||
}
|
||||
async getDefaultDotcomCliVersion() {
|
||||
async getDefaultCliVersionFromFlags() {
|
||||
const response = await this.getAllFeatures();
|
||||
const enabledFeatureFlagCliVersions = Object.entries(response).map(
|
||||
([f, isEnabled]) => isEnabled ? this.getCliVersionFromFeatureFlag(f) : void 0
|
||||
@@ -89042,7 +89042,7 @@ var GitHubFeatureFlags = class {
|
||||
}
|
||||
}
|
||||
async loadApiResponse() {
|
||||
if (this.gitHubVersion.type !== 0 /* DOTCOM */ && this.gitHubVersion.type !== 2 /* GHE_DOTCOM */) {
|
||||
if (!supportsFeatureFlags(this.gitHubVersion.type)) {
|
||||
this.logger.debug(
|
||||
"Not running against github.com. Disabling all toggleable features."
|
||||
);
|
||||
@@ -89095,6 +89095,9 @@ var GitHubFeatureFlags = class {
|
||||
}
|
||||
}
|
||||
};
|
||||
function supportsFeatureFlags(githubVariant) {
|
||||
return githubVariant === "GitHub.com" /* DOTCOM */ || githubVariant === "GHEC-DR" /* GHE_DOTCOM */;
|
||||
}
|
||||
|
||||
// src/diff-informed-analysis-utils.ts
|
||||
async function getDiffInformedAnalysisBranches(codeql, features, logger) {
|
||||
@@ -89102,7 +89105,7 @@ async function getDiffInformedAnalysisBranches(codeql, features, logger) {
|
||||
return void 0;
|
||||
}
|
||||
const gitHubVersion = await getGitHubVersion();
|
||||
if (gitHubVersion.type === 1 /* GHES */ && satisfiesGHESVersion(gitHubVersion.version, "<3.19", true)) {
|
||||
if (gitHubVersion.type === "GHES" /* GHES */ && satisfiesGHESVersion(gitHubVersion.version, "<3.19", true)) {
|
||||
return void 0;
|
||||
}
|
||||
const branches = getPullRequestBranches();
|
||||
@@ -90134,7 +90137,7 @@ async function getCodeQLSource(toolsInput, defaultCliVersion, apiDetails, varian
|
||||
toolsVersion: cliVersion2 ?? humanReadableVersion
|
||||
};
|
||||
}
|
||||
if (variant !== 0 /* DOTCOM */ && !forceShippedTools && !toolsInput) {
|
||||
if (variant === "GHES" /* GHES */ && !forceShippedTools && !toolsInput) {
|
||||
const result = await findOverridingToolsInCache(
|
||||
humanReadableVersion,
|
||||
logger
|
||||
@@ -91686,7 +91689,7 @@ async function cleanupAndUploadDatabases(repositoryNwo, codeql, config, apiDetai
|
||||
logger.debug("In test mode. Skipping database upload.");
|
||||
return;
|
||||
}
|
||||
if (config.gitHubVersion.type !== 0 /* DOTCOM */ && config.gitHubVersion.type !== 2 /* GHE_DOTCOM */) {
|
||||
if (config.gitHubVersion.type !== "GitHub.com" /* DOTCOM */ && config.gitHubVersion.type !== "GHEC-DR" /* GHE_DOTCOM */) {
|
||||
logger.debug("Not running against github.com or GHEC-DR. Skipping upload.");
|
||||
return;
|
||||
}
|
||||
@@ -93140,7 +93143,7 @@ function areAllRunsUnique(sarifObjects) {
|
||||
return true;
|
||||
}
|
||||
async function shouldShowCombineSarifFilesDeprecationWarning(sarifObjects, githubVersion) {
|
||||
if (githubVersion.type === 1 /* GHES */ && satisfiesGHESVersion(githubVersion.version, "<3.14", true)) {
|
||||
if (githubVersion.type === "GHES" /* GHES */ && satisfiesGHESVersion(githubVersion.version, "<3.14", true)) {
|
||||
return false;
|
||||
}
|
||||
return !areAllRunsUnique(sarifObjects) && !process.env.CODEQL_MERGE_SARIF_DEPRECATION_WARNING;
|
||||
@@ -93155,7 +93158,7 @@ async function throwIfCombineSarifFilesDisabled(sarifObjects, githubVersion) {
|
||||
);
|
||||
}
|
||||
async function shouldDisableCombineSarifFiles(sarifObjects, githubVersion) {
|
||||
if (githubVersion.type === 1 /* GHES */) {
|
||||
if (githubVersion.type === "GHES" /* GHES */) {
|
||||
if (satisfiesGHESVersion(githubVersion.version, "<3.18", true)) {
|
||||
return false;
|
||||
}
|
||||
@@ -93170,7 +93173,7 @@ async function combineSarifFilesUsingCLI(sarifFiles, gitHubVersion, features, lo
|
||||
const sarifObjects = sarifFiles.map((sarifFile) => {
|
||||
return JSON.parse(fs15.readFileSync(sarifFile, "utf8"));
|
||||
});
|
||||
const deprecationWarningMessage = gitHubVersion.type === 1 /* GHES */ ? "and will be removed in GitHub Enterprise Server 3.18" : "and will be removed in July 2025";
|
||||
const deprecationWarningMessage = gitHubVersion.type === "GHES" /* GHES */ ? "and will be removed in GitHub Enterprise Server 3.18" : "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, gitHubVersion);
|
||||
|
||||
23
lib/autobuild-action.js
generated
23
lib/autobuild-action.js
generated
@@ -83034,7 +83034,7 @@ function parseGitHubUrl(inputUrl) {
|
||||
var CODEQL_ACTION_WARNED_ABOUT_VERSION_ENV_VAR = "CODEQL_ACTION_WARNED_ABOUT_VERSION";
|
||||
var hasBeenWarnedAboutVersion = false;
|
||||
function checkGitHubVersionInRange(version, logger) {
|
||||
if (hasBeenWarnedAboutVersion || version.type !== 1 /* GHES */) {
|
||||
if (hasBeenWarnedAboutVersion || version.type !== "GHES" /* GHES */) {
|
||||
return;
|
||||
}
|
||||
const disallowedAPIVersionReason = apiVersionInRange(
|
||||
@@ -83161,7 +83161,7 @@ async function checkDiskUsage(logger) {
|
||||
function checkActionVersion(version, githubVersion) {
|
||||
if (!semver.satisfies(version, ">=4") && // do not log error if the customer is already running v4
|
||||
!process.env["CODEQL_ACTION_DID_LOG_VERSION_DEPRECATION" /* LOG_VERSION_DEPRECATION */]) {
|
||||
if (githubVersion.type === 0 /* DOTCOM */ || githubVersion.type === 2 /* GHE_DOTCOM */ || githubVersion.type === 1 /* GHES */ && semver.satisfies(
|
||||
if (githubVersion.type === "GitHub.com" /* DOTCOM */ || githubVersion.type === "GHEC-DR" /* GHE_DOTCOM */ || githubVersion.type === "GHES" /* GHES */ && semver.satisfies(
|
||||
semver.coerce(githubVersion.version) ?? "0.0.0",
|
||||
">=3.20"
|
||||
)) {
|
||||
@@ -83367,17 +83367,17 @@ function getApiClient() {
|
||||
var cachedGitHubVersion = void 0;
|
||||
async function getGitHubVersionFromApi(apiClient, apiDetails) {
|
||||
if (parseGitHubUrl(apiDetails.url) === GITHUB_DOTCOM_URL) {
|
||||
return { type: 0 /* DOTCOM */ };
|
||||
return { type: "GitHub.com" /* DOTCOM */ };
|
||||
}
|
||||
const response = await apiClient.rest.meta.get();
|
||||
if (response.headers[GITHUB_ENTERPRISE_VERSION_HEADER] === void 0) {
|
||||
return { type: 0 /* DOTCOM */ };
|
||||
return { type: "GitHub.com" /* DOTCOM */ };
|
||||
}
|
||||
if (response.headers[GITHUB_ENTERPRISE_VERSION_HEADER] === "ghe.com") {
|
||||
return { type: 2 /* GHE_DOTCOM */ };
|
||||
return { type: "GHEC-DR" /* GHE_DOTCOM */ };
|
||||
}
|
||||
const version = response.headers[GITHUB_ENTERPRISE_VERSION_HEADER];
|
||||
return { type: 1 /* GHES */, version };
|
||||
return { type: "GHES" /* GHES */, version };
|
||||
}
|
||||
async function getGitHubVersion() {
|
||||
if (cachedGitHubVersion === void 0) {
|
||||
@@ -84264,15 +84264,15 @@ var GitHubFeatureFlags = class {
|
||||
return version;
|
||||
}
|
||||
async getDefaultCliVersion(variant) {
|
||||
if (variant === 0 /* DOTCOM */) {
|
||||
return await this.getDefaultDotcomCliVersion();
|
||||
if (supportsFeatureFlags(variant)) {
|
||||
return await this.getDefaultCliVersionFromFlags();
|
||||
}
|
||||
return {
|
||||
cliVersion,
|
||||
tagName: bundleVersion
|
||||
};
|
||||
}
|
||||
async getDefaultDotcomCliVersion() {
|
||||
async getDefaultCliVersionFromFlags() {
|
||||
const response = await this.getAllFeatures();
|
||||
const enabledFeatureFlagCliVersions = Object.entries(response).map(
|
||||
([f, isEnabled]) => isEnabled ? this.getCliVersionFromFeatureFlag(f) : void 0
|
||||
@@ -84361,7 +84361,7 @@ var GitHubFeatureFlags = class {
|
||||
}
|
||||
}
|
||||
async loadApiResponse() {
|
||||
if (this.gitHubVersion.type !== 0 /* DOTCOM */ && this.gitHubVersion.type !== 2 /* GHE_DOTCOM */) {
|
||||
if (!supportsFeatureFlags(this.gitHubVersion.type)) {
|
||||
this.logger.debug(
|
||||
"Not running against github.com. Disabling all toggleable features."
|
||||
);
|
||||
@@ -84414,6 +84414,9 @@ var GitHubFeatureFlags = class {
|
||||
}
|
||||
}
|
||||
};
|
||||
function supportsFeatureFlags(githubVariant) {
|
||||
return githubVariant === "GitHub.com" /* DOTCOM */ || githubVariant === "GHEC-DR" /* GHE_DOTCOM */;
|
||||
}
|
||||
|
||||
// src/trap-caching.ts
|
||||
var actionsCache2 = __toESM(require_cache3());
|
||||
|
||||
31
lib/init-action-post.js
generated
31
lib/init-action-post.js
generated
@@ -122166,7 +122166,7 @@ function parseGitHubUrl(inputUrl) {
|
||||
var CODEQL_ACTION_WARNED_ABOUT_VERSION_ENV_VAR = "CODEQL_ACTION_WARNED_ABOUT_VERSION";
|
||||
var hasBeenWarnedAboutVersion = false;
|
||||
function checkGitHubVersionInRange(version, logger) {
|
||||
if (hasBeenWarnedAboutVersion || version.type !== 1 /* GHES */) {
|
||||
if (hasBeenWarnedAboutVersion || version.type !== "GHES" /* GHES */) {
|
||||
return;
|
||||
}
|
||||
const disallowedAPIVersionReason = apiVersionInRange(
|
||||
@@ -122668,17 +122668,17 @@ function getAuthorizationHeaderFor(logger, apiDetails, url2) {
|
||||
var cachedGitHubVersion = void 0;
|
||||
async function getGitHubVersionFromApi(apiClient, apiDetails) {
|
||||
if (parseGitHubUrl(apiDetails.url) === GITHUB_DOTCOM_URL) {
|
||||
return { type: 0 /* DOTCOM */ };
|
||||
return { type: "GitHub.com" /* DOTCOM */ };
|
||||
}
|
||||
const response = await apiClient.rest.meta.get();
|
||||
if (response.headers[GITHUB_ENTERPRISE_VERSION_HEADER] === void 0) {
|
||||
return { type: 0 /* DOTCOM */ };
|
||||
return { type: "GitHub.com" /* DOTCOM */ };
|
||||
}
|
||||
if (response.headers[GITHUB_ENTERPRISE_VERSION_HEADER] === "ghe.com") {
|
||||
return { type: 2 /* GHE_DOTCOM */ };
|
||||
return { type: "GHEC-DR" /* GHE_DOTCOM */ };
|
||||
}
|
||||
const version = response.headers[GITHUB_ENTERPRISE_VERSION_HEADER];
|
||||
return { type: 1 /* GHES */, version };
|
||||
return { type: "GHES" /* GHES */, version };
|
||||
}
|
||||
async function getGitHubVersion() {
|
||||
if (cachedGitHubVersion === void 0) {
|
||||
@@ -123705,15 +123705,15 @@ var GitHubFeatureFlags = class {
|
||||
return version;
|
||||
}
|
||||
async getDefaultCliVersion(variant) {
|
||||
if (variant === 0 /* DOTCOM */) {
|
||||
return await this.getDefaultDotcomCliVersion();
|
||||
if (supportsFeatureFlags(variant)) {
|
||||
return await this.getDefaultCliVersionFromFlags();
|
||||
}
|
||||
return {
|
||||
cliVersion,
|
||||
tagName: bundleVersion
|
||||
};
|
||||
}
|
||||
async getDefaultDotcomCliVersion() {
|
||||
async getDefaultCliVersionFromFlags() {
|
||||
const response = await this.getAllFeatures();
|
||||
const enabledFeatureFlagCliVersions = Object.entries(response).map(
|
||||
([f, isEnabled]) => isEnabled ? this.getCliVersionFromFeatureFlag(f) : void 0
|
||||
@@ -123802,7 +123802,7 @@ var GitHubFeatureFlags = class {
|
||||
}
|
||||
}
|
||||
async loadApiResponse() {
|
||||
if (this.gitHubVersion.type !== 0 /* DOTCOM */ && this.gitHubVersion.type !== 2 /* GHE_DOTCOM */) {
|
||||
if (!supportsFeatureFlags(this.gitHubVersion.type)) {
|
||||
this.logger.debug(
|
||||
"Not running against github.com. Disabling all toggleable features."
|
||||
);
|
||||
@@ -123855,6 +123855,9 @@ var GitHubFeatureFlags = class {
|
||||
}
|
||||
}
|
||||
};
|
||||
function supportsFeatureFlags(githubVariant) {
|
||||
return githubVariant === "GitHub.com" /* DOTCOM */ || githubVariant === "GHEC-DR" /* GHE_DOTCOM */;
|
||||
}
|
||||
|
||||
// src/diff-informed-analysis-utils.ts
|
||||
function getDiffRangesJsonFilePath() {
|
||||
@@ -124630,7 +124633,7 @@ async function getCodeQLSource(toolsInput, defaultCliVersion, apiDetails, varian
|
||||
toolsVersion: cliVersion2 ?? humanReadableVersion
|
||||
};
|
||||
}
|
||||
if (variant !== 0 /* DOTCOM */ && !forceShippedTools && !toolsInput) {
|
||||
if (variant === "GHES" /* GHES */ && !forceShippedTools && !toolsInput) {
|
||||
const result = await findOverridingToolsInCache(
|
||||
humanReadableVersion,
|
||||
logger
|
||||
@@ -125688,7 +125691,7 @@ async function uploadDebugArtifacts(logger, toUpload, rootDir, artifactName, ghV
|
||||
}
|
||||
}
|
||||
async function getArtifactUploaderClient(logger, ghVariant) {
|
||||
if (ghVariant === 1 /* GHES */) {
|
||||
if (ghVariant === "GHES" /* GHES */) {
|
||||
logger.info(
|
||||
"Debug artifacts can be consumed with `actions/download-artifact@v3` because the `v4` version is not yet compatible on GHES."
|
||||
);
|
||||
@@ -127162,7 +127165,7 @@ function areAllRunsUnique(sarifObjects) {
|
||||
return true;
|
||||
}
|
||||
async function shouldShowCombineSarifFilesDeprecationWarning(sarifObjects, githubVersion) {
|
||||
if (githubVersion.type === 1 /* GHES */ && satisfiesGHESVersion(githubVersion.version, "<3.14", true)) {
|
||||
if (githubVersion.type === "GHES" /* GHES */ && satisfiesGHESVersion(githubVersion.version, "<3.14", true)) {
|
||||
return false;
|
||||
}
|
||||
return !areAllRunsUnique(sarifObjects) && !process.env.CODEQL_MERGE_SARIF_DEPRECATION_WARNING;
|
||||
@@ -127177,7 +127180,7 @@ async function throwIfCombineSarifFilesDisabled(sarifObjects, githubVersion) {
|
||||
);
|
||||
}
|
||||
async function shouldDisableCombineSarifFiles(sarifObjects, githubVersion) {
|
||||
if (githubVersion.type === 1 /* GHES */) {
|
||||
if (githubVersion.type === "GHES" /* GHES */) {
|
||||
if (satisfiesGHESVersion(githubVersion.version, "<3.18", true)) {
|
||||
return false;
|
||||
}
|
||||
@@ -127192,7 +127195,7 @@ async function combineSarifFilesUsingCLI(sarifFiles, gitHubVersion, features, lo
|
||||
const sarifObjects = sarifFiles.map((sarifFile) => {
|
||||
return JSON.parse(fs14.readFileSync(sarifFile, "utf8"));
|
||||
});
|
||||
const deprecationWarningMessage = gitHubVersion.type === 1 /* GHES */ ? "and will be removed in GitHub Enterprise Server 3.18" : "and will be removed in July 2025";
|
||||
const deprecationWarningMessage = gitHubVersion.type === "GHES" /* GHES */ ? "and will be removed in GitHub Enterprise Server 3.18" : "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, gitHubVersion);
|
||||
|
||||
29
lib/init-action.js
generated
29
lib/init-action.js
generated
@@ -84534,7 +84534,7 @@ function parseGitHubUrl(inputUrl) {
|
||||
var CODEQL_ACTION_WARNED_ABOUT_VERSION_ENV_VAR = "CODEQL_ACTION_WARNED_ABOUT_VERSION";
|
||||
var hasBeenWarnedAboutVersion = false;
|
||||
function checkGitHubVersionInRange(version, logger) {
|
||||
if (hasBeenWarnedAboutVersion || version.type !== 1 /* GHES */) {
|
||||
if (hasBeenWarnedAboutVersion || version.type !== "GHES" /* GHES */) {
|
||||
return;
|
||||
}
|
||||
const disallowedAPIVersionReason = apiVersionInRange(
|
||||
@@ -84738,7 +84738,7 @@ async function checkDiskUsage(logger) {
|
||||
function checkActionVersion(version, githubVersion) {
|
||||
if (!semver.satisfies(version, ">=4") && // do not log error if the customer is already running v4
|
||||
!process.env["CODEQL_ACTION_DID_LOG_VERSION_DEPRECATION" /* LOG_VERSION_DEPRECATION */]) {
|
||||
if (githubVersion.type === 0 /* DOTCOM */ || githubVersion.type === 2 /* GHE_DOTCOM */ || githubVersion.type === 1 /* GHES */ && semver.satisfies(
|
||||
if (githubVersion.type === "GitHub.com" /* DOTCOM */ || githubVersion.type === "GHEC-DR" /* GHE_DOTCOM */ || githubVersion.type === "GHES" /* GHES */ && semver.satisfies(
|
||||
semver.coerce(githubVersion.version) ?? "0.0.0",
|
||||
">=3.20"
|
||||
)) {
|
||||
@@ -85118,17 +85118,17 @@ function getAuthorizationHeaderFor(logger, apiDetails, url) {
|
||||
var cachedGitHubVersion = void 0;
|
||||
async function getGitHubVersionFromApi(apiClient, apiDetails) {
|
||||
if (parseGitHubUrl(apiDetails.url) === GITHUB_DOTCOM_URL) {
|
||||
return { type: 0 /* DOTCOM */ };
|
||||
return { type: "GitHub.com" /* DOTCOM */ };
|
||||
}
|
||||
const response = await apiClient.rest.meta.get();
|
||||
if (response.headers[GITHUB_ENTERPRISE_VERSION_HEADER] === void 0) {
|
||||
return { type: 0 /* DOTCOM */ };
|
||||
return { type: "GitHub.com" /* DOTCOM */ };
|
||||
}
|
||||
if (response.headers[GITHUB_ENTERPRISE_VERSION_HEADER] === "ghe.com") {
|
||||
return { type: 2 /* GHE_DOTCOM */ };
|
||||
return { type: "GHEC-DR" /* GHE_DOTCOM */ };
|
||||
}
|
||||
const version = response.headers[GITHUB_ENTERPRISE_VERSION_HEADER];
|
||||
return { type: 1 /* GHES */, version };
|
||||
return { type: "GHES" /* GHES */, version };
|
||||
}
|
||||
async function getGitHubVersion() {
|
||||
if (cachedGitHubVersion === void 0) {
|
||||
@@ -85350,7 +85350,7 @@ var RepositoryPropertyName = /* @__PURE__ */ ((RepositoryPropertyName2) => {
|
||||
return RepositoryPropertyName2;
|
||||
})(RepositoryPropertyName || {});
|
||||
async function loadPropertiesFromApi(gitHubVersion, logger, repositoryNwo) {
|
||||
if (gitHubVersion.type === 1 /* GHES */) {
|
||||
if (gitHubVersion.type === "GHES" /* GHES */) {
|
||||
return {};
|
||||
}
|
||||
try {
|
||||
@@ -86359,15 +86359,15 @@ var GitHubFeatureFlags = class {
|
||||
return version;
|
||||
}
|
||||
async getDefaultCliVersion(variant) {
|
||||
if (variant === 0 /* DOTCOM */) {
|
||||
return await this.getDefaultDotcomCliVersion();
|
||||
if (supportsFeatureFlags(variant)) {
|
||||
return await this.getDefaultCliVersionFromFlags();
|
||||
}
|
||||
return {
|
||||
cliVersion,
|
||||
tagName: bundleVersion
|
||||
};
|
||||
}
|
||||
async getDefaultDotcomCliVersion() {
|
||||
async getDefaultCliVersionFromFlags() {
|
||||
const response = await this.getAllFeatures();
|
||||
const enabledFeatureFlagCliVersions = Object.entries(response).map(
|
||||
([f, isEnabled]) => isEnabled ? this.getCliVersionFromFeatureFlag(f) : void 0
|
||||
@@ -86456,7 +86456,7 @@ var GitHubFeatureFlags = class {
|
||||
}
|
||||
}
|
||||
async loadApiResponse() {
|
||||
if (this.gitHubVersion.type !== 0 /* DOTCOM */ && this.gitHubVersion.type !== 2 /* GHE_DOTCOM */) {
|
||||
if (!supportsFeatureFlags(this.gitHubVersion.type)) {
|
||||
this.logger.debug(
|
||||
"Not running against github.com. Disabling all toggleable features."
|
||||
);
|
||||
@@ -86509,6 +86509,9 @@ var GitHubFeatureFlags = class {
|
||||
}
|
||||
}
|
||||
};
|
||||
function supportsFeatureFlags(githubVariant) {
|
||||
return githubVariant === "GitHub.com" /* DOTCOM */ || githubVariant === "GHEC-DR" /* GHE_DOTCOM */;
|
||||
}
|
||||
|
||||
// src/diff-informed-analysis-utils.ts
|
||||
async function shouldPerformDiffInformedAnalysis(codeql, features, logger) {
|
||||
@@ -86519,7 +86522,7 @@ async function getDiffInformedAnalysisBranches(codeql, features, logger) {
|
||||
return void 0;
|
||||
}
|
||||
const gitHubVersion = await getGitHubVersion();
|
||||
if (gitHubVersion.type === 1 /* GHES */ && satisfiesGHESVersion(gitHubVersion.version, "<3.19", true)) {
|
||||
if (gitHubVersion.type === "GHES" /* GHES */ && satisfiesGHESVersion(gitHubVersion.version, "<3.19", true)) {
|
||||
return void 0;
|
||||
}
|
||||
const branches = getPullRequestBranches();
|
||||
@@ -88382,7 +88385,7 @@ async function getCodeQLSource(toolsInput, defaultCliVersion, apiDetails, varian
|
||||
toolsVersion: cliVersion2 ?? humanReadableVersion
|
||||
};
|
||||
}
|
||||
if (variant !== 0 /* DOTCOM */ && !forceShippedTools && !toolsInput) {
|
||||
if (variant === "GHES" /* GHES */ && !forceShippedTools && !toolsInput) {
|
||||
const result = await findOverridingToolsInCache(
|
||||
humanReadableVersion,
|
||||
logger
|
||||
|
||||
12
lib/resolve-environment-action.js
generated
12
lib/resolve-environment-action.js
generated
@@ -83034,7 +83034,7 @@ function parseGitHubUrl(inputUrl) {
|
||||
var CODEQL_ACTION_WARNED_ABOUT_VERSION_ENV_VAR = "CODEQL_ACTION_WARNED_ABOUT_VERSION";
|
||||
var hasBeenWarnedAboutVersion = false;
|
||||
function checkGitHubVersionInRange(version, logger) {
|
||||
if (hasBeenWarnedAboutVersion || version.type !== 1 /* GHES */) {
|
||||
if (hasBeenWarnedAboutVersion || version.type !== "GHES" /* GHES */) {
|
||||
return;
|
||||
}
|
||||
const disallowedAPIVersionReason = apiVersionInRange(
|
||||
@@ -83173,7 +83173,7 @@ async function checkDiskUsage(logger) {
|
||||
function checkActionVersion(version, githubVersion) {
|
||||
if (!semver.satisfies(version, ">=4") && // do not log error if the customer is already running v4
|
||||
!process.env["CODEQL_ACTION_DID_LOG_VERSION_DEPRECATION" /* LOG_VERSION_DEPRECATION */]) {
|
||||
if (githubVersion.type === 0 /* DOTCOM */ || githubVersion.type === 2 /* GHE_DOTCOM */ || githubVersion.type === 1 /* GHES */ && semver.satisfies(
|
||||
if (githubVersion.type === "GitHub.com" /* DOTCOM */ || githubVersion.type === "GHEC-DR" /* GHE_DOTCOM */ || githubVersion.type === "GHES" /* GHES */ && semver.satisfies(
|
||||
semver.coerce(githubVersion.version) ?? "0.0.0",
|
||||
">=3.20"
|
||||
)) {
|
||||
@@ -83375,17 +83375,17 @@ function getApiClient() {
|
||||
var cachedGitHubVersion = void 0;
|
||||
async function getGitHubVersionFromApi(apiClient, apiDetails) {
|
||||
if (parseGitHubUrl(apiDetails.url) === GITHUB_DOTCOM_URL) {
|
||||
return { type: 0 /* DOTCOM */ };
|
||||
return { type: "GitHub.com" /* DOTCOM */ };
|
||||
}
|
||||
const response = await apiClient.rest.meta.get();
|
||||
if (response.headers[GITHUB_ENTERPRISE_VERSION_HEADER] === void 0) {
|
||||
return { type: 0 /* DOTCOM */ };
|
||||
return { type: "GitHub.com" /* DOTCOM */ };
|
||||
}
|
||||
if (response.headers[GITHUB_ENTERPRISE_VERSION_HEADER] === "ghe.com") {
|
||||
return { type: 2 /* GHE_DOTCOM */ };
|
||||
return { type: "GHEC-DR" /* GHE_DOTCOM */ };
|
||||
}
|
||||
const version = response.headers[GITHUB_ENTERPRISE_VERSION_HEADER];
|
||||
return { type: 1 /* GHES */, version };
|
||||
return { type: "GHES" /* GHES */, version };
|
||||
}
|
||||
async function getGitHubVersion() {
|
||||
if (cachedGitHubVersion === void 0) {
|
||||
|
||||
25
lib/setup-codeql-action.js
generated
25
lib/setup-codeql-action.js
generated
@@ -83091,7 +83091,7 @@ function parseGitHubUrl(inputUrl) {
|
||||
var CODEQL_ACTION_WARNED_ABOUT_VERSION_ENV_VAR = "CODEQL_ACTION_WARNED_ABOUT_VERSION";
|
||||
var hasBeenWarnedAboutVersion = false;
|
||||
function checkGitHubVersionInRange(version, logger) {
|
||||
if (hasBeenWarnedAboutVersion || version.type !== 1 /* GHES */) {
|
||||
if (hasBeenWarnedAboutVersion || version.type !== "GHES" /* GHES */) {
|
||||
return;
|
||||
}
|
||||
const disallowedAPIVersionReason = apiVersionInRange(
|
||||
@@ -83249,7 +83249,7 @@ async function checkDiskUsage(logger) {
|
||||
function checkActionVersion(version, githubVersion) {
|
||||
if (!semver.satisfies(version, ">=4") && // do not log error if the customer is already running v4
|
||||
!process.env["CODEQL_ACTION_DID_LOG_VERSION_DEPRECATION" /* LOG_VERSION_DEPRECATION */]) {
|
||||
if (githubVersion.type === 0 /* DOTCOM */ || githubVersion.type === 2 /* GHE_DOTCOM */ || githubVersion.type === 1 /* GHES */ && semver.satisfies(
|
||||
if (githubVersion.type === "GitHub.com" /* DOTCOM */ || githubVersion.type === "GHEC-DR" /* GHE_DOTCOM */ || githubVersion.type === "GHES" /* GHES */ && semver.satisfies(
|
||||
semver.coerce(githubVersion.version) ?? "0.0.0",
|
||||
">=3.20"
|
||||
)) {
|
||||
@@ -83492,17 +83492,17 @@ function getAuthorizationHeaderFor(logger, apiDetails, url) {
|
||||
var cachedGitHubVersion = void 0;
|
||||
async function getGitHubVersionFromApi(apiClient, apiDetails) {
|
||||
if (parseGitHubUrl(apiDetails.url) === GITHUB_DOTCOM_URL) {
|
||||
return { type: 0 /* DOTCOM */ };
|
||||
return { type: "GitHub.com" /* DOTCOM */ };
|
||||
}
|
||||
const response = await apiClient.rest.meta.get();
|
||||
if (response.headers[GITHUB_ENTERPRISE_VERSION_HEADER] === void 0) {
|
||||
return { type: 0 /* DOTCOM */ };
|
||||
return { type: "GitHub.com" /* DOTCOM */ };
|
||||
}
|
||||
if (response.headers[GITHUB_ENTERPRISE_VERSION_HEADER] === "ghe.com") {
|
||||
return { type: 2 /* GHE_DOTCOM */ };
|
||||
return { type: "GHEC-DR" /* GHE_DOTCOM */ };
|
||||
}
|
||||
const version = response.headers[GITHUB_ENTERPRISE_VERSION_HEADER];
|
||||
return { type: 1 /* GHES */, version };
|
||||
return { type: "GHES" /* GHES */, version };
|
||||
}
|
||||
async function getGitHubVersion() {
|
||||
if (cachedGitHubVersion === void 0) {
|
||||
@@ -84167,15 +84167,15 @@ var GitHubFeatureFlags = class {
|
||||
return version;
|
||||
}
|
||||
async getDefaultCliVersion(variant) {
|
||||
if (variant === 0 /* DOTCOM */) {
|
||||
return await this.getDefaultDotcomCliVersion();
|
||||
if (supportsFeatureFlags(variant)) {
|
||||
return await this.getDefaultCliVersionFromFlags();
|
||||
}
|
||||
return {
|
||||
cliVersion,
|
||||
tagName: bundleVersion
|
||||
};
|
||||
}
|
||||
async getDefaultDotcomCliVersion() {
|
||||
async getDefaultCliVersionFromFlags() {
|
||||
const response = await this.getAllFeatures();
|
||||
const enabledFeatureFlagCliVersions = Object.entries(response).map(
|
||||
([f, isEnabled]) => isEnabled ? this.getCliVersionFromFeatureFlag(f) : void 0
|
||||
@@ -84264,7 +84264,7 @@ var GitHubFeatureFlags = class {
|
||||
}
|
||||
}
|
||||
async loadApiResponse() {
|
||||
if (this.gitHubVersion.type !== 0 /* DOTCOM */ && this.gitHubVersion.type !== 2 /* GHE_DOTCOM */) {
|
||||
if (!supportsFeatureFlags(this.gitHubVersion.type)) {
|
||||
this.logger.debug(
|
||||
"Not running against github.com. Disabling all toggleable features."
|
||||
);
|
||||
@@ -84317,6 +84317,9 @@ var GitHubFeatureFlags = class {
|
||||
}
|
||||
}
|
||||
};
|
||||
function supportsFeatureFlags(githubVariant) {
|
||||
return githubVariant === "GitHub.com" /* DOTCOM */ || githubVariant === "GHEC-DR" /* GHE_DOTCOM */;
|
||||
}
|
||||
|
||||
// src/init.ts
|
||||
var toolrunner4 = __toESM(require_toolrunner());
|
||||
@@ -85261,7 +85264,7 @@ async function getCodeQLSource(toolsInput, defaultCliVersion, apiDetails, varian
|
||||
toolsVersion: cliVersion2 ?? humanReadableVersion
|
||||
};
|
||||
}
|
||||
if (variant !== 0 /* DOTCOM */ && !forceShippedTools && !toolsInput) {
|
||||
if (variant === "GHES" /* GHES */ && !forceShippedTools && !toolsInput) {
|
||||
const result = await findOverridingToolsInCache(
|
||||
humanReadableVersion,
|
||||
logger
|
||||
|
||||
12
lib/start-proxy-action-post.js
generated
12
lib/start-proxy-action-post.js
generated
@@ -119235,7 +119235,7 @@ function parseGitHubUrl(inputUrl) {
|
||||
var CODEQL_ACTION_WARNED_ABOUT_VERSION_ENV_VAR = "CODEQL_ACTION_WARNED_ABOUT_VERSION";
|
||||
var hasBeenWarnedAboutVersion = false;
|
||||
function checkGitHubVersionInRange(version, logger) {
|
||||
if (hasBeenWarnedAboutVersion || version.type !== 1 /* GHES */) {
|
||||
if (hasBeenWarnedAboutVersion || version.type !== "GHES" /* GHES */) {
|
||||
return;
|
||||
}
|
||||
const disallowedAPIVersionReason = apiVersionInRange(
|
||||
@@ -119341,17 +119341,17 @@ function getApiClient() {
|
||||
var cachedGitHubVersion = void 0;
|
||||
async function getGitHubVersionFromApi(apiClient, apiDetails) {
|
||||
if (parseGitHubUrl(apiDetails.url) === GITHUB_DOTCOM_URL) {
|
||||
return { type: 0 /* DOTCOM */ };
|
||||
return { type: "GitHub.com" /* DOTCOM */ };
|
||||
}
|
||||
const response = await apiClient.rest.meta.get();
|
||||
if (response.headers[GITHUB_ENTERPRISE_VERSION_HEADER] === void 0) {
|
||||
return { type: 0 /* DOTCOM */ };
|
||||
return { type: "GitHub.com" /* DOTCOM */ };
|
||||
}
|
||||
if (response.headers[GITHUB_ENTERPRISE_VERSION_HEADER] === "ghe.com") {
|
||||
return { type: 2 /* GHE_DOTCOM */ };
|
||||
return { type: "GHEC-DR" /* GHE_DOTCOM */ };
|
||||
}
|
||||
const version = response.headers[GITHUB_ENTERPRISE_VERSION_HEADER];
|
||||
return { type: 1 /* GHES */, version };
|
||||
return { type: "GHES" /* GHES */, version };
|
||||
}
|
||||
async function getGitHubVersion() {
|
||||
if (cachedGitHubVersion === void 0) {
|
||||
@@ -119848,7 +119848,7 @@ var glob = __toESM(require_glob3());
|
||||
|
||||
// src/debug-artifacts.ts
|
||||
async function getArtifactUploaderClient(logger, ghVariant) {
|
||||
if (ghVariant === 1 /* GHES */) {
|
||||
if (ghVariant === "GHES" /* GHES */) {
|
||||
logger.info(
|
||||
"Debug artifacts can be consumed with `actions/download-artifact@v3` because the `v4` version is not yet compatible on GHES."
|
||||
);
|
||||
|
||||
16
lib/upload-lib.js
generated
16
lib/upload-lib.js
generated
@@ -86348,17 +86348,17 @@ function getAuthorizationHeaderFor(logger, apiDetails, url2) {
|
||||
var cachedGitHubVersion = void 0;
|
||||
async function getGitHubVersionFromApi(apiClient, apiDetails) {
|
||||
if (parseGitHubUrl(apiDetails.url) === GITHUB_DOTCOM_URL) {
|
||||
return { type: 0 /* DOTCOM */ };
|
||||
return { type: "GitHub.com" /* DOTCOM */ };
|
||||
}
|
||||
const response = await apiClient.rest.meta.get();
|
||||
if (response.headers[GITHUB_ENTERPRISE_VERSION_HEADER] === void 0) {
|
||||
return { type: 0 /* DOTCOM */ };
|
||||
return { type: "GitHub.com" /* DOTCOM */ };
|
||||
}
|
||||
if (response.headers[GITHUB_ENTERPRISE_VERSION_HEADER] === "ghe.com") {
|
||||
return { type: 2 /* GHE_DOTCOM */ };
|
||||
return { type: "GHEC-DR" /* GHE_DOTCOM */ };
|
||||
}
|
||||
const version = response.headers[GITHUB_ENTERPRISE_VERSION_HEADER];
|
||||
return { type: 1 /* GHES */, version };
|
||||
return { type: "GHES" /* GHES */, version };
|
||||
}
|
||||
async function getGitHubVersion() {
|
||||
if (cachedGitHubVersion === void 0) {
|
||||
@@ -87977,7 +87977,7 @@ async function getCodeQLSource(toolsInput, defaultCliVersion, apiDetails, varian
|
||||
toolsVersion: cliVersion2 ?? humanReadableVersion
|
||||
};
|
||||
}
|
||||
if (variant !== 0 /* DOTCOM */ && !forceShippedTools && !toolsInput) {
|
||||
if (variant === "GHES" /* GHES */ && !forceShippedTools && !toolsInput) {
|
||||
const result = await findOverridingToolsInCache(
|
||||
humanReadableVersion,
|
||||
logger
|
||||
@@ -90031,7 +90031,7 @@ function areAllRunsUnique(sarifObjects) {
|
||||
return true;
|
||||
}
|
||||
async function shouldShowCombineSarifFilesDeprecationWarning(sarifObjects, githubVersion) {
|
||||
if (githubVersion.type === 1 /* GHES */ && satisfiesGHESVersion(githubVersion.version, "<3.14", true)) {
|
||||
if (githubVersion.type === "GHES" /* GHES */ && satisfiesGHESVersion(githubVersion.version, "<3.14", true)) {
|
||||
return false;
|
||||
}
|
||||
return !areAllRunsUnique(sarifObjects) && !process.env.CODEQL_MERGE_SARIF_DEPRECATION_WARNING;
|
||||
@@ -90046,7 +90046,7 @@ async function throwIfCombineSarifFilesDisabled(sarifObjects, githubVersion) {
|
||||
);
|
||||
}
|
||||
async function shouldDisableCombineSarifFiles(sarifObjects, githubVersion) {
|
||||
if (githubVersion.type === 1 /* GHES */) {
|
||||
if (githubVersion.type === "GHES" /* GHES */) {
|
||||
if (satisfiesGHESVersion(githubVersion.version, "<3.18", true)) {
|
||||
return false;
|
||||
}
|
||||
@@ -90061,7 +90061,7 @@ async function combineSarifFilesUsingCLI(sarifFiles, gitHubVersion, features, lo
|
||||
const sarifObjects = sarifFiles.map((sarifFile) => {
|
||||
return JSON.parse(fs11.readFileSync(sarifFile, "utf8"));
|
||||
});
|
||||
const deprecationWarningMessage = gitHubVersion.type === 1 /* GHES */ ? "and will be removed in GitHub Enterprise Server 3.18" : "and will be removed in July 2025";
|
||||
const deprecationWarningMessage = gitHubVersion.type === "GHES" /* GHES */ ? "and will be removed in GitHub Enterprise Server 3.18" : "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, gitHubVersion);
|
||||
|
||||
12
lib/upload-sarif-action-post.js
generated
12
lib/upload-sarif-action-post.js
generated
@@ -119235,7 +119235,7 @@ function parseGitHubUrl(inputUrl) {
|
||||
var CODEQL_ACTION_WARNED_ABOUT_VERSION_ENV_VAR = "CODEQL_ACTION_WARNED_ABOUT_VERSION";
|
||||
var hasBeenWarnedAboutVersion = false;
|
||||
function checkGitHubVersionInRange(version, logger) {
|
||||
if (hasBeenWarnedAboutVersion || version.type !== 1 /* GHES */) {
|
||||
if (hasBeenWarnedAboutVersion || version.type !== "GHES" /* GHES */) {
|
||||
return;
|
||||
}
|
||||
const disallowedAPIVersionReason = apiVersionInRange(
|
||||
@@ -119345,17 +119345,17 @@ function getApiClient() {
|
||||
var cachedGitHubVersion = void 0;
|
||||
async function getGitHubVersionFromApi(apiClient, apiDetails) {
|
||||
if (parseGitHubUrl(apiDetails.url) === GITHUB_DOTCOM_URL) {
|
||||
return { type: 0 /* DOTCOM */ };
|
||||
return { type: "GitHub.com" /* DOTCOM */ };
|
||||
}
|
||||
const response = await apiClient.rest.meta.get();
|
||||
if (response.headers[GITHUB_ENTERPRISE_VERSION_HEADER] === void 0) {
|
||||
return { type: 0 /* DOTCOM */ };
|
||||
return { type: "GitHub.com" /* DOTCOM */ };
|
||||
}
|
||||
if (response.headers[GITHUB_ENTERPRISE_VERSION_HEADER] === "ghe.com") {
|
||||
return { type: 2 /* GHE_DOTCOM */ };
|
||||
return { type: "GHEC-DR" /* GHE_DOTCOM */ };
|
||||
}
|
||||
const version = response.headers[GITHUB_ENTERPRISE_VERSION_HEADER];
|
||||
return { type: 1 /* GHES */, version };
|
||||
return { type: "GHES" /* GHES */, version };
|
||||
}
|
||||
async function getGitHubVersion() {
|
||||
if (cachedGitHubVersion === void 0) {
|
||||
@@ -119920,7 +119920,7 @@ async function uploadDebugArtifacts(logger, toUpload, rootDir, artifactName, ghV
|
||||
}
|
||||
}
|
||||
async function getArtifactUploaderClient(logger, ghVariant) {
|
||||
if (ghVariant === 1 /* GHES */) {
|
||||
if (ghVariant === "GHES" /* GHES */) {
|
||||
logger.info(
|
||||
"Debug artifacts can be consumed with `actions/download-artifact@v3` because the `v4` version is not yet compatible on GHES."
|
||||
);
|
||||
|
||||
29
lib/upload-sarif-action.js
generated
29
lib/upload-sarif-action.js
generated
@@ -86069,7 +86069,7 @@ async function checkDiskUsage(logger) {
|
||||
function checkActionVersion(version, githubVersion) {
|
||||
if (!semver.satisfies(version, ">=4") && // do not log error if the customer is already running v4
|
||||
!process.env["CODEQL_ACTION_DID_LOG_VERSION_DEPRECATION" /* LOG_VERSION_DEPRECATION */]) {
|
||||
if (githubVersion.type === 0 /* DOTCOM */ || githubVersion.type === 2 /* GHE_DOTCOM */ || githubVersion.type === 1 /* GHES */ && semver.satisfies(
|
||||
if (githubVersion.type === "GitHub.com" /* DOTCOM */ || githubVersion.type === "GHEC-DR" /* GHE_DOTCOM */ || githubVersion.type === "GHES" /* GHES */ && semver.satisfies(
|
||||
semver.coerce(githubVersion.version) ?? "0.0.0",
|
||||
">=3.20"
|
||||
)) {
|
||||
@@ -86394,17 +86394,17 @@ function getAuthorizationHeaderFor(logger, apiDetails, url2) {
|
||||
var cachedGitHubVersion = void 0;
|
||||
async function getGitHubVersionFromApi(apiClient, apiDetails) {
|
||||
if (parseGitHubUrl(apiDetails.url) === GITHUB_DOTCOM_URL) {
|
||||
return { type: 0 /* DOTCOM */ };
|
||||
return { type: "GitHub.com" /* DOTCOM */ };
|
||||
}
|
||||
const response = await apiClient.rest.meta.get();
|
||||
if (response.headers[GITHUB_ENTERPRISE_VERSION_HEADER] === void 0) {
|
||||
return { type: 0 /* DOTCOM */ };
|
||||
return { type: "GitHub.com" /* DOTCOM */ };
|
||||
}
|
||||
if (response.headers[GITHUB_ENTERPRISE_VERSION_HEADER] === "ghe.com") {
|
||||
return { type: 2 /* GHE_DOTCOM */ };
|
||||
return { type: "GHEC-DR" /* GHE_DOTCOM */ };
|
||||
}
|
||||
const version = response.headers[GITHUB_ENTERPRISE_VERSION_HEADER];
|
||||
return { type: 1 /* GHES */, version };
|
||||
return { type: "GHES" /* GHES */, version };
|
||||
}
|
||||
async function getGitHubVersion() {
|
||||
if (cachedGitHubVersion === void 0) {
|
||||
@@ -87117,15 +87117,15 @@ var GitHubFeatureFlags = class {
|
||||
return version;
|
||||
}
|
||||
async getDefaultCliVersion(variant) {
|
||||
if (variant === 0 /* DOTCOM */) {
|
||||
return await this.getDefaultDotcomCliVersion();
|
||||
if (supportsFeatureFlags(variant)) {
|
||||
return await this.getDefaultCliVersionFromFlags();
|
||||
}
|
||||
return {
|
||||
cliVersion,
|
||||
tagName: bundleVersion
|
||||
};
|
||||
}
|
||||
async getDefaultDotcomCliVersion() {
|
||||
async getDefaultCliVersionFromFlags() {
|
||||
const response = await this.getAllFeatures();
|
||||
const enabledFeatureFlagCliVersions = Object.entries(response).map(
|
||||
([f, isEnabled]) => isEnabled ? this.getCliVersionFromFeatureFlag(f) : void 0
|
||||
@@ -87214,7 +87214,7 @@ var GitHubFeatureFlags = class {
|
||||
}
|
||||
}
|
||||
async loadApiResponse() {
|
||||
if (this.gitHubVersion.type !== 0 /* DOTCOM */ && this.gitHubVersion.type !== 2 /* GHE_DOTCOM */) {
|
||||
if (!supportsFeatureFlags(this.gitHubVersion.type)) {
|
||||
this.logger.debug(
|
||||
"Not running against github.com. Disabling all toggleable features."
|
||||
);
|
||||
@@ -87267,6 +87267,9 @@ var GitHubFeatureFlags = class {
|
||||
}
|
||||
}
|
||||
};
|
||||
function supportsFeatureFlags(githubVariant) {
|
||||
return githubVariant === "GitHub.com" /* DOTCOM */ || githubVariant === "GHEC-DR" /* GHE_DOTCOM */;
|
||||
}
|
||||
|
||||
// src/status-report.ts
|
||||
var os = __toESM(require("os"));
|
||||
@@ -88495,7 +88498,7 @@ async function getCodeQLSource(toolsInput, defaultCliVersion, apiDetails, varian
|
||||
toolsVersion: cliVersion2 ?? humanReadableVersion
|
||||
};
|
||||
}
|
||||
if (variant !== 0 /* DOTCOM */ && !forceShippedTools && !toolsInput) {
|
||||
if (variant === "GHES" /* GHES */ && !forceShippedTools && !toolsInput) {
|
||||
const result = await findOverridingToolsInCache(
|
||||
humanReadableVersion,
|
||||
logger
|
||||
@@ -90549,7 +90552,7 @@ function areAllRunsUnique(sarifObjects) {
|
||||
return true;
|
||||
}
|
||||
async function shouldShowCombineSarifFilesDeprecationWarning(sarifObjects, githubVersion) {
|
||||
if (githubVersion.type === 1 /* GHES */ && satisfiesGHESVersion(githubVersion.version, "<3.14", true)) {
|
||||
if (githubVersion.type === "GHES" /* GHES */ && satisfiesGHESVersion(githubVersion.version, "<3.14", true)) {
|
||||
return false;
|
||||
}
|
||||
return !areAllRunsUnique(sarifObjects) && !process.env.CODEQL_MERGE_SARIF_DEPRECATION_WARNING;
|
||||
@@ -90564,7 +90567,7 @@ async function throwIfCombineSarifFilesDisabled(sarifObjects, githubVersion) {
|
||||
);
|
||||
}
|
||||
async function shouldDisableCombineSarifFiles(sarifObjects, githubVersion) {
|
||||
if (githubVersion.type === 1 /* GHES */) {
|
||||
if (githubVersion.type === "GHES" /* GHES */) {
|
||||
if (satisfiesGHESVersion(githubVersion.version, "<3.18", true)) {
|
||||
return false;
|
||||
}
|
||||
@@ -90579,7 +90582,7 @@ async function combineSarifFilesUsingCLI(sarifFiles, gitHubVersion, features, lo
|
||||
const sarifObjects = sarifFiles.map((sarifFile) => {
|
||||
return JSON.parse(fs12.readFileSync(sarifFile, "utf8"));
|
||||
});
|
||||
const deprecationWarningMessage = gitHubVersion.type === 1 /* GHES */ ? "and will be removed in GitHub Enterprise Server 3.18" : "and will be removed in July 2025";
|
||||
const deprecationWarningMessage = gitHubVersion.type === "GHES" /* GHES */ ? "and will be removed in GitHub Enterprise Server 3.18" : "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, gitHubVersion);
|
||||
|
||||
@@ -436,97 +436,79 @@ test(`selects CLI from defaults.json on GHES`, async (t) => {
|
||||
});
|
||||
});
|
||||
|
||||
test("selects CLI v2.20.1 on Dotcom when feature flags enable v2.20.0 and v2.20.1", async (t) => {
|
||||
await withTmpDir(async (tmpDir) => {
|
||||
const features = setUpFeatureFlagTests(tmpDir);
|
||||
const expectedFeatureEnablement = initializeFeatures(true);
|
||||
expectedFeatureEnablement["default_codeql_version_2_20_0_enabled"] = true;
|
||||
expectedFeatureEnablement["default_codeql_version_2_20_1_enabled"] = true;
|
||||
expectedFeatureEnablement["default_codeql_version_2_20_2_enabled"] = false;
|
||||
expectedFeatureEnablement["default_codeql_version_2_20_3_enabled"] = false;
|
||||
expectedFeatureEnablement["default_codeql_version_2_20_4_enabled"] = false;
|
||||
expectedFeatureEnablement["default_codeql_version_2_20_5_enabled"] = false;
|
||||
mockFeatureFlagApiEndpoint(200, expectedFeatureEnablement);
|
||||
for (const variant of [GitHubVariant.DOTCOM, GitHubVariant.GHE_DOTCOM]) {
|
||||
test(`selects CLI v2.20.1 on ${variant} when feature flags enable v2.20.0 and v2.20.1`, async (t) => {
|
||||
await withTmpDir(async (tmpDir) => {
|
||||
const features = setUpFeatureFlagTests(tmpDir);
|
||||
const expectedFeatureEnablement = initializeFeatures(true);
|
||||
expectedFeatureEnablement["default_codeql_version_2_20_0_enabled"] = true;
|
||||
expectedFeatureEnablement["default_codeql_version_2_20_1_enabled"] = true;
|
||||
expectedFeatureEnablement["default_codeql_version_2_20_2_enabled"] =
|
||||
false;
|
||||
expectedFeatureEnablement["default_codeql_version_2_20_3_enabled"] =
|
||||
false;
|
||||
expectedFeatureEnablement["default_codeql_version_2_20_4_enabled"] =
|
||||
false;
|
||||
expectedFeatureEnablement["default_codeql_version_2_20_5_enabled"] =
|
||||
false;
|
||||
mockFeatureFlagApiEndpoint(200, expectedFeatureEnablement);
|
||||
|
||||
const defaultCliVersion = await features.getDefaultCliVersion(
|
||||
GitHubVariant.DOTCOM,
|
||||
);
|
||||
t.deepEqual(defaultCliVersion, {
|
||||
cliVersion: "2.20.1",
|
||||
tagName: "codeql-bundle-v2.20.1",
|
||||
toolsFeatureFlagsValid: true,
|
||||
const defaultCliVersion = await features.getDefaultCliVersion(variant);
|
||||
t.deepEqual(defaultCliVersion, {
|
||||
cliVersion: "2.20.1",
|
||||
tagName: "codeql-bundle-v2.20.1",
|
||||
toolsFeatureFlagsValid: true,
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
test("includes tag name", async (t) => {
|
||||
await withTmpDir(async (tmpDir) => {
|
||||
const features = setUpFeatureFlagTests(tmpDir);
|
||||
const expectedFeatureEnablement = initializeFeatures(true);
|
||||
expectedFeatureEnablement["default_codeql_version_2_20_0_enabled"] = true;
|
||||
mockFeatureFlagApiEndpoint(200, expectedFeatureEnablement);
|
||||
test(`selects CLI from defaults.json on ${variant} when no default version feature flags are enabled`, async (t) => {
|
||||
await withTmpDir(async (tmpDir) => {
|
||||
const features = setUpFeatureFlagTests(tmpDir);
|
||||
const expectedFeatureEnablement = initializeFeatures(true);
|
||||
mockFeatureFlagApiEndpoint(200, expectedFeatureEnablement);
|
||||
|
||||
const defaultCliVersion = await features.getDefaultCliVersion(
|
||||
GitHubVariant.DOTCOM,
|
||||
);
|
||||
t.deepEqual(defaultCliVersion, {
|
||||
cliVersion: "2.20.0",
|
||||
tagName: "codeql-bundle-v2.20.0",
|
||||
toolsFeatureFlagsValid: true,
|
||||
const defaultCliVersion = await features.getDefaultCliVersion(variant);
|
||||
t.deepEqual(defaultCliVersion, {
|
||||
cliVersion: defaults.cliVersion,
|
||||
tagName: defaults.bundleVersion,
|
||||
toolsFeatureFlagsValid: false,
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
test(`selects CLI from defaults.json on Dotcom when no default version feature flags are enabled`, async (t) => {
|
||||
await withTmpDir(async (tmpDir) => {
|
||||
const features = setUpFeatureFlagTests(tmpDir);
|
||||
const expectedFeatureEnablement = initializeFeatures(true);
|
||||
mockFeatureFlagApiEndpoint(200, expectedFeatureEnablement);
|
||||
test(`ignores invalid version numbers in default version feature flags on ${variant}`, async (t) => {
|
||||
await withTmpDir(async (tmpDir) => {
|
||||
const loggedMessages = [];
|
||||
const features = setUpFeatureFlagTests(
|
||||
tmpDir,
|
||||
getRecordingLogger(loggedMessages),
|
||||
);
|
||||
const expectedFeatureEnablement = initializeFeatures(true);
|
||||
expectedFeatureEnablement["default_codeql_version_2_20_0_enabled"] = true;
|
||||
expectedFeatureEnablement["default_codeql_version_2_20_1_enabled"] = true;
|
||||
expectedFeatureEnablement["default_codeql_version_2_20_invalid_enabled"] =
|
||||
true;
|
||||
mockFeatureFlagApiEndpoint(200, expectedFeatureEnablement);
|
||||
|
||||
const defaultCliVersion = await features.getDefaultCliVersion(
|
||||
GitHubVariant.DOTCOM,
|
||||
);
|
||||
t.deepEqual(defaultCliVersion, {
|
||||
cliVersion: defaults.cliVersion,
|
||||
tagName: defaults.bundleVersion,
|
||||
toolsFeatureFlagsValid: false,
|
||||
const defaultCliVersion = await features.getDefaultCliVersion(variant);
|
||||
t.deepEqual(defaultCliVersion, {
|
||||
cliVersion: "2.20.1",
|
||||
tagName: "codeql-bundle-v2.20.1",
|
||||
toolsFeatureFlagsValid: true,
|
||||
});
|
||||
|
||||
t.assert(
|
||||
loggedMessages.find(
|
||||
(v: LoggedMessage) =>
|
||||
v.type === "warning" &&
|
||||
v.message ===
|
||||
"Ignoring feature flag default_codeql_version_2_20_invalid_enabled as it does not specify a valid CodeQL version.",
|
||||
) !== undefined,
|
||||
);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
test("ignores invalid version numbers in default version feature flags", async (t) => {
|
||||
await withTmpDir(async (tmpDir) => {
|
||||
const loggedMessages = [];
|
||||
const features = setUpFeatureFlagTests(
|
||||
tmpDir,
|
||||
getRecordingLogger(loggedMessages),
|
||||
);
|
||||
const expectedFeatureEnablement = initializeFeatures(true);
|
||||
expectedFeatureEnablement["default_codeql_version_2_20_0_enabled"] = true;
|
||||
expectedFeatureEnablement["default_codeql_version_2_20_1_enabled"] = true;
|
||||
expectedFeatureEnablement["default_codeql_version_2_20_invalid_enabled"] =
|
||||
true;
|
||||
mockFeatureFlagApiEndpoint(200, expectedFeatureEnablement);
|
||||
|
||||
const defaultCliVersion = await features.getDefaultCliVersion(
|
||||
GitHubVariant.DOTCOM,
|
||||
);
|
||||
t.deepEqual(defaultCliVersion, {
|
||||
cliVersion: "2.20.1",
|
||||
tagName: "codeql-bundle-v2.20.1",
|
||||
toolsFeatureFlagsValid: true,
|
||||
});
|
||||
|
||||
t.assert(
|
||||
loggedMessages.find(
|
||||
(v: LoggedMessage) =>
|
||||
v.type === "warning" &&
|
||||
v.message ===
|
||||
"Ignoring feature flag default_codeql_version_2_20_invalid_enabled as it does not specify a valid CodeQL version.",
|
||||
) !== undefined,
|
||||
);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
test("legacy feature flags should end with _enabled", async (t) => {
|
||||
for (const [feature, config] of Object.entries(featureConfig)) {
|
||||
|
||||
@@ -486,8 +486,8 @@ class GitHubFeatureFlags {
|
||||
async getDefaultCliVersion(
|
||||
variant: util.GitHubVariant,
|
||||
): Promise<CodeQLDefaultVersionInfo> {
|
||||
if (variant === util.GitHubVariant.DOTCOM) {
|
||||
return await this.getDefaultDotcomCliVersion();
|
||||
if (supportsFeatureFlags(variant)) {
|
||||
return await this.getDefaultCliVersionFromFlags();
|
||||
}
|
||||
return {
|
||||
cliVersion: defaults.cliVersion,
|
||||
@@ -495,7 +495,7 @@ class GitHubFeatureFlags {
|
||||
};
|
||||
}
|
||||
|
||||
async getDefaultDotcomCliVersion(): Promise<CodeQLDefaultVersionInfo> {
|
||||
async getDefaultCliVersionFromFlags(): Promise<CodeQLDefaultVersionInfo> {
|
||||
const response = await this.getAllFeatures();
|
||||
|
||||
const enabledFeatureFlagCliVersions = Object.entries(response)
|
||||
@@ -621,10 +621,7 @@ class GitHubFeatureFlags {
|
||||
|
||||
private async loadApiResponse(): Promise<GitHubFeatureFlagsApiResponse> {
|
||||
// Do nothing when not running against github.com
|
||||
if (
|
||||
this.gitHubVersion.type !== util.GitHubVariant.DOTCOM &&
|
||||
this.gitHubVersion.type !== util.GitHubVariant.GHE_DOTCOM
|
||||
) {
|
||||
if (!supportsFeatureFlags(this.gitHubVersion.type)) {
|
||||
this.logger.debug(
|
||||
"Not running against github.com. Disabling all toggleable features.",
|
||||
);
|
||||
@@ -690,3 +687,10 @@ class GitHubFeatureFlags {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function supportsFeatureFlags(githubVariant: util.GitHubVariant): boolean {
|
||||
return (
|
||||
githubVariant === util.GitHubVariant.DOTCOM ||
|
||||
githubVariant === util.GitHubVariant.GHE_DOTCOM
|
||||
);
|
||||
}
|
||||
|
||||
@@ -511,7 +511,7 @@ export async function getCodeQLSource(
|
||||
// different version to save download time if the version hasn't been
|
||||
// specified explicitly (in which case we always honor it).
|
||||
if (
|
||||
variant !== util.GitHubVariant.DOTCOM &&
|
||||
variant === util.GitHubVariant.GHES &&
|
||||
!forceShippedTools &&
|
||||
!toolsInput
|
||||
) {
|
||||
|
||||
@@ -434,7 +434,7 @@ function formatGitHubVersion(version: util.GitHubVersion): string {
|
||||
case util.GitHubVariant.DOTCOM:
|
||||
return "dotcom";
|
||||
case util.GitHubVariant.GHE_DOTCOM:
|
||||
return "GHE dotcom";
|
||||
return "GHEC-DR";
|
||||
case util.GitHubVariant.GHES:
|
||||
return `GHES ${version.version}`;
|
||||
default:
|
||||
|
||||
@@ -556,9 +556,9 @@ const CODEQL_ACTION_WARNED_ABOUT_VERSION_ENV_VAR =
|
||||
let hasBeenWarnedAboutVersion = false;
|
||||
|
||||
export enum GitHubVariant {
|
||||
DOTCOM,
|
||||
GHES,
|
||||
GHE_DOTCOM,
|
||||
DOTCOM = "GitHub.com",
|
||||
GHES = "GHES",
|
||||
GHE_DOTCOM = "GHEC-DR",
|
||||
}
|
||||
export type GitHubVersion =
|
||||
| { type: GitHubVariant.DOTCOM }
|
||||
|
||||
Reference in New Issue
Block a user