Merge branch 'main' into henrymercer/bump-minimum-codeql-version
This commit is contained in:
commit
fed45865ba
234 changed files with 26797 additions and 28982 deletions
|
|
@ -4,7 +4,11 @@ import * as path from "path";
|
|||
import * as semver from "semver";
|
||||
|
||||
import { getApiClient } from "./api-client";
|
||||
import { CodeQL } from "./codeql";
|
||||
import {
|
||||
CODEQL_VERSION_BUNDLE_SEMANTICALLY_VERSIONED,
|
||||
CODEQL_VERSION_NEW_ANALYSIS_SUMMARY,
|
||||
CodeQL,
|
||||
} from "./codeql";
|
||||
import * as defaults from "./defaults.json";
|
||||
import { Logger } from "./logging";
|
||||
import { RepositoryNwo } from "./repository";
|
||||
|
|
@ -13,20 +17,11 @@ import * as util from "./util";
|
|||
const DEFAULT_VERSION_FEATURE_FLAG_PREFIX = "default_codeql_version_";
|
||||
const DEFAULT_VERSION_FEATURE_FLAG_SUFFIX = "_enabled";
|
||||
|
||||
export type CodeQLDefaultVersionInfo =
|
||||
| {
|
||||
cliVersion: string;
|
||||
toolsFeatureFlagsValid?: boolean;
|
||||
variant: util.GitHubVariant.DOTCOM;
|
||||
}
|
||||
| {
|
||||
cliVersion: string;
|
||||
tagName: string;
|
||||
variant:
|
||||
| util.GitHubVariant.GHAE
|
||||
| util.GitHubVariant.GHES
|
||||
| util.GitHubVariant.GHE_DOTCOM;
|
||||
};
|
||||
export interface CodeQLDefaultVersionInfo {
|
||||
cliVersion: string;
|
||||
tagName: string;
|
||||
toolsFeatureFlagsValid?: boolean;
|
||||
}
|
||||
|
||||
export interface FeatureEnablement {
|
||||
/** Gets the default version of the CodeQL tools. */
|
||||
|
|
@ -39,11 +34,13 @@ export interface FeatureEnablement {
|
|||
export enum Feature {
|
||||
CliConfigFileEnabled = "cli_config_file_enabled",
|
||||
DisableKotlinAnalysisEnabled = "disable_kotlin_analysis_enabled",
|
||||
ExportCodeScanningConfigEnabled = "export_code_scanning_config_enabled",
|
||||
DisablePythonDependencyInstallationEnabled = "disable_python_dependency_installation_enabled",
|
||||
ExportDiagnosticsEnabled = "export_diagnostics_enabled",
|
||||
MlPoweredQueriesEnabled = "ml_powered_queries_enabled",
|
||||
NewAnalysisSummaryEnabled = "new_analysis_summary_enabled",
|
||||
QaTelemetryEnabled = "qa_telemetry_enabled",
|
||||
ScalingReservedRam = "scaling_reserved_ram",
|
||||
UploadFailedSarifEnabled = "upload_failed_sarif_enabled",
|
||||
DisablePythonDependencyInstallation = "disable_python_dependency_installation",
|
||||
}
|
||||
|
||||
export const featureConfig: Record<
|
||||
|
|
@ -60,28 +57,37 @@ export const featureConfig: Record<
|
|||
minimumVersion: "2.11.6",
|
||||
defaultValue: true,
|
||||
},
|
||||
[Feature.ExportCodeScanningConfigEnabled]: {
|
||||
envVar: "CODEQL_ACTION_EXPORT_CODE_SCANNING_CONFIG",
|
||||
minimumVersion: "2.12.3",
|
||||
defaultValue: true,
|
||||
},
|
||||
[Feature.ExportDiagnosticsEnabled]: {
|
||||
envVar: "CODEQL_ACTION_EXPORT_DIAGNOSTICS",
|
||||
minimumVersion: "2.12.4",
|
||||
defaultValue: true,
|
||||
},
|
||||
|
||||
[Feature.MlPoweredQueriesEnabled]: {
|
||||
envVar: "CODEQL_ML_POWERED_QUERIES",
|
||||
minimumVersion: undefined,
|
||||
defaultValue: false,
|
||||
},
|
||||
[Feature.NewAnalysisSummaryEnabled]: {
|
||||
envVar: "CODEQL_ACTION_NEW_ANALYSIS_SUMMARY",
|
||||
minimumVersion: CODEQL_VERSION_NEW_ANALYSIS_SUMMARY,
|
||||
defaultValue: false,
|
||||
},
|
||||
[Feature.QaTelemetryEnabled]: {
|
||||
envVar: "CODEQL_ACTION_QA_TELEMETRY",
|
||||
minimumVersion: undefined,
|
||||
defaultValue: false,
|
||||
},
|
||||
[Feature.ScalingReservedRam]: {
|
||||
envVar: "CODEQL_ACTION_SCALING_RESERVED_RAM",
|
||||
minimumVersion: undefined,
|
||||
defaultValue: false,
|
||||
},
|
||||
[Feature.UploadFailedSarifEnabled]: {
|
||||
envVar: "CODEQL_ACTION_UPLOAD_FAILED_SARIF",
|
||||
minimumVersion: "2.11.3",
|
||||
defaultValue: true,
|
||||
},
|
||||
[Feature.DisablePythonDependencyInstallation]: {
|
||||
[Feature.DisablePythonDependencyInstallationEnabled]: {
|
||||
envVar: "CODEQL_ACTION_DISABLE_PYTHON_DEPENDENCY_INSTALLATION",
|
||||
// Although the python extractor only started supporting not extracting installed
|
||||
// dependencies in 2.13.1, the init-action can still benefit from not installing
|
||||
|
|
@ -251,33 +257,27 @@ class GitHubFeatureFlags {
|
|||
variant: util.GitHubVariant
|
||||
): Promise<CodeQLDefaultVersionInfo> {
|
||||
if (variant === util.GitHubVariant.DOTCOM) {
|
||||
const defaultDotComCliVersion = await this.getDefaultDotcomCliVersion();
|
||||
return {
|
||||
cliVersion: defaultDotComCliVersion.version,
|
||||
toolsFeatureFlagsValid: this.hasAccessedRemoteFeatureFlags
|
||||
? defaultDotComCliVersion.toolsFeatureFlagsValid
|
||||
: undefined,
|
||||
variant,
|
||||
};
|
||||
return await this.getDefaultDotcomCliVersion();
|
||||
}
|
||||
return {
|
||||
cliVersion: defaults.cliVersion,
|
||||
tagName: defaults.bundleVersion,
|
||||
variant,
|
||||
};
|
||||
}
|
||||
|
||||
async getDefaultDotcomCliVersion(): Promise<{
|
||||
version: string;
|
||||
toolsFeatureFlagsValid: boolean | undefined;
|
||||
}> {
|
||||
async getDefaultDotcomCliVersion(): Promise<CodeQLDefaultVersionInfo> {
|
||||
const response = await this.getAllFeatures();
|
||||
|
||||
const enabledFeatureFlagCliVersions = Object.entries(response)
|
||||
.map(([f, isEnabled]) =>
|
||||
isEnabled ? this.getCliVersionFromFeatureFlag(f) : undefined
|
||||
)
|
||||
.filter((f) => f !== undefined)
|
||||
.filter(
|
||||
(f) =>
|
||||
f !== undefined &&
|
||||
// Only consider versions that have semantically versioned bundles.
|
||||
semver.gte(f, CODEQL_VERSION_BUNDLE_SEMANTICALLY_VERSIONED)
|
||||
)
|
||||
.map((f) => f as string);
|
||||
|
||||
if (enabledFeatureFlagCliVersions.length === 0) {
|
||||
|
|
@ -295,12 +295,14 @@ class GitHubFeatureFlags {
|
|||
"Feature flags do not specify a default CLI version. Falling back to the CLI version " +
|
||||
`shipped with the Action. This is ${defaults.cliVersion}.`
|
||||
);
|
||||
return {
|
||||
version: defaults.cliVersion,
|
||||
toolsFeatureFlagsValid: this.hasAccessedRemoteFeatureFlags
|
||||
? false
|
||||
: undefined,
|
||||
const result: CodeQLDefaultVersionInfo = {
|
||||
cliVersion: defaults.cliVersion,
|
||||
tagName: defaults.bundleVersion,
|
||||
};
|
||||
if (this.hasAccessedRemoteFeatureFlags) {
|
||||
result.toolsFeatureFlagsValid = false;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
const maxCliVersion = enabledFeatureFlagCliVersions.reduce(
|
||||
|
|
@ -311,7 +313,11 @@ class GitHubFeatureFlags {
|
|||
this.logger.debug(
|
||||
`Derived default CLI version of ${maxCliVersion} from feature flags.`
|
||||
);
|
||||
return { version: maxCliVersion, toolsFeatureFlagsValid: true };
|
||||
return {
|
||||
cliVersion: maxCliVersion,
|
||||
tagName: `codeql-bundle-v${maxCliVersion}`,
|
||||
toolsFeatureFlagsValid: true,
|
||||
};
|
||||
}
|
||||
|
||||
async getValue(feature: Feature): Promise<boolean | undefined> {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue