mirror of
https://github.com/github/codeql-action.git
synced 2026-04-01 17:22:19 +00:00
Put change behind a FF
This commit is contained in:
5
lib/analyze-action-post.js
generated
5
lib/analyze-action-post.js
generated
@@ -162226,6 +162226,11 @@ var featureConfig = {
|
||||
// cannot be found when interpreting results.
|
||||
minimumVersion: void 0
|
||||
},
|
||||
["start_proxy_remove_unused_registries" /* StartProxyRemoveUnusedRegistries */]: {
|
||||
defaultValue: false,
|
||||
envVar: "CODEQL_ACTION_START_PROXY_REMOVE_UNUSED_REGISTRIES",
|
||||
minimumVersion: void 0
|
||||
},
|
||||
["start_proxy_use_features_release" /* StartProxyUseFeaturesRelease */]: {
|
||||
defaultValue: false,
|
||||
envVar: "CODEQL_ACTION_START_PROXY_USE_FEATURES_RELEASE",
|
||||
|
||||
5
lib/analyze-action.js
generated
5
lib/analyze-action.js
generated
@@ -107986,6 +107986,11 @@ var featureConfig = {
|
||||
// cannot be found when interpreting results.
|
||||
minimumVersion: void 0
|
||||
},
|
||||
["start_proxy_remove_unused_registries" /* StartProxyRemoveUnusedRegistries */]: {
|
||||
defaultValue: false,
|
||||
envVar: "CODEQL_ACTION_START_PROXY_REMOVE_UNUSED_REGISTRIES",
|
||||
minimumVersion: void 0
|
||||
},
|
||||
["start_proxy_use_features_release" /* StartProxyUseFeaturesRelease */]: {
|
||||
defaultValue: false,
|
||||
envVar: "CODEQL_ACTION_START_PROXY_USE_FEATURES_RELEASE",
|
||||
|
||||
5
lib/autobuild-action.js
generated
5
lib/autobuild-action.js
generated
@@ -104275,6 +104275,11 @@ var featureConfig = {
|
||||
// cannot be found when interpreting results.
|
||||
minimumVersion: void 0
|
||||
},
|
||||
["start_proxy_remove_unused_registries" /* StartProxyRemoveUnusedRegistries */]: {
|
||||
defaultValue: false,
|
||||
envVar: "CODEQL_ACTION_START_PROXY_REMOVE_UNUSED_REGISTRIES",
|
||||
minimumVersion: void 0
|
||||
},
|
||||
["start_proxy_use_features_release" /* StartProxyUseFeaturesRelease */]: {
|
||||
defaultValue: false,
|
||||
envVar: "CODEQL_ACTION_START_PROXY_USE_FEATURES_RELEASE",
|
||||
|
||||
5
lib/init-action-post.js
generated
5
lib/init-action-post.js
generated
@@ -165723,6 +165723,11 @@ var featureConfig = {
|
||||
// cannot be found when interpreting results.
|
||||
minimumVersion: void 0
|
||||
},
|
||||
["start_proxy_remove_unused_registries" /* StartProxyRemoveUnusedRegistries */]: {
|
||||
defaultValue: false,
|
||||
envVar: "CODEQL_ACTION_START_PROXY_REMOVE_UNUSED_REGISTRIES",
|
||||
minimumVersion: void 0
|
||||
},
|
||||
["start_proxy_use_features_release" /* StartProxyUseFeaturesRelease */]: {
|
||||
defaultValue: false,
|
||||
envVar: "CODEQL_ACTION_START_PROXY_USE_FEATURES_RELEASE",
|
||||
|
||||
5
lib/init-action.js
generated
5
lib/init-action.js
generated
@@ -105521,6 +105521,11 @@ var featureConfig = {
|
||||
// cannot be found when interpreting results.
|
||||
minimumVersion: void 0
|
||||
},
|
||||
["start_proxy_remove_unused_registries" /* StartProxyRemoveUnusedRegistries */]: {
|
||||
defaultValue: false,
|
||||
envVar: "CODEQL_ACTION_START_PROXY_REMOVE_UNUSED_REGISTRIES",
|
||||
minimumVersion: void 0
|
||||
},
|
||||
["start_proxy_use_features_release" /* StartProxyUseFeaturesRelease */]: {
|
||||
defaultValue: false,
|
||||
envVar: "CODEQL_ACTION_START_PROXY_USE_FEATURES_RELEASE",
|
||||
|
||||
5
lib/resolve-environment-action.js
generated
5
lib/resolve-environment-action.js
generated
@@ -104266,6 +104266,11 @@ var featureConfig = {
|
||||
// cannot be found when interpreting results.
|
||||
minimumVersion: void 0
|
||||
},
|
||||
["start_proxy_remove_unused_registries" /* StartProxyRemoveUnusedRegistries */]: {
|
||||
defaultValue: false,
|
||||
envVar: "CODEQL_ACTION_START_PROXY_REMOVE_UNUSED_REGISTRIES",
|
||||
minimumVersion: void 0
|
||||
},
|
||||
["start_proxy_use_features_release" /* StartProxyUseFeaturesRelease */]: {
|
||||
defaultValue: false,
|
||||
envVar: "CODEQL_ACTION_START_PROXY_USE_FEATURES_RELEASE",
|
||||
|
||||
5
lib/setup-codeql-action.js
generated
5
lib/setup-codeql-action.js
generated
@@ -104163,6 +104163,11 @@ var featureConfig = {
|
||||
// cannot be found when interpreting results.
|
||||
minimumVersion: void 0
|
||||
},
|
||||
["start_proxy_remove_unused_registries" /* StartProxyRemoveUnusedRegistries */]: {
|
||||
defaultValue: false,
|
||||
envVar: "CODEQL_ACTION_START_PROXY_REMOVE_UNUSED_REGISTRIES",
|
||||
minimumVersion: void 0
|
||||
},
|
||||
["start_proxy_use_features_release" /* StartProxyUseFeaturesRelease */]: {
|
||||
defaultValue: false,
|
||||
envVar: "CODEQL_ACTION_START_PROXY_USE_FEATURES_RELEASE",
|
||||
|
||||
5
lib/start-proxy-action-post.js
generated
5
lib/start-proxy-action-post.js
generated
@@ -161632,6 +161632,11 @@ var featureConfig = {
|
||||
// cannot be found when interpreting results.
|
||||
minimumVersion: void 0
|
||||
},
|
||||
["start_proxy_remove_unused_registries" /* StartProxyRemoveUnusedRegistries */]: {
|
||||
defaultValue: false,
|
||||
envVar: "CODEQL_ACTION_START_PROXY_REMOVE_UNUSED_REGISTRIES",
|
||||
minimumVersion: void 0
|
||||
},
|
||||
["start_proxy_use_features_release" /* StartProxyUseFeaturesRelease */]: {
|
||||
defaultValue: false,
|
||||
envVar: "CODEQL_ACTION_START_PROXY_USE_FEATURES_RELEASE",
|
||||
|
||||
25
lib/start-proxy-action.js
generated
25
lib/start-proxy-action.js
generated
@@ -120955,6 +120955,11 @@ var featureConfig = {
|
||||
// cannot be found when interpreting results.
|
||||
minimumVersion: void 0
|
||||
},
|
||||
["start_proxy_remove_unused_registries" /* StartProxyRemoveUnusedRegistries */]: {
|
||||
defaultValue: false,
|
||||
envVar: "CODEQL_ACTION_START_PROXY_REMOVE_UNUSED_REGISTRIES",
|
||||
minimumVersion: void 0
|
||||
},
|
||||
["start_proxy_use_features_release" /* StartProxyUseFeaturesRelease */]: {
|
||||
defaultValue: false,
|
||||
envVar: "CODEQL_ACTION_START_PROXY_USE_FEATURES_RELEASE",
|
||||
@@ -121739,6 +121744,15 @@ function isPAT(value) {
|
||||
]);
|
||||
}
|
||||
var LANGUAGE_TO_REGISTRY_TYPE = {
|
||||
java: ["maven_repository"],
|
||||
csharp: ["nuget_feed"],
|
||||
javascript: ["npm_registry"],
|
||||
python: ["python_index"],
|
||||
ruby: ["rubygems_server"],
|
||||
rust: ["cargo_registry"],
|
||||
go: ["goproxy_server", "git_source"]
|
||||
};
|
||||
var NEW_LANGUAGE_TO_REGISTRY_TYPE = {
|
||||
actions: [],
|
||||
java: ["maven_repository"],
|
||||
csharp: ["nuget_feed"],
|
||||
@@ -121765,8 +121779,9 @@ function getRegistryAddress(registry) {
|
||||
);
|
||||
}
|
||||
}
|
||||
function getCredentials(logger, registrySecrets, registriesCredentials, language) {
|
||||
const registryTypeForLanguage = language ? LANGUAGE_TO_REGISTRY_TYPE[language] : void 0;
|
||||
function getCredentials(logger, registrySecrets, registriesCredentials, language, skipUnusedRegistries = false) {
|
||||
const registryMapping = skipUnusedRegistries ? NEW_LANGUAGE_TO_REGISTRY_TYPE : LANGUAGE_TO_REGISTRY_TYPE;
|
||||
const registryTypeForLanguage = language ? registryMapping[language] : void 0;
|
||||
let credentialsStr;
|
||||
if (registriesCredentials !== void 0) {
|
||||
logger.info(`Using registries_credentials input.`);
|
||||
@@ -122263,11 +122278,15 @@ async function run(startedAt) {
|
||||
);
|
||||
const languageInput = getOptionalInput("language");
|
||||
language = languageInput ? parseLanguage(languageInput) : void 0;
|
||||
const skipUnusedRegistries = await features.getValue(
|
||||
"start_proxy_remove_unused_registries" /* StartProxyRemoveUnusedRegistries */
|
||||
);
|
||||
const credentials = getCredentials(
|
||||
logger,
|
||||
getOptionalInput("registry_secrets"),
|
||||
getOptionalInput("registries_credentials"),
|
||||
language
|
||||
language,
|
||||
skipUnusedRegistries
|
||||
);
|
||||
if (credentials.length === 0) {
|
||||
logger.info("No credentials found, skipping proxy setup.");
|
||||
|
||||
5
lib/upload-lib.js
generated
5
lib/upload-lib.js
generated
@@ -107434,6 +107434,11 @@ var featureConfig = {
|
||||
// cannot be found when interpreting results.
|
||||
minimumVersion: void 0
|
||||
},
|
||||
["start_proxy_remove_unused_registries" /* StartProxyRemoveUnusedRegistries */]: {
|
||||
defaultValue: false,
|
||||
envVar: "CODEQL_ACTION_START_PROXY_REMOVE_UNUSED_REGISTRIES",
|
||||
minimumVersion: void 0
|
||||
},
|
||||
["start_proxy_use_features_release" /* StartProxyUseFeaturesRelease */]: {
|
||||
defaultValue: false,
|
||||
envVar: "CODEQL_ACTION_START_PROXY_USE_FEATURES_RELEASE",
|
||||
|
||||
5
lib/upload-sarif-action-post.js
generated
5
lib/upload-sarif-action-post.js
generated
@@ -161794,6 +161794,11 @@ var featureConfig = {
|
||||
// cannot be found when interpreting results.
|
||||
minimumVersion: void 0
|
||||
},
|
||||
["start_proxy_remove_unused_registries" /* StartProxyRemoveUnusedRegistries */]: {
|
||||
defaultValue: false,
|
||||
envVar: "CODEQL_ACTION_START_PROXY_REMOVE_UNUSED_REGISTRIES",
|
||||
minimumVersion: void 0
|
||||
},
|
||||
["start_proxy_use_features_release" /* StartProxyUseFeaturesRelease */]: {
|
||||
defaultValue: false,
|
||||
envVar: "CODEQL_ACTION_START_PROXY_USE_FEATURES_RELEASE",
|
||||
|
||||
5
lib/upload-sarif-action.js
generated
5
lib/upload-sarif-action.js
generated
@@ -107147,6 +107147,11 @@ var featureConfig = {
|
||||
// cannot be found when interpreting results.
|
||||
minimumVersion: void 0
|
||||
},
|
||||
["start_proxy_remove_unused_registries" /* StartProxyRemoveUnusedRegistries */]: {
|
||||
defaultValue: false,
|
||||
envVar: "CODEQL_ACTION_START_PROXY_REMOVE_UNUSED_REGISTRIES",
|
||||
minimumVersion: void 0
|
||||
},
|
||||
["start_proxy_use_features_release" /* StartProxyUseFeaturesRelease */]: {
|
||||
defaultValue: false,
|
||||
envVar: "CODEQL_ACTION_START_PROXY_USE_FEATURES_RELEASE",
|
||||
|
||||
@@ -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",
|
||||
StartProxyRemoveUnusedRegistries = "start_proxy_remove_unused_registries",
|
||||
StartProxyUseFeaturesRelease = "start_proxy_use_features_release",
|
||||
UploadOverlayDbToApi = "upload_overlay_db_to_api",
|
||||
UseRepositoryProperties = "use_repository_properties_v2",
|
||||
@@ -328,6 +329,11 @@ export const featureConfig = {
|
||||
// cannot be found when interpreting results.
|
||||
minimumVersion: undefined,
|
||||
},
|
||||
[Feature.StartProxyRemoveUnusedRegistries]: {
|
||||
defaultValue: false,
|
||||
envVar: "CODEQL_ACTION_START_PROXY_REMOVE_UNUSED_REGISTRIES",
|
||||
minimumVersion: undefined,
|
||||
},
|
||||
[Feature.StartProxyUseFeaturesRelease]: {
|
||||
defaultValue: false,
|
||||
envVar: "CODEQL_ACTION_START_PROXY_USE_FEATURES_RELEASE",
|
||||
|
||||
@@ -5,7 +5,7 @@ import * as core from "@actions/core";
|
||||
|
||||
import * as actionsUtil from "./actions-util";
|
||||
import { getGitHubVersion } from "./api-client";
|
||||
import { FeatureEnablement, initFeatures } from "./feature-flags";
|
||||
import { Feature, FeatureEnablement, initFeatures } from "./feature-flags";
|
||||
import { KnownLanguage } from "./languages";
|
||||
import { getActionsLogger, Logger } from "./logging";
|
||||
import { getRepositoryNwo } from "./repository";
|
||||
@@ -58,12 +58,18 @@ async function run(startedAt: Date) {
|
||||
const languageInput = actionsUtil.getOptionalInput("language");
|
||||
language = languageInput ? parseLanguage(languageInput) : undefined;
|
||||
|
||||
// Query the FF for whether we should use the reduced registry mapping.
|
||||
const skipUnusedRegistries = await features.getValue(
|
||||
Feature.StartProxyRemoveUnusedRegistries,
|
||||
);
|
||||
|
||||
// Get the registry configurations from one of the inputs.
|
||||
const credentials = getCredentials(
|
||||
logger,
|
||||
actionsUtil.getOptionalInput("registry_secrets"),
|
||||
actionsUtil.getOptionalInput("registries_credentials"),
|
||||
language,
|
||||
skipUnusedRegistries,
|
||||
);
|
||||
|
||||
if (credentials.length === 0) {
|
||||
|
||||
@@ -328,6 +328,32 @@ test("getCredentials logs a warning when a PAT is used without a username", asyn
|
||||
]);
|
||||
});
|
||||
|
||||
test("getCredentials returns all credentials for Actions when using LANGUAGE_TO_REGISTRY_TYPE", async (t) => {
|
||||
const credentialsInput = toEncodedJSON(mixedCredentials);
|
||||
|
||||
const credentials = startProxyExports.getCredentials(
|
||||
getRunnerLogger(true),
|
||||
undefined,
|
||||
credentialsInput,
|
||||
KnownLanguage.actions,
|
||||
false,
|
||||
);
|
||||
t.is(credentials.length, mixedCredentials.length);
|
||||
});
|
||||
|
||||
test("getCredentials returns no credentials for Actions when using NEW_LANGUAGE_TO_REGISTRY_TYPE", async (t) => {
|
||||
const credentialsInput = toEncodedJSON(mixedCredentials);
|
||||
|
||||
const credentials = startProxyExports.getCredentials(
|
||||
getRunnerLogger(true),
|
||||
undefined,
|
||||
credentialsInput,
|
||||
KnownLanguage.actions,
|
||||
true,
|
||||
);
|
||||
t.deepEqual(credentials, []);
|
||||
});
|
||||
|
||||
test("parseLanguage", async (t) => {
|
||||
// Exact matches
|
||||
t.deepEqual(parseLanguage("csharp"), KnownLanguage.csharp);
|
||||
|
||||
@@ -224,7 +224,19 @@ function isPAT(value: string) {
|
||||
]);
|
||||
}
|
||||
|
||||
const LANGUAGE_TO_REGISTRY_TYPE: Partial<Record<KnownLanguage, string[]>> = {
|
||||
type RegistryMapping = Partial<Record<KnownLanguage, string[]>>;
|
||||
|
||||
const LANGUAGE_TO_REGISTRY_TYPE: RegistryMapping = {
|
||||
java: ["maven_repository"],
|
||||
csharp: ["nuget_feed"],
|
||||
javascript: ["npm_registry"],
|
||||
python: ["python_index"],
|
||||
ruby: ["rubygems_server"],
|
||||
rust: ["cargo_registry"],
|
||||
go: ["goproxy_server", "git_source"],
|
||||
} as const;
|
||||
|
||||
const NEW_LANGUAGE_TO_REGISTRY_TYPE: RegistryMapping = {
|
||||
actions: [],
|
||||
java: ["maven_repository"],
|
||||
csharp: ["nuget_feed"],
|
||||
@@ -268,9 +280,13 @@ export function getCredentials(
|
||||
registrySecrets: string | undefined,
|
||||
registriesCredentials: string | undefined,
|
||||
language: KnownLanguage | undefined,
|
||||
skipUnusedRegistries: boolean = false,
|
||||
): Credential[] {
|
||||
const registryMapping = skipUnusedRegistries
|
||||
? NEW_LANGUAGE_TO_REGISTRY_TYPE
|
||||
: LANGUAGE_TO_REGISTRY_TYPE;
|
||||
const registryTypeForLanguage = language
|
||||
? LANGUAGE_TO_REGISTRY_TYPE[language]
|
||||
? registryMapping[language]
|
||||
: undefined;
|
||||
|
||||
let credentialsStr: string;
|
||||
|
||||
Reference in New Issue
Block a user