From 7a55ffeaf1cee40b2baa35a33085c50e6d2197b5 Mon Sep 17 00:00:00 2001 From: Henry Mercer Date: Wed, 10 Dec 2025 17:19:12 +0000 Subject: [PATCH 1/3] Determine CodeQL version from feature flags on GHEC-DR --- lib/analyze-action-post.js | 12 +-- lib/analyze-action.js | 33 +++---- lib/autobuild-action.js | 23 ++--- lib/init-action-post.js | 31 ++++--- lib/init-action.js | 29 ++++--- lib/resolve-environment-action.js | 12 +-- lib/setup-codeql-action.js | 25 +++--- lib/start-proxy-action-post.js | 12 +-- lib/upload-lib.js | 16 ++-- lib/upload-sarif-action-post.js | 12 +-- lib/upload-sarif-action.js | 29 ++++--- src/feature-flags.test.ts | 140 +++++++++++++----------------- src/feature-flags.ts | 18 ++-- src/setup-codeql.ts | 2 +- src/util.test.ts | 2 +- src/util.ts | 6 +- 16 files changed, 203 insertions(+), 199 deletions(-) diff --git a/lib/analyze-action-post.js b/lib/analyze-action-post.js index 37725d00bf..e9d563953f 100644 --- a/lib/analyze-action-post.js +++ b/lib/analyze-action-post.js @@ -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." ); diff --git a/lib/analyze-action.js b/lib/analyze-action.js index 8206afce01..aa7ae2919f 100644 --- a/lib/analyze-action.js +++ b/lib/analyze-action.js @@ -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); diff --git a/lib/autobuild-action.js b/lib/autobuild-action.js index d4b7fc1f6d..d960a3efcd 100644 --- a/lib/autobuild-action.js +++ b/lib/autobuild-action.js @@ -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()); diff --git a/lib/init-action-post.js b/lib/init-action-post.js index 62e78df8a5..0cb62be1d1 100644 --- a/lib/init-action-post.js +++ b/lib/init-action-post.js @@ -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); diff --git a/lib/init-action.js b/lib/init-action.js index 185510e02e..5c5253b9cf 100644 --- a/lib/init-action.js +++ b/lib/init-action.js @@ -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 diff --git a/lib/resolve-environment-action.js b/lib/resolve-environment-action.js index cd65a4bf1c..f6176cc3b2 100644 --- a/lib/resolve-environment-action.js +++ b/lib/resolve-environment-action.js @@ -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) { diff --git a/lib/setup-codeql-action.js b/lib/setup-codeql-action.js index 780d2cc6de..5b31700497 100644 --- a/lib/setup-codeql-action.js +++ b/lib/setup-codeql-action.js @@ -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 diff --git a/lib/start-proxy-action-post.js b/lib/start-proxy-action-post.js index c78e8262a6..e6b27d5c9c 100644 --- a/lib/start-proxy-action-post.js +++ b/lib/start-proxy-action-post.js @@ -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." ); diff --git a/lib/upload-lib.js b/lib/upload-lib.js index de44834ac9..70e266dd14 100644 --- a/lib/upload-lib.js +++ b/lib/upload-lib.js @@ -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); diff --git a/lib/upload-sarif-action-post.js b/lib/upload-sarif-action-post.js index f95b705faf..9322aa0c85 100644 --- a/lib/upload-sarif-action-post.js +++ b/lib/upload-sarif-action-post.js @@ -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." ); diff --git a/lib/upload-sarif-action.js b/lib/upload-sarif-action.js index f8ea28a2d0..3e2eb320dc 100644 --- a/lib/upload-sarif-action.js +++ b/lib/upload-sarif-action.js @@ -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); diff --git a/src/feature-flags.test.ts b/src/feature-flags.test.ts index ae9f079cab..1c4b5ef0c5 100644 --- a/src/feature-flags.test.ts +++ b/src/feature-flags.test.ts @@ -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); - const defaultCliVersion = await features.getDefaultCliVersion( - GitHubVariant.DOTCOM, - ); - t.deepEqual(defaultCliVersion, { - cliVersion: defaults.cliVersion, - tagName: defaults.bundleVersion, - toolsFeatureFlagsValid: false, - }); - }); -}); + 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); -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(variant); + t.deepEqual(defaultCliVersion, { + cliVersion: "2.20.1", + tagName: "codeql-bundle-v2.20.1", + toolsFeatureFlagsValid: true, + }); - 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, + ); }); - - 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)) { diff --git a/src/feature-flags.ts b/src/feature-flags.ts index 10e2e296c3..d6f6653f71 100644 --- a/src/feature-flags.ts +++ b/src/feature-flags.ts @@ -486,8 +486,8 @@ class GitHubFeatureFlags { async getDefaultCliVersion( variant: util.GitHubVariant, ): Promise { - 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 { + async getDefaultCliVersionFromFlags(): Promise { const response = await this.getAllFeatures(); const enabledFeatureFlagCliVersions = Object.entries(response) @@ -621,10 +621,7 @@ class GitHubFeatureFlags { private async loadApiResponse(): Promise { // 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 + ); +} diff --git a/src/setup-codeql.ts b/src/setup-codeql.ts index 16375421a7..2a39673d97 100644 --- a/src/setup-codeql.ts +++ b/src/setup-codeql.ts @@ -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 ) { diff --git a/src/util.test.ts b/src/util.test.ts index 2a8d941ec6..5b2f3e2acf 100644 --- a/src/util.test.ts +++ b/src/util.test.ts @@ -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: diff --git a/src/util.ts b/src/util.ts index aefcc5a2af..c5b57424ec 100644 --- a/src/util.ts +++ b/src/util.ts @@ -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 } From 1fc7d3785dc1d1ab06fa848d631eeb834a7e1e1e Mon Sep 17 00:00:00 2001 From: Henry Mercer Date: Wed, 10 Dec 2025 17:37:28 +0000 Subject: [PATCH 2/3] Rename GHE_DOTCOM to GHEC_DR This more closely reflects the published naming https://docs.github.com/en/enterprise-cloud@latest/admin/data-residency/about-github-enterprise-cloud-with-data-residency --- lib/analyze-action-post.js | 2 +- lib/analyze-action.js | 8 ++++---- lib/autobuild-action.js | 6 +++--- lib/init-action-post.js | 4 ++-- lib/init-action.js | 6 +++--- lib/resolve-environment-action.js | 4 ++-- lib/setup-codeql-action.js | 6 +++--- lib/start-proxy-action-post.js | 2 +- lib/upload-lib.js | 2 +- lib/upload-sarif-action-post.js | 2 +- lib/upload-sarif-action.js | 6 +++--- src/api-client.test.ts | 4 ++-- src/api-client.ts | 2 +- src/database-upload.ts | 2 +- src/feature-flags.test.ts | 6 +++--- src/feature-flags.ts | 2 +- src/util.test.ts | 8 ++++---- src/util.ts | 6 +++--- 18 files changed, 39 insertions(+), 39 deletions(-) diff --git a/lib/analyze-action-post.js b/lib/analyze-action-post.js index e9d563953f..b6bab330a1 100644 --- a/lib/analyze-action-post.js +++ b/lib/analyze-action-post.js @@ -119465,7 +119465,7 @@ async function getGitHubVersionFromApi(apiClient, apiDetails) { return { type: "GitHub.com" /* DOTCOM */ }; } if (response.headers[GITHUB_ENTERPRISE_VERSION_HEADER] === "ghe.com") { - return { type: "GHEC-DR" /* GHE_DOTCOM */ }; + return { type: "GHEC-DR" /* GHEC_DR */ }; } const version = response.headers[GITHUB_ENTERPRISE_VERSION_HEADER]; return { type: "GHES" /* GHES */, version }; diff --git a/lib/analyze-action.js b/lib/analyze-action.js index aa7ae2919f..8ab312d99a 100644 --- a/lib/analyze-action.js +++ b/lib/analyze-action.js @@ -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 === "GitHub.com" /* DOTCOM */ || githubVersion.type === "GHEC-DR" /* GHE_DOTCOM */ || githubVersion.type === "GHES" /* GHES */ && semver.satisfies( + if (githubVersion.type === "GitHub.com" /* DOTCOM */ || githubVersion.type === "GHEC-DR" /* GHEC_DR */ || githubVersion.type === "GHES" /* GHES */ && semver.satisfies( semver.coerce(githubVersion.version) ?? "0.0.0", ">=3.20" )) { @@ -87800,7 +87800,7 @@ async function getGitHubVersionFromApi(apiClient, apiDetails) { return { type: "GitHub.com" /* DOTCOM */ }; } if (response.headers[GITHUB_ENTERPRISE_VERSION_HEADER] === "ghe.com") { - return { type: "GHEC-DR" /* GHE_DOTCOM */ }; + return { type: "GHEC-DR" /* GHEC_DR */ }; } const version = response.headers[GITHUB_ENTERPRISE_VERSION_HEADER]; return { type: "GHES" /* GHES */, version }; @@ -89096,7 +89096,7 @@ var GitHubFeatureFlags = class { } }; function supportsFeatureFlags(githubVariant) { - return githubVariant === "GitHub.com" /* DOTCOM */ || githubVariant === "GHEC-DR" /* GHE_DOTCOM */; + return githubVariant === "GitHub.com" /* DOTCOM */ || githubVariant === "GHEC-DR" /* GHEC_DR */; } // src/diff-informed-analysis-utils.ts @@ -91689,7 +91689,7 @@ async function cleanupAndUploadDatabases(repositoryNwo, codeql, config, apiDetai logger.debug("In test mode. Skipping database upload."); return; } - if (config.gitHubVersion.type !== "GitHub.com" /* DOTCOM */ && config.gitHubVersion.type !== "GHEC-DR" /* GHE_DOTCOM */) { + if (config.gitHubVersion.type !== "GitHub.com" /* DOTCOM */ && config.gitHubVersion.type !== "GHEC-DR" /* GHEC_DR */) { logger.debug("Not running against github.com or GHEC-DR. Skipping upload."); return; } diff --git a/lib/autobuild-action.js b/lib/autobuild-action.js index d960a3efcd..965591d63f 100644 --- a/lib/autobuild-action.js +++ b/lib/autobuild-action.js @@ -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 === "GitHub.com" /* DOTCOM */ || githubVersion.type === "GHEC-DR" /* GHE_DOTCOM */ || githubVersion.type === "GHES" /* GHES */ && semver.satisfies( + if (githubVersion.type === "GitHub.com" /* DOTCOM */ || githubVersion.type === "GHEC-DR" /* GHEC_DR */ || githubVersion.type === "GHES" /* GHES */ && semver.satisfies( semver.coerce(githubVersion.version) ?? "0.0.0", ">=3.20" )) { @@ -83374,7 +83374,7 @@ async function getGitHubVersionFromApi(apiClient, apiDetails) { return { type: "GitHub.com" /* DOTCOM */ }; } if (response.headers[GITHUB_ENTERPRISE_VERSION_HEADER] === "ghe.com") { - return { type: "GHEC-DR" /* GHE_DOTCOM */ }; + return { type: "GHEC-DR" /* GHEC_DR */ }; } const version = response.headers[GITHUB_ENTERPRISE_VERSION_HEADER]; return { type: "GHES" /* GHES */, version }; @@ -84415,7 +84415,7 @@ var GitHubFeatureFlags = class { } }; function supportsFeatureFlags(githubVariant) { - return githubVariant === "GitHub.com" /* DOTCOM */ || githubVariant === "GHEC-DR" /* GHE_DOTCOM */; + return githubVariant === "GitHub.com" /* DOTCOM */ || githubVariant === "GHEC-DR" /* GHEC_DR */; } // src/trap-caching.ts diff --git a/lib/init-action-post.js b/lib/init-action-post.js index 0cb62be1d1..24c0be53ab 100644 --- a/lib/init-action-post.js +++ b/lib/init-action-post.js @@ -122675,7 +122675,7 @@ async function getGitHubVersionFromApi(apiClient, apiDetails) { return { type: "GitHub.com" /* DOTCOM */ }; } if (response.headers[GITHUB_ENTERPRISE_VERSION_HEADER] === "ghe.com") { - return { type: "GHEC-DR" /* GHE_DOTCOM */ }; + return { type: "GHEC-DR" /* GHEC_DR */ }; } const version = response.headers[GITHUB_ENTERPRISE_VERSION_HEADER]; return { type: "GHES" /* GHES */, version }; @@ -123856,7 +123856,7 @@ var GitHubFeatureFlags = class { } }; function supportsFeatureFlags(githubVariant) { - return githubVariant === "GitHub.com" /* DOTCOM */ || githubVariant === "GHEC-DR" /* GHE_DOTCOM */; + return githubVariant === "GitHub.com" /* DOTCOM */ || githubVariant === "GHEC-DR" /* GHEC_DR */; } // src/diff-informed-analysis-utils.ts diff --git a/lib/init-action.js b/lib/init-action.js index 5c5253b9cf..1ee94b7d80 100644 --- a/lib/init-action.js +++ b/lib/init-action.js @@ -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 === "GitHub.com" /* DOTCOM */ || githubVersion.type === "GHEC-DR" /* GHE_DOTCOM */ || githubVersion.type === "GHES" /* GHES */ && semver.satisfies( + if (githubVersion.type === "GitHub.com" /* DOTCOM */ || githubVersion.type === "GHEC-DR" /* GHEC_DR */ || githubVersion.type === "GHES" /* GHES */ && semver.satisfies( semver.coerce(githubVersion.version) ?? "0.0.0", ">=3.20" )) { @@ -85125,7 +85125,7 @@ async function getGitHubVersionFromApi(apiClient, apiDetails) { return { type: "GitHub.com" /* DOTCOM */ }; } if (response.headers[GITHUB_ENTERPRISE_VERSION_HEADER] === "ghe.com") { - return { type: "GHEC-DR" /* GHE_DOTCOM */ }; + return { type: "GHEC-DR" /* GHEC_DR */ }; } const version = response.headers[GITHUB_ENTERPRISE_VERSION_HEADER]; return { type: "GHES" /* GHES */, version }; @@ -86510,7 +86510,7 @@ var GitHubFeatureFlags = class { } }; function supportsFeatureFlags(githubVariant) { - return githubVariant === "GitHub.com" /* DOTCOM */ || githubVariant === "GHEC-DR" /* GHE_DOTCOM */; + return githubVariant === "GitHub.com" /* DOTCOM */ || githubVariant === "GHEC-DR" /* GHEC_DR */; } // src/diff-informed-analysis-utils.ts diff --git a/lib/resolve-environment-action.js b/lib/resolve-environment-action.js index f6176cc3b2..a277fbbffb 100644 --- a/lib/resolve-environment-action.js +++ b/lib/resolve-environment-action.js @@ -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 === "GitHub.com" /* DOTCOM */ || githubVersion.type === "GHEC-DR" /* GHE_DOTCOM */ || githubVersion.type === "GHES" /* GHES */ && semver.satisfies( + if (githubVersion.type === "GitHub.com" /* DOTCOM */ || githubVersion.type === "GHEC-DR" /* GHEC_DR */ || githubVersion.type === "GHES" /* GHES */ && semver.satisfies( semver.coerce(githubVersion.version) ?? "0.0.0", ">=3.20" )) { @@ -83382,7 +83382,7 @@ async function getGitHubVersionFromApi(apiClient, apiDetails) { return { type: "GitHub.com" /* DOTCOM */ }; } if (response.headers[GITHUB_ENTERPRISE_VERSION_HEADER] === "ghe.com") { - return { type: "GHEC-DR" /* GHE_DOTCOM */ }; + return { type: "GHEC-DR" /* GHEC_DR */ }; } const version = response.headers[GITHUB_ENTERPRISE_VERSION_HEADER]; return { type: "GHES" /* GHES */, version }; diff --git a/lib/setup-codeql-action.js b/lib/setup-codeql-action.js index 5b31700497..e59a1b77e8 100644 --- a/lib/setup-codeql-action.js +++ b/lib/setup-codeql-action.js @@ -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 === "GitHub.com" /* DOTCOM */ || githubVersion.type === "GHEC-DR" /* GHE_DOTCOM */ || githubVersion.type === "GHES" /* GHES */ && semver.satisfies( + if (githubVersion.type === "GitHub.com" /* DOTCOM */ || githubVersion.type === "GHEC-DR" /* GHEC_DR */ || githubVersion.type === "GHES" /* GHES */ && semver.satisfies( semver.coerce(githubVersion.version) ?? "0.0.0", ">=3.20" )) { @@ -83499,7 +83499,7 @@ async function getGitHubVersionFromApi(apiClient, apiDetails) { return { type: "GitHub.com" /* DOTCOM */ }; } if (response.headers[GITHUB_ENTERPRISE_VERSION_HEADER] === "ghe.com") { - return { type: "GHEC-DR" /* GHE_DOTCOM */ }; + return { type: "GHEC-DR" /* GHEC_DR */ }; } const version = response.headers[GITHUB_ENTERPRISE_VERSION_HEADER]; return { type: "GHES" /* GHES */, version }; @@ -84318,7 +84318,7 @@ var GitHubFeatureFlags = class { } }; function supportsFeatureFlags(githubVariant) { - return githubVariant === "GitHub.com" /* DOTCOM */ || githubVariant === "GHEC-DR" /* GHE_DOTCOM */; + return githubVariant === "GitHub.com" /* DOTCOM */ || githubVariant === "GHEC-DR" /* GHEC_DR */; } // src/init.ts diff --git a/lib/start-proxy-action-post.js b/lib/start-proxy-action-post.js index e6b27d5c9c..7610737546 100644 --- a/lib/start-proxy-action-post.js +++ b/lib/start-proxy-action-post.js @@ -119348,7 +119348,7 @@ async function getGitHubVersionFromApi(apiClient, apiDetails) { return { type: "GitHub.com" /* DOTCOM */ }; } if (response.headers[GITHUB_ENTERPRISE_VERSION_HEADER] === "ghe.com") { - return { type: "GHEC-DR" /* GHE_DOTCOM */ }; + return { type: "GHEC-DR" /* GHEC_DR */ }; } const version = response.headers[GITHUB_ENTERPRISE_VERSION_HEADER]; return { type: "GHES" /* GHES */, version }; diff --git a/lib/upload-lib.js b/lib/upload-lib.js index 70e266dd14..a6300b1bc8 100644 --- a/lib/upload-lib.js +++ b/lib/upload-lib.js @@ -86355,7 +86355,7 @@ async function getGitHubVersionFromApi(apiClient, apiDetails) { return { type: "GitHub.com" /* DOTCOM */ }; } if (response.headers[GITHUB_ENTERPRISE_VERSION_HEADER] === "ghe.com") { - return { type: "GHEC-DR" /* GHE_DOTCOM */ }; + return { type: "GHEC-DR" /* GHEC_DR */ }; } const version = response.headers[GITHUB_ENTERPRISE_VERSION_HEADER]; return { type: "GHES" /* GHES */, version }; diff --git a/lib/upload-sarif-action-post.js b/lib/upload-sarif-action-post.js index 9322aa0c85..6ace87bbab 100644 --- a/lib/upload-sarif-action-post.js +++ b/lib/upload-sarif-action-post.js @@ -119352,7 +119352,7 @@ async function getGitHubVersionFromApi(apiClient, apiDetails) { return { type: "GitHub.com" /* DOTCOM */ }; } if (response.headers[GITHUB_ENTERPRISE_VERSION_HEADER] === "ghe.com") { - return { type: "GHEC-DR" /* GHE_DOTCOM */ }; + return { type: "GHEC-DR" /* GHEC_DR */ }; } const version = response.headers[GITHUB_ENTERPRISE_VERSION_HEADER]; return { type: "GHES" /* GHES */, version }; diff --git a/lib/upload-sarif-action.js b/lib/upload-sarif-action.js index 3e2eb320dc..f15c301f68 100644 --- a/lib/upload-sarif-action.js +++ b/lib/upload-sarif-action.js @@ -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 === "GitHub.com" /* DOTCOM */ || githubVersion.type === "GHEC-DR" /* GHE_DOTCOM */ || githubVersion.type === "GHES" /* GHES */ && semver.satisfies( + if (githubVersion.type === "GitHub.com" /* DOTCOM */ || githubVersion.type === "GHEC-DR" /* GHEC_DR */ || githubVersion.type === "GHES" /* GHES */ && semver.satisfies( semver.coerce(githubVersion.version) ?? "0.0.0", ">=3.20" )) { @@ -86401,7 +86401,7 @@ async function getGitHubVersionFromApi(apiClient, apiDetails) { return { type: "GitHub.com" /* DOTCOM */ }; } if (response.headers[GITHUB_ENTERPRISE_VERSION_HEADER] === "ghe.com") { - return { type: "GHEC-DR" /* GHE_DOTCOM */ }; + return { type: "GHEC-DR" /* GHEC_DR */ }; } const version = response.headers[GITHUB_ENTERPRISE_VERSION_HEADER]; return { type: "GHES" /* GHES */, version }; @@ -87268,7 +87268,7 @@ var GitHubFeatureFlags = class { } }; function supportsFeatureFlags(githubVariant) { - return githubVariant === "GitHub.com" /* DOTCOM */ || githubVariant === "GHEC-DR" /* GHE_DOTCOM */; + return githubVariant === "GitHub.com" /* DOTCOM */ || githubVariant === "GHEC-DR" /* GHEC_DR */; } // src/status-report.ts diff --git a/src/api-client.test.ts b/src/api-client.test.ts index d3a5ce2bca..073f68ff1b 100644 --- a/src/api-client.test.ts +++ b/src/api-client.test.ts @@ -95,14 +95,14 @@ test("getGitHubVersion for different domain", async (t) => { t.deepEqual({ type: util.GitHubVariant.DOTCOM }, v3); }); -test("getGitHubVersion for GHE_DOTCOM", async (t) => { +test("getGitHubVersion for GHEC-DR", async (t) => { mockGetMetaVersionHeader("ghe.com"); const gheDotcom = await api.getGitHubVersionFromApi(api.getApiClient(), { auth: "", url: "https://foo.ghe.com", apiURL: undefined, }); - t.deepEqual({ type: util.GitHubVariant.GHE_DOTCOM }, gheDotcom); + t.deepEqual({ type: util.GitHubVariant.GHEC_DR }, gheDotcom); }); test("wrapApiConfigurationError correctly wraps specific configuration errors", (t) => { diff --git a/src/api-client.ts b/src/api-client.ts index 600da1ed6d..32a6a080b7 100644 --- a/src/api-client.ts +++ b/src/api-client.ts @@ -125,7 +125,7 @@ export async function getGitHubVersionFromApi( } if (response.headers[GITHUB_ENTERPRISE_VERSION_HEADER] === "ghe.com") { - return { type: GitHubVariant.GHE_DOTCOM }; + return { type: GitHubVariant.GHEC_DR }; } const version = response.headers[GITHUB_ENTERPRISE_VERSION_HEADER] as string; diff --git a/src/database-upload.ts b/src/database-upload.ts index d99df14c3d..ab0e2636a2 100644 --- a/src/database-upload.ts +++ b/src/database-upload.ts @@ -41,7 +41,7 @@ export async function cleanupAndUploadDatabases( // Do nothing when not running against github.com if ( config.gitHubVersion.type !== util.GitHubVariant.DOTCOM && - config.gitHubVersion.type !== util.GitHubVariant.GHE_DOTCOM + config.gitHubVersion.type !== util.GitHubVariant.GHEC_DR ) { logger.debug("Not running against github.com or GHEC-DR. Skipping upload."); return; diff --git a/src/feature-flags.test.ts b/src/feature-flags.test.ts index 1c4b5ef0c5..11e7ba538f 100644 --- a/src/feature-flags.test.ts +++ b/src/feature-flags.test.ts @@ -62,13 +62,13 @@ test(`All features are disabled if running against GHES`, async (t) => { }); }); -test(`Feature flags are requested in Proxima`, async (t) => { +test(`Feature flags are requested in GHEC-DR`, async (t) => { await withTmpDir(async (tmpDir) => { const loggedMessages = []; const features = setUpFeatureFlagTests( tmpDir, getRecordingLogger(loggedMessages), - { type: GitHubVariant.GHE_DOTCOM }, + { type: GitHubVariant.GHEC_DR }, ); mockFeatureFlagApiEndpoint(200, initializeFeatures(true)); @@ -436,7 +436,7 @@ test(`selects CLI from defaults.json on GHES`, async (t) => { }); }); -for (const variant of [GitHubVariant.DOTCOM, GitHubVariant.GHE_DOTCOM]) { +for (const variant of [GitHubVariant.DOTCOM, GitHubVariant.GHEC_DR]) { 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); diff --git a/src/feature-flags.ts b/src/feature-flags.ts index d6f6653f71..4ad548d11b 100644 --- a/src/feature-flags.ts +++ b/src/feature-flags.ts @@ -691,6 +691,6 @@ class GitHubFeatureFlags { function supportsFeatureFlags(githubVariant: util.GitHubVariant): boolean { return ( githubVariant === util.GitHubVariant.DOTCOM || - githubVariant === util.GitHubVariant.GHE_DOTCOM + githubVariant === util.GitHubVariant.GHEC_DR ); } diff --git a/src/util.test.ts b/src/util.test.ts index 5b2f3e2acf..1376ae7801 100644 --- a/src/util.test.ts +++ b/src/util.test.ts @@ -433,7 +433,7 @@ function formatGitHubVersion(version: util.GitHubVersion): string { switch (version.type) { case util.GitHubVariant.DOTCOM: return "dotcom"; - case util.GitHubVariant.GHE_DOTCOM: + case util.GitHubVariant.GHEC_DR: return "GHEC-DR"; case util.GitHubVariant.GHES: return `GHES ${version.version}`; @@ -445,12 +445,12 @@ function formatGitHubVersion(version: util.GitHubVersion): string { const CHECK_ACTION_VERSION_TESTS: Array<[string, util.GitHubVersion, boolean]> = [ ["2.2.1", { type: util.GitHubVariant.DOTCOM }, true], - ["2.2.1", { type: util.GitHubVariant.GHE_DOTCOM }, true], + ["2.2.1", { type: util.GitHubVariant.GHEC_DR }, true], ["2.2.1", { type: util.GitHubVariant.GHES, version: "3.10" }, false], ["2.2.1", { type: util.GitHubVariant.GHES, version: "3.11" }, false], ["2.2.1", { type: util.GitHubVariant.GHES, version: "3.12" }, false], ["3.2.1", { type: util.GitHubVariant.DOTCOM }, true], - ["3.2.1", { type: util.GitHubVariant.GHE_DOTCOM }, true], + ["3.2.1", { type: util.GitHubVariant.GHEC_DR }, true], ["3.2.1", { type: util.GitHubVariant.GHES, version: "3.10" }, false], ["3.2.1", { type: util.GitHubVariant.GHES, version: "3.11" }, false], ["3.2.1", { type: util.GitHubVariant.GHES, version: "3.12" }, false], @@ -458,7 +458,7 @@ const CHECK_ACTION_VERSION_TESTS: Array<[string, util.GitHubVersion, boolean]> = ["3.2.1", { type: util.GitHubVariant.GHES, version: "3.20" }, true], ["3.2.1", { type: util.GitHubVariant.GHES, version: "3.21" }, true], ["4.2.1", { type: util.GitHubVariant.DOTCOM }, false], - ["4.2.1", { type: util.GitHubVariant.GHE_DOTCOM }, false], + ["4.2.1", { type: util.GitHubVariant.GHEC_DR }, false], ["4.2.1", { type: util.GitHubVariant.GHES, version: "3.19" }, false], ["4.2.1", { type: util.GitHubVariant.GHES, version: "3.20" }, false], ["4.2.1", { type: util.GitHubVariant.GHES, version: "3.21" }, false], diff --git a/src/util.ts b/src/util.ts index c5b57424ec..48b5e00968 100644 --- a/src/util.ts +++ b/src/util.ts @@ -558,11 +558,11 @@ let hasBeenWarnedAboutVersion = false; export enum GitHubVariant { DOTCOM = "GitHub.com", GHES = "GHES", - GHE_DOTCOM = "GHEC-DR", + GHEC_DR = "GHEC-DR", } export type GitHubVersion = | { type: GitHubVariant.DOTCOM } - | { type: GitHubVariant.GHE_DOTCOM } + | { type: GitHubVariant.GHEC_DR } | { type: GitHubVariant.GHES; version: string }; export function checkGitHubVersionInRange( @@ -1105,7 +1105,7 @@ export function checkActionVersion( // and should update to CodeQL Action v4. if ( githubVersion.type === GitHubVariant.DOTCOM || - githubVersion.type === GitHubVariant.GHE_DOTCOM || + githubVersion.type === GitHubVariant.GHEC_DR || (githubVersion.type === GitHubVariant.GHES && semver.satisfies( semver.coerce(githubVersion.version) ?? "0.0.0", From da501245d4ed799c6f771bf73b4c8c38b54e18fc Mon Sep 17 00:00:00 2001 From: Henry Mercer Date: Wed, 10 Dec 2025 17:38:39 +0000 Subject: [PATCH 3/3] Update PR template to include GHEC-DR --- .github/pull_request_template.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md index 3c6d14f717..2e552907f1 100644 --- a/.github/pull_request_template.md +++ b/.github/pull_request_template.md @@ -34,7 +34,7 @@ Products: Environments: -- **Dotcom** - Impacts CodeQL workflows on `github.com`. +- **Dotcom** - Impacts CodeQL workflows on `github.com` and/or GitHub Enterprise Cloud with Data Residency. - **GHES** - Impacts CodeQL workflows on GitHub Enterprise Server. - **Testing/None** - This change does not impact any CodeQL workflows in production.