Compare commits

...

6 Commits

Author SHA1 Message Date
Angela P Wen
17573ee1cc Merge pull request #1534 from github/update-v2.2.4-40babc141
Merge main into releases/v2
2023-02-10 10:20:44 -08:00
github-actions[bot]
b6975b4b1a Update changelog for v2.2.4 2023-02-10 17:42:05 +00:00
Angela P Wen
40babc141f Tools telemetry: accurately report when feature flags were inaccessible (#1532)
* Cache whether feature flags are accessible

* Small comment fixup from linting change
2023-02-10 09:06:43 -08:00
Chuan-kai Lin
7ba5ed7eed Merge pull request #1531 from github/mergeback/v2.2.3-to-main-8775e868
Mergeback v2.2.3 refs/heads/releases/v2 into main
2023-02-08 13:06:40 -08:00
github-actions[bot]
21f3020df6 Update checked-in dependencies 2023-02-08 20:40:37 +00:00
github-actions[bot]
b872c5adfd Update changelog and version after v2.2.3 2023-02-08 20:37:07 +00:00
9 changed files with 37 additions and 16 deletions

View File

@@ -1,5 +1,9 @@
# CodeQL Action Changelog # CodeQL Action Changelog
## 2.2.4 - 10 Feb 2023
No user facing changes.
## 2.2.3 - 08 Feb 2023 ## 2.2.3 - 08 Feb 2023
- Update default CodeQL bundle version to 2.12.2. [#1518](https://github.com/github/codeql-action/pull/1518) - Update default CodeQL bundle version to 2.12.2. [#1518](https://github.com/github/codeql-action/pull/1518)

14
lib/feature-flags.js generated
View File

@@ -118,7 +118,7 @@ class GitHubFeatureFlags {
this.repositoryNwo = repositoryNwo; this.repositoryNwo = repositoryNwo;
this.featureFlagsFile = featureFlagsFile; this.featureFlagsFile = featureFlagsFile;
this.logger = logger; this.logger = logger;
/**/ this.hasAccessedRemoteFeatureFlags = false; // Not accessed by default.
} }
getCliVersionFromFeatureFlag(f) { getCliVersionFromFeatureFlag(f) {
if (!f.startsWith(DEFAULT_VERSION_FEATURE_FLAG_PREFIX) || if (!f.startsWith(DEFAULT_VERSION_FEATURE_FLAG_PREFIX) ||
@@ -139,7 +139,9 @@ class GitHubFeatureFlags {
const defaultDotComCliVersion = await this.getDefaultDotcomCliVersion(); const defaultDotComCliVersion = await this.getDefaultDotcomCliVersion();
return { return {
cliVersion: defaultDotComCliVersion.version, cliVersion: defaultDotComCliVersion.version,
toolsFeatureFlagsValid: defaultDotComCliVersion.toolsFeatureFlagsValid, toolsFeatureFlagsValid: this.hasAccessedRemoteFeatureFlags
? defaultDotComCliVersion.toolsFeatureFlagsValid
: undefined,
variant, variant,
}; };
} }
@@ -170,7 +172,9 @@ class GitHubFeatureFlags {
`shipped with the Action. This is ${defaults.cliVersion}.`); `shipped with the Action. This is ${defaults.cliVersion}.`);
return { return {
version: defaults.cliVersion, version: defaults.cliVersion,
toolsFeatureFlagsValid: false, toolsFeatureFlagsValid: this.hasAccessedRemoteFeatureFlags
? false
: undefined,
}; };
} }
const maxCliVersion = enabledFeatureFlagCliVersions.reduce((maxVersion, currentVersion) => currentVersion > maxVersion ? currentVersion : maxVersion, enabledFeatureFlagCliVersions[0]); const maxCliVersion = enabledFeatureFlagCliVersions.reduce((maxVersion, currentVersion) => currentVersion > maxVersion ? currentVersion : maxVersion, enabledFeatureFlagCliVersions[0]);
@@ -237,6 +241,7 @@ class GitHubFeatureFlags {
// Do nothing when not running against github.com // Do nothing when not running against github.com
if (this.gitHubVersion.type !== util.GitHubVariant.DOTCOM) { if (this.gitHubVersion.type !== util.GitHubVariant.DOTCOM) {
this.logger.debug("Not running against github.com. Disabling all toggleable features."); this.logger.debug("Not running against github.com. Disabling all toggleable features.");
this.hasAccessedRemoteFeatureFlags = false;
return {}; return {};
} }
try { try {
@@ -247,6 +252,7 @@ class GitHubFeatureFlags {
const remoteFlags = response.data; const remoteFlags = response.data;
this.logger.debug("Loaded the following default values for the feature flags from the Code Scanning API: " + this.logger.debug("Loaded the following default values for the feature flags from the Code Scanning API: " +
`${JSON.stringify(remoteFlags)}`); `${JSON.stringify(remoteFlags)}`);
this.hasAccessedRemoteFeatureFlags = true;
return remoteFlags; return remoteFlags;
} }
catch (e) { catch (e) {
@@ -255,6 +261,7 @@ class GitHubFeatureFlags {
"As a result, it will not be opted into any experimental features. " + "As a result, it will not be opted into any experimental features. " +
"This could be because the Action is running on a pull request from a fork. If not, " + "This could be because the Action is running on a pull request from a fork. If not, " +
`please ensure the Action has the 'security-events: write' permission. Details: ${e}`); `please ensure the Action has the 'security-events: write' permission. Details: ${e}`);
this.hasAccessedRemoteFeatureFlags = false;
return {}; return {};
} }
else { else {
@@ -265,7 +272,6 @@ class GitHubFeatureFlags {
throw new Error(`Encountered an error while trying to determine feature enablement: ${e}`); throw new Error(`Encountered an error while trying to determine feature enablement: ${e}`);
} }
} }
return {};
} }
} }
//# sourceMappingURL=feature-flags.js.map //# sourceMappingURL=feature-flags.js.map

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

2
node_modules/.package-lock.json generated vendored
View File

@@ -1,6 +1,6 @@
{ {
"name": "codeql", "name": "codeql",
"version": "2.2.3", "version": "2.2.4",
"lockfileVersion": 3, "lockfileVersion": 3,
"requires": true, "requires": true,
"packages": { "packages": {

4
package-lock.json generated
View File

@@ -1,12 +1,12 @@
{ {
"name": "codeql", "name": "codeql",
"version": "2.2.3", "version": "2.2.4",
"lockfileVersion": 3, "lockfileVersion": 3,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "codeql", "name": "codeql",
"version": "2.2.3", "version": "2.2.4",
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"@actions/artifact": "^1.1.0", "@actions/artifact": "^1.1.0",

View File

@@ -1,6 +1,6 @@
{ {
"name": "codeql", "name": "codeql",
"version": "2.2.3", "version": "2.2.4",
"private": true, "private": true,
"description": "CodeQL action", "description": "CodeQL action",
"scripts": { "scripts": {

View File

@@ -153,13 +153,17 @@ export class Features implements FeatureEnablement {
class GitHubFeatureFlags implements FeatureEnablement { class GitHubFeatureFlags implements FeatureEnablement {
private cachedApiResponse: GitHubFeatureFlagsApiResponse | undefined; private cachedApiResponse: GitHubFeatureFlagsApiResponse | undefined;
// We cache whether the feature flags were accessed or not in order to accurately report whether flags were
// incorrectly configured vs. inaccessible in our telemetry.
private hasAccessedRemoteFeatureFlags: boolean;
constructor( constructor(
private readonly gitHubVersion: util.GitHubVersion, private readonly gitHubVersion: util.GitHubVersion,
private readonly repositoryNwo: RepositoryNwo, private readonly repositoryNwo: RepositoryNwo,
private readonly featureFlagsFile: string, private readonly featureFlagsFile: string,
private readonly logger: Logger private readonly logger: Logger
) { ) {
/**/ this.hasAccessedRemoteFeatureFlags = false; // Not accessed by default.
} }
private getCliVersionFromFeatureFlag(f: string): string | undefined { private getCliVersionFromFeatureFlag(f: string): string | undefined {
@@ -192,7 +196,9 @@ class GitHubFeatureFlags implements FeatureEnablement {
const defaultDotComCliVersion = await this.getDefaultDotcomCliVersion(); const defaultDotComCliVersion = await this.getDefaultDotcomCliVersion();
return { return {
cliVersion: defaultDotComCliVersion.version, cliVersion: defaultDotComCliVersion.version,
toolsFeatureFlagsValid: defaultDotComCliVersion.toolsFeatureFlagsValid, toolsFeatureFlagsValid: this.hasAccessedRemoteFeatureFlags
? defaultDotComCliVersion.toolsFeatureFlagsValid
: undefined,
variant, variant,
}; };
} }
@@ -205,7 +211,7 @@ class GitHubFeatureFlags implements FeatureEnablement {
async getDefaultDotcomCliVersion(): Promise<{ async getDefaultDotcomCliVersion(): Promise<{
version: string; version: string;
toolsFeatureFlagsValid: boolean; toolsFeatureFlagsValid: boolean | undefined;
}> { }> {
const response = await this.getAllFeatures(); const response = await this.getAllFeatures();
@@ -233,7 +239,9 @@ class GitHubFeatureFlags implements FeatureEnablement {
); );
return { return {
version: defaults.cliVersion, version: defaults.cliVersion,
toolsFeatureFlagsValid: false, toolsFeatureFlagsValid: this.hasAccessedRemoteFeatureFlags
? false
: undefined,
}; };
} }
@@ -331,6 +339,7 @@ class GitHubFeatureFlags implements FeatureEnablement {
this.logger.debug( this.logger.debug(
"Not running against github.com. Disabling all toggleable features." "Not running against github.com. Disabling all toggleable features."
); );
this.hasAccessedRemoteFeatureFlags = false;
return {}; return {};
} }
try { try {
@@ -346,6 +355,7 @@ class GitHubFeatureFlags implements FeatureEnablement {
"Loaded the following default values for the feature flags from the Code Scanning API: " + "Loaded the following default values for the feature flags from the Code Scanning API: " +
`${JSON.stringify(remoteFlags)}` `${JSON.stringify(remoteFlags)}`
); );
this.hasAccessedRemoteFeatureFlags = true;
return remoteFlags; return remoteFlags;
} catch (e) { } catch (e) {
if (util.isHTTPError(e) && e.status === 403) { if (util.isHTTPError(e) && e.status === 403) {
@@ -355,6 +365,7 @@ class GitHubFeatureFlags implements FeatureEnablement {
"This could be because the Action is running on a pull request from a fork. If not, " + "This could be because the Action is running on a pull request from a fork. If not, " +
`please ensure the Action has the 'security-events: write' permission. Details: ${e}` `please ensure the Action has the 'security-events: write' permission. Details: ${e}`
); );
this.hasAccessedRemoteFeatureFlags = false;
return {}; return {};
} else { } else {
// Some features, such as `ml_powered_queries_enabled` affect the produced alerts. // Some features, such as `ml_powered_queries_enabled` affect the produced alerts.
@@ -366,6 +377,5 @@ class GitHubFeatureFlags implements FeatureEnablement {
); );
} }
} }
return {};
} }
} }

View File

@@ -86,7 +86,8 @@ interface InitWithConfigStatusReport extends InitStatusReport {
interface InitToolsDownloadFields { interface InitToolsDownloadFields {
/** Time taken to download the bundle, in milliseconds. */ /** Time taken to download the bundle, in milliseconds. */
tools_download_duration_ms?: number; tools_download_duration_ms?: number;
/** Whether the relevant tools dotcom feature flags have been misconfigured. /**
* Whether the relevant tools dotcom feature flags have been misconfigured.
* Only populated if we attempt to determine the default version based on the dotcom feature flags. */ * Only populated if we attempt to determine the default version based on the dotcom feature flags. */
tools_feature_flags_valid?: boolean; tools_feature_flags_valid?: boolean;
} }