From db33d20bf4d9e52bf28614819f7d60f5cb9c9256 Mon Sep 17 00:00:00 2001 From: "Michael B. Gale" Date: Thu, 26 Feb 2026 13:10:52 +0000 Subject: [PATCH] Put change behind a FF --- lib/analyze-action-post.js | 5 ++++ lib/analyze-action.js | 5 ++++ lib/autobuild-action.js | 5 ++++ lib/init-action-post.js | 5 ++++ lib/init-action.js | 5 ++++ lib/resolve-environment-action.js | 5 ++++ lib/setup-codeql-action.js | 5 ++++ lib/start-proxy-action-post.js | 5 ++++ lib/start-proxy-action.js | 18 +++++++++-- lib/upload-lib.js | 5 ++++ lib/upload-sarif-action-post.js | 5 ++++ lib/upload-sarif-action.js | 5 ++++ src/feature-flags.ts | 6 ++++ src/start-proxy.test.ts | 50 +++++++++++++++++++++++++++++++ src/start-proxy.ts | 26 ++++++++++++++-- 15 files changed, 150 insertions(+), 5 deletions(-) diff --git a/lib/analyze-action-post.js b/lib/analyze-action-post.js index d95b97875..775ae41f5 100644 --- a/lib/analyze-action-post.js +++ b/lib/analyze-action-post.js @@ -161755,6 +161755,11 @@ var featureConfig = { // cannot be found when interpreting results. minimumVersion: void 0 }, + ["start_proxy_use_features_release" /* StartProxyUseFeaturesRelease */]: { + defaultValue: false, + envVar: "CODEQL_ACTION_START_PROXY_USE_FEATURES_RELEASE", + minimumVersion: void 0 + }, ["upload_overlay_db_to_api" /* UploadOverlayDbToApi */]: { defaultValue: false, envVar: "CODEQL_ACTION_UPLOAD_OVERLAY_DB_TO_API", diff --git a/lib/analyze-action.js b/lib/analyze-action.js index c490eaad7..4857bbb3b 100644 --- a/lib/analyze-action.js +++ b/lib/analyze-action.js @@ -107853,6 +107853,11 @@ var featureConfig = { // cannot be found when interpreting results. minimumVersion: void 0 }, + ["start_proxy_use_features_release" /* StartProxyUseFeaturesRelease */]: { + defaultValue: false, + envVar: "CODEQL_ACTION_START_PROXY_USE_FEATURES_RELEASE", + minimumVersion: void 0 + }, ["upload_overlay_db_to_api" /* UploadOverlayDbToApi */]: { defaultValue: false, envVar: "CODEQL_ACTION_UPLOAD_OVERLAY_DB_TO_API", diff --git a/lib/autobuild-action.js b/lib/autobuild-action.js index 664212ec8..500b3396d 100644 --- a/lib/autobuild-action.js +++ b/lib/autobuild-action.js @@ -104142,6 +104142,11 @@ var featureConfig = { // cannot be found when interpreting results. minimumVersion: void 0 }, + ["start_proxy_use_features_release" /* StartProxyUseFeaturesRelease */]: { + defaultValue: false, + envVar: "CODEQL_ACTION_START_PROXY_USE_FEATURES_RELEASE", + minimumVersion: void 0 + }, ["upload_overlay_db_to_api" /* UploadOverlayDbToApi */]: { defaultValue: false, envVar: "CODEQL_ACTION_UPLOAD_OVERLAY_DB_TO_API", diff --git a/lib/init-action-post.js b/lib/init-action-post.js index e4d4060d4..f53b7d367 100644 --- a/lib/init-action-post.js +++ b/lib/init-action-post.js @@ -165252,6 +165252,11 @@ var featureConfig = { // cannot be found when interpreting results. minimumVersion: void 0 }, + ["start_proxy_use_features_release" /* StartProxyUseFeaturesRelease */]: { + defaultValue: false, + envVar: "CODEQL_ACTION_START_PROXY_USE_FEATURES_RELEASE", + minimumVersion: void 0 + }, ["upload_overlay_db_to_api" /* UploadOverlayDbToApi */]: { defaultValue: false, envVar: "CODEQL_ACTION_UPLOAD_OVERLAY_DB_TO_API", diff --git a/lib/init-action.js b/lib/init-action.js index 74a627293..66de01afe 100644 --- a/lib/init-action.js +++ b/lib/init-action.js @@ -105371,6 +105371,11 @@ var featureConfig = { // cannot be found when interpreting results. minimumVersion: void 0 }, + ["start_proxy_use_features_release" /* StartProxyUseFeaturesRelease */]: { + defaultValue: false, + envVar: "CODEQL_ACTION_START_PROXY_USE_FEATURES_RELEASE", + minimumVersion: void 0 + }, ["upload_overlay_db_to_api" /* UploadOverlayDbToApi */]: { defaultValue: false, envVar: "CODEQL_ACTION_UPLOAD_OVERLAY_DB_TO_API", diff --git a/lib/resolve-environment-action.js b/lib/resolve-environment-action.js index 3df530b88..6483f98fe 100644 --- a/lib/resolve-environment-action.js +++ b/lib/resolve-environment-action.js @@ -104133,6 +104133,11 @@ var featureConfig = { // cannot be found when interpreting results. minimumVersion: void 0 }, + ["start_proxy_use_features_release" /* StartProxyUseFeaturesRelease */]: { + defaultValue: false, + envVar: "CODEQL_ACTION_START_PROXY_USE_FEATURES_RELEASE", + minimumVersion: void 0 + }, ["upload_overlay_db_to_api" /* UploadOverlayDbToApi */]: { defaultValue: false, envVar: "CODEQL_ACTION_UPLOAD_OVERLAY_DB_TO_API", diff --git a/lib/setup-codeql-action.js b/lib/setup-codeql-action.js index 179fbab6a..7f63d7b93 100644 --- a/lib/setup-codeql-action.js +++ b/lib/setup-codeql-action.js @@ -104042,6 +104042,11 @@ var featureConfig = { // cannot be found when interpreting results. minimumVersion: void 0 }, + ["start_proxy_use_features_release" /* StartProxyUseFeaturesRelease */]: { + defaultValue: false, + envVar: "CODEQL_ACTION_START_PROXY_USE_FEATURES_RELEASE", + minimumVersion: void 0 + }, ["upload_overlay_db_to_api" /* UploadOverlayDbToApi */]: { defaultValue: false, envVar: "CODEQL_ACTION_UPLOAD_OVERLAY_DB_TO_API", diff --git a/lib/start-proxy-action-post.js b/lib/start-proxy-action-post.js index 7ddcd2426..dffe7d2b1 100644 --- a/lib/start-proxy-action-post.js +++ b/lib/start-proxy-action-post.js @@ -161161,6 +161161,11 @@ var featureConfig = { // cannot be found when interpreting results. minimumVersion: void 0 }, + ["start_proxy_use_features_release" /* StartProxyUseFeaturesRelease */]: { + defaultValue: false, + envVar: "CODEQL_ACTION_START_PROXY_USE_FEATURES_RELEASE", + minimumVersion: void 0 + }, ["upload_overlay_db_to_api" /* UploadOverlayDbToApi */]: { defaultValue: false, envVar: "CODEQL_ACTION_UPLOAD_OVERLAY_DB_TO_API", diff --git a/lib/start-proxy-action.js b/lib/start-proxy-action.js index 9208971b1..5db5e20e5 100644 --- a/lib/start-proxy-action.js +++ b/lib/start-proxy-action.js @@ -120834,6 +120834,11 @@ var featureConfig = { // cannot be found when interpreting results. minimumVersion: void 0 }, + ["start_proxy_use_features_release" /* StartProxyUseFeaturesRelease */]: { + defaultValue: false, + envVar: "CODEQL_ACTION_START_PROXY_USE_FEATURES_RELEASE", + minimumVersion: void 0 + }, ["upload_overlay_db_to_api" /* UploadOverlayDbToApi */]: { defaultValue: false, envVar: "CODEQL_ACTION_UPLOAD_OVERLAY_DB_TO_API", @@ -121706,11 +121711,20 @@ async function getReleaseByVersion(version) { tag: version }); } +async function getCliVersionFromFeatures(features) { + const gitHubVersion = await getGitHubVersion(); + return await features.getDefaultCliVersion(gitHubVersion.type); +} async function getDownloadUrl(logger, features) { const proxyPackage = getProxyPackage(); try { - const gitHubVersion = await getGitHubVersion(); - const versionInfo = await features.getDefaultCliVersion(gitHubVersion.type); + const useFeaturesToDetermineCLI = await features.getValue( + "start_proxy_use_features_release" /* StartProxyUseFeaturesRelease */ + ); + const versionInfo = useFeaturesToDetermineCLI ? await getCliVersionFromFeatures(features) : { + cliVersion, + tagName: bundleVersion + }; const cliRelease = await getReleaseByVersion(versionInfo.tagName); for (const asset of cliRelease.data.assets) { if (asset.name === proxyPackage) { diff --git a/lib/upload-lib.js b/lib/upload-lib.js index f7e8206de..04d723f26 100644 --- a/lib/upload-lib.js +++ b/lib/upload-lib.js @@ -107301,6 +107301,11 @@ var featureConfig = { // cannot be found when interpreting results. minimumVersion: void 0 }, + ["start_proxy_use_features_release" /* StartProxyUseFeaturesRelease */]: { + defaultValue: false, + envVar: "CODEQL_ACTION_START_PROXY_USE_FEATURES_RELEASE", + minimumVersion: void 0 + }, ["upload_overlay_db_to_api" /* UploadOverlayDbToApi */]: { defaultValue: false, envVar: "CODEQL_ACTION_UPLOAD_OVERLAY_DB_TO_API", diff --git a/lib/upload-sarif-action-post.js b/lib/upload-sarif-action-post.js index 010dfa897..812e73e47 100644 --- a/lib/upload-sarif-action-post.js +++ b/lib/upload-sarif-action-post.js @@ -161323,6 +161323,11 @@ var featureConfig = { // cannot be found when interpreting results. minimumVersion: void 0 }, + ["start_proxy_use_features_release" /* StartProxyUseFeaturesRelease */]: { + defaultValue: false, + envVar: "CODEQL_ACTION_START_PROXY_USE_FEATURES_RELEASE", + minimumVersion: void 0 + }, ["upload_overlay_db_to_api" /* UploadOverlayDbToApi */]: { defaultValue: false, envVar: "CODEQL_ACTION_UPLOAD_OVERLAY_DB_TO_API", diff --git a/lib/upload-sarif-action.js b/lib/upload-sarif-action.js index 3459ded50..c14378e0d 100644 --- a/lib/upload-sarif-action.js +++ b/lib/upload-sarif-action.js @@ -107026,6 +107026,11 @@ var featureConfig = { // cannot be found when interpreting results. minimumVersion: void 0 }, + ["start_proxy_use_features_release" /* StartProxyUseFeaturesRelease */]: { + defaultValue: false, + envVar: "CODEQL_ACTION_START_PROXY_USE_FEATURES_RELEASE", + minimumVersion: void 0 + }, ["upload_overlay_db_to_api" /* UploadOverlayDbToApi */]: { defaultValue: false, envVar: "CODEQL_ACTION_UPLOAD_OVERLAY_DB_TO_API", diff --git a/src/feature-flags.ts b/src/feature-flags.ts index 6155950a4..546d2e0ff 100644 --- a/src/feature-flags.ts +++ b/src/feature-flags.ts @@ -77,6 +77,7 @@ export enum Feature { QaTelemetryEnabled = "qa_telemetry_enabled", /** Note that this currently only disables baseline file coverage information. */ SkipFileCoverageOnPrs = "skip_file_coverage_on_prs", + StartProxyUseFeaturesRelease = "start_proxy_use_features_release", UploadOverlayDbToApi = "upload_overlay_db_to_api", UseRepositoryProperties = "use_repository_properties_v2", ValidateDbConfig = "validate_db_config", @@ -327,6 +328,11 @@ export const featureConfig = { // cannot be found when interpreting results. minimumVersion: undefined, }, + [Feature.StartProxyUseFeaturesRelease]: { + defaultValue: false, + envVar: "CODEQL_ACTION_START_PROXY_USE_FEATURES_RELEASE", + minimumVersion: undefined, + }, [Feature.UploadOverlayDbToApi]: { defaultValue: false, envVar: "CODEQL_ACTION_UPLOAD_OVERLAY_DB_TO_API", diff --git a/src/start-proxy.test.ts b/src/start-proxy.test.ts index eb8fb5a5c..d00061196 100644 --- a/src/start-proxy.test.ts +++ b/src/start-proxy.test.ts @@ -15,6 +15,7 @@ import { parseLanguage } from "./start-proxy"; import * as statusReport from "./status-report"; import { checkExpectedLogMessages, + createFeatures, getRecordingLogger, makeTestToken, RecordingLogger, @@ -621,6 +622,52 @@ test("getProxyBinaryPath - returns path from tool cache if available", async (t) }); test("getProxyBinaryPath - downloads proxy if not in cache", async (t) => { + const downloadUrl = "url-we-want"; + mockGetReleaseByTag([ + { name: startProxyExports.getProxyPackage(), url: downloadUrl }, + ]); + + await withRecordingLoggerAsync(async (logger) => { + const toolcachePath = "/path/to/proxy/dir"; + const find = sinon.stub(toolcache, "find").returns(""); + const getApiDetails = sinon.stub(apiClient, "getApiDetails").returns({ + auth: "", + url: "", + apiURL: "", + }); + const getAuthorizationHeaderFor = sinon + .stub(apiClient, "getAuthorizationHeaderFor") + .returns(undefined); + const archivePath = "/path/to/archive"; + const downloadTool = sinon + .stub(toolcache, "downloadTool") + .resolves(archivePath); + const extractedPath = "/path/to/extracted"; + const extractTar = sinon + .stub(toolcache, "extractTar") + .resolves(extractedPath); + const cacheDir = sinon.stub(toolcache, "cacheDir").resolves(toolcachePath); + + const path = await startProxyExports.getProxyBinaryPath( + logger, + createFeatures([]), + ); + + t.assert(find.calledOnce); + t.assert(getApiDetails.calledOnce); + t.assert(getAuthorizationHeaderFor.calledOnce); + t.assert(downloadTool.calledOnceWith(downloadUrl)); + t.assert(extractTar.calledOnceWith(archivePath)); + t.assert(cacheDir.calledOnceWith(extractedPath)); + t.assert(path); + t.is( + path, + filepath.join(toolcachePath, startProxyExports.getProxyFilename()), + ); + }); +}); + +test("getProxyBinaryPath - downloads proxy based on features if not in cache", async (t) => { const logger = new RecordingLogger(); const expectedTag = "codeql-bundle-v2.20.1"; const expectedParams = { @@ -672,6 +719,9 @@ test("getProxyBinaryPath - downloads proxy if not in cache", async (t) => { sinon.stub(apiClient, "getGitHubVersion").resolves(gitHubVersion); const features = setUpFeatureFlagTests(tempDir, logger, gitHubVersion); + sinon.stub(features, "getValue").callsFake(async (_feature, _codeql) => { + return true; + }); const getDefaultCliVersion = sinon .stub(features, "getDefaultCliVersion") .resolves({ cliVersion: "2.20.1", tagName: expectedTag }); diff --git a/src/start-proxy.ts b/src/start-proxy.ts index 03bdd7c9d..abc13a77a 100644 --- a/src/start-proxy.ts +++ b/src/start-proxy.ts @@ -12,7 +12,11 @@ import { import * as artifactScanner from "./artifact-scanner"; import { Config } from "./config-utils"; import * as defaults from "./defaults.json"; -import { FeatureEnablement } from "./feature-flags"; +import { + CodeQLDefaultVersionInfo, + Feature, + FeatureEnablement, +} from "./feature-flags"; import { KnownLanguage } from "./languages"; import { Logger } from "./logging"; import { @@ -405,6 +409,14 @@ async function getReleaseByVersion(version: string) { }); } +/** Uses `features` to determine the default CLI version. */ +async function getCliVersionFromFeatures( + features: FeatureEnablement, +): Promise { + const gitHubVersion = await getGitHubVersion(); + return await features.getDefaultCliVersion(gitHubVersion.type); +} + /** * Determines the URL of the proxy release asset that we should download if its not * already in the toolcache, and its version. @@ -420,10 +432,18 @@ export async function getDownloadUrl( const proxyPackage = getProxyPackage(); try { + const useFeaturesToDetermineCLI = await features.getValue( + Feature.StartProxyUseFeaturesRelease, + ); + // Retrieve information about the CLI version we should use. This will be either the linked // version, or the one enabled by FFs. - const gitHubVersion = await getGitHubVersion(); - const versionInfo = await features.getDefaultCliVersion(gitHubVersion.type); + const versionInfo = useFeaturesToDetermineCLI + ? await getCliVersionFromFeatures(features) + : { + cliVersion: defaults.cliVersion, + tagName: defaults.bundleVersion, + }; // Try to retrieve information about the CLI bundle release identified by `versionInfo`. const cliRelease = await getReleaseByVersion(versionInfo.tagName);