Remove feature flag for analysis summary v2

This commit is contained in:
Henry Mercer 2023-10-25 17:24:22 +01:00
parent edb8265ab8
commit 2cbabeaa72
12 changed files with 91 additions and 49 deletions

2
lib/analyze.js generated
View file

@ -232,7 +232,7 @@ async function runQueries(sarifFolder, memoryFlag, addSnippetsFlag, threadsFlag,
}
statusReport["event_reports"].push(perQueryAlertCountEventReport);
}
if (!(await features.getValue(feature_flags_1.Feature.AnalysisSummaryV2Enabled, codeql))) {
if (!(await util.codeQlVersionAbove(codeql, codeql_1.CODEQL_VERSION_ANALYSIS_SUMMARY_V2))) {
await runPrintLinesOfCode(language);
}
}

File diff suppressed because one or more lines are too long

16
lib/codeql.js generated
View file

@ -23,12 +23,13 @@ var __importStar = (this && this.__importStar) || function (mod) {
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.getGeneratedCodeScanningConfigPath = exports.getTrapCachingExtractorConfigArgsForLang = exports.getTrapCachingExtractorConfigArgs = exports.getExtraOptions = exports.getCodeQLForCmd = exports.getCodeQLForTesting = exports.getCachedCodeQL = exports.setCodeQL = exports.getCodeQL = exports.setupCodeQL = exports.CODEQL_VERSION_LANGUAGE_ALIASING = exports.CODEQL_VERSION_LANGUAGE_BASELINE_CONFIG = exports.CODEQL_VERSION_RESOLVE_ENVIRONMENT = exports.CODEQL_VERSION_DIAGNOSTICS_EXPORT_FIXED = exports.CODEQL_VERSION_BETTER_NO_CODE_ERROR_MESSAGE = exports.CODEQL_VERSION_INIT_WITH_QLCONFIG = exports.CODEQL_VERSION_EXPORT_CODE_SCANNING_CONFIG = exports.CODEQL_VERSION_SECURITY_EXPERIMENTAL_SUITE = exports.CommandInvocationError = void 0;
exports.getGeneratedCodeScanningConfigPath = exports.getTrapCachingExtractorConfigArgsForLang = exports.getTrapCachingExtractorConfigArgs = exports.getExtraOptions = exports.getCodeQLForCmd = exports.getCodeQLForTesting = exports.getCachedCodeQL = exports.setCodeQL = exports.getCodeQL = exports.setupCodeQL = exports.CODEQL_VERSION_ANALYSIS_SUMMARY_V2 = exports.CODEQL_VERSION_LANGUAGE_ALIASING = exports.CODEQL_VERSION_LANGUAGE_BASELINE_CONFIG = exports.CODEQL_VERSION_RESOLVE_ENVIRONMENT = exports.CODEQL_VERSION_DIAGNOSTICS_EXPORT_FIXED = exports.CODEQL_VERSION_BETTER_NO_CODE_ERROR_MESSAGE = exports.CODEQL_VERSION_INIT_WITH_QLCONFIG = exports.CODEQL_VERSION_EXPORT_CODE_SCANNING_CONFIG = exports.CODEQL_VERSION_SECURITY_EXPERIMENTAL_SUITE = exports.CommandInvocationError = void 0;
const fs = __importStar(require("fs"));
const path = __importStar(require("path"));
const core = __importStar(require("@actions/core"));
const toolrunner = __importStar(require("@actions/exec/lib/toolrunner"));
const yaml = __importStar(require("js-yaml"));
const semver = __importStar(require("semver"));
const actions_util_1 = require("./actions-util");
const environment_1 = require("./environment");
const feature_flags_1 = require("./feature-flags");
@ -126,6 +127,10 @@ exports.CODEQL_VERSION_LANGUAGE_BASELINE_CONFIG = "2.14.2";
* Versions 2.14.4+ of the CodeQL CLI support language aliasing.
*/
exports.CODEQL_VERSION_LANGUAGE_ALIASING = "2.14.4";
/**
* Versions 2.15.0+ of the CodeQL CLI support new analysis summaries.
*/
exports.CODEQL_VERSION_ANALYSIS_SUMMARY_V2 = "2.15.0";
/**
* Set up CodeQL CLI access.
*
@ -518,10 +523,15 @@ async function getCodeQLForCmd(cmd, checkVersion) {
else if (await util.codeQlVersionAbove(this, "2.12.4")) {
codeqlArgs.push("--no-sarif-include-diagnostics");
}
if (await features.getValue(feature_flags_1.Feature.AnalysisSummaryV2Enabled, this)) {
if (
// Analysis summary v2 links to the status page, so check the GHES version we're running on
// supports the status page.
(config.gitHubVersion.type !== util.GitHubVariant.GHES ||
semver.gte(config.gitHubVersion.version, "3.9.0")) &&
(await util.codeQlVersionAbove(this, exports.CODEQL_VERSION_ANALYSIS_SUMMARY_V2))) {
codeqlArgs.push("--new-analysis-summary");
}
else if (await util.codeQlVersionAbove(this, feature_flags_1.CODEQL_VERSION_ANALYSIS_SUMMARY_V2)) {
else if (await util.codeQlVersionAbove(this, exports.CODEQL_VERSION_ANALYSIS_SUMMARY_V2)) {
codeqlArgs.push("--no-new-analysis-summary");
}
codeqlArgs.push(databasePath);

File diff suppressed because one or more lines are too long

28
lib/codeql.test.js generated
View file

@ -624,30 +624,46 @@ const injectedConfigMacro = ava_1.default.macro({
});
const NEW_ANALYSIS_SUMMARY_TEST_CASES = [
{
featureEnabled: true,
codeqlVersion: "2.15.0",
githubVersion: {
type: util.GitHubVariant.DOTCOM,
},
flagPassed: true,
negativeFlagPassed: false,
},
{
featureEnabled: false,
codeqlVersion: "2.15.0",
githubVersion: {
type: util.GitHubVariant.GHES,
version: "3.9.0",
},
flagPassed: true,
negativeFlagPassed: false,
},
{
codeqlVersion: "2.15.0",
githubVersion: {
type: util.GitHubVariant.GHES,
version: "3.8.6",
},
flagPassed: false,
negativeFlagPassed: true,
},
{
featureEnabled: false,
codeqlVersion: "2.14.6",
githubVersion: {
type: util.GitHubVariant.DOTCOM,
},
flagPassed: false,
negativeFlagPassed: false,
},
];
for (const { featureEnabled, codeqlVersion, flagPassed, negativeFlagPassed, } of NEW_ANALYSIS_SUMMARY_TEST_CASES) {
for (const { codeqlVersion, flagPassed, githubVersion, negativeFlagPassed, } of NEW_ANALYSIS_SUMMARY_TEST_CASES) {
(0, ava_1.default)(`database interpret-results passes ${flagPassed
? "--new-analysis-summary"
: negativeFlagPassed
? "--no-new-analysis-summary"
: "nothing"} for CodeQL CLI v${codeqlVersion} when the new analysis summary feature is ${featureEnabled ? "enabled" : "disabled"}`, async (t) => {
: "nothing"} for CodeQL CLI v${codeqlVersion} and ${util.GitHubVariant[githubVersion.type]} ${githubVersion.version ? ` ${githubVersion.version}` : ""}`, async (t) => {
const runnerConstructorStub = stubToolRunnerConstructor();
const codeqlObject = await codeql.getCodeQLForTesting();
sinon
@ -655,7 +671,7 @@ for (const { featureEnabled, codeqlVersion, flagPassed, negativeFlagPassed, } of
.resolves((0, testing_utils_1.makeVersionInfo)(codeqlVersion));
// safeWhich throws because of the test CodeQL object.
sinon.stub(safeWhich, "safeWhich").resolves("");
await codeqlObject.databaseInterpretResults("", [], "", "", "", "-v", "", stubConfig, (0, testing_utils_1.createFeatures)(featureEnabled ? [feature_flags_1.Feature.AnalysisSummaryV2Enabled] : []), (0, logging_1.getRunnerLogger)(true));
await codeqlObject.databaseInterpretResults("", [], "", "", "", "-v", "", Object.assign({}, stubConfig, { gitHubVersion: githubVersion }), (0, testing_utils_1.createFeatures)([]), (0, logging_1.getRunnerLogger)(true));
t.is(runnerConstructorStub.firstCall.args[1].includes("--new-analysis-summary"), flagPassed, `--new-analysis-summary should${flagPassed ? "" : "n't"} be passed`);
t.is(runnerConstructorStub.firstCall.args[1].includes("--no-new-analysis-summary"), negativeFlagPassed, `--no-new-analysis-summary should${negativeFlagPassed ? "" : "n't"} be passed`);
});

File diff suppressed because one or more lines are too long

12
lib/feature-flags.js generated
View file

@ -23,7 +23,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.logCodeScanningConfigInCli = exports.useCodeScanningConfigInCli = exports.Features = exports.FEATURE_FLAGS_FILE_NAME = exports.featureConfig = exports.Feature = exports.CODEQL_VERSION_SUBLANGUAGE_FILE_COVERAGE = exports.CODEQL_VERSION_ANALYSIS_SUMMARY_V2 = exports.CODEQL_VERSION_INTRA_LAYER_PARALLELISM = exports.CODEQL_VERSION_BUNDLE_SEMANTICALLY_VERSIONED = void 0;
exports.logCodeScanningConfigInCli = exports.useCodeScanningConfigInCli = exports.Features = exports.FEATURE_FLAGS_FILE_NAME = exports.featureConfig = exports.Feature = exports.CODEQL_VERSION_SUBLANGUAGE_FILE_COVERAGE = exports.CODEQL_VERSION_INTRA_LAYER_PARALLELISM = exports.CODEQL_VERSION_BUNDLE_SEMANTICALLY_VERSIONED = void 0;
const fs = __importStar(require("fs"));
const path = __importStar(require("path"));
const semver = __importStar(require("semver"));
@ -41,10 +41,6 @@ exports.CODEQL_VERSION_BUNDLE_SEMANTICALLY_VERSIONED = "2.13.4";
* limit to 2.14.6 onwards, since that's the version that has mitigations against OOM failures.
*/
exports.CODEQL_VERSION_INTRA_LAYER_PARALLELISM = "2.14.6";
/**
* Versions 2.15.0+ of the CodeQL CLI support new analysis summaries.
*/
exports.CODEQL_VERSION_ANALYSIS_SUMMARY_V2 = "2.15.0";
/**
* Versions 2.15.0+ of the CodeQL CLI support sub-language file coverage information.
*/
@ -56,7 +52,6 @@ exports.CODEQL_VERSION_SUBLANGUAGE_FILE_COVERAGE = "2.15.0";
*/
var Feature;
(function (Feature) {
Feature["AnalysisSummaryV2Enabled"] = "analysis_summary_v2_enabled";
Feature["CliConfigFileEnabled"] = "cli_config_file_enabled";
Feature["CodeqlJavaLombokEnabled"] = "codeql_java_lombok_enabled";
Feature["CppDependencyInstallation"] = "cpp_dependency_installation_enabled";
@ -69,11 +64,6 @@ var Feature;
Feature["UploadFailedSarifEnabled"] = "upload_failed_sarif_enabled";
})(Feature || (exports.Feature = Feature = {}));
exports.featureConfig = {
[Feature.AnalysisSummaryV2Enabled]: {
envVar: "CODEQL_ACTION_ANALYSIS_SUMMARY_V2",
minimumVersion: exports.CODEQL_VERSION_ANALYSIS_SUMMARY_V2,
defaultValue: false,
},
[Feature.CodeqlJavaLombokEnabled]: {
envVar: "CODEQL_JAVA_LOMBOK",
minimumVersion: "2.14.0",

File diff suppressed because one or more lines are too long

View file

@ -7,7 +7,11 @@ import del from "del";
import * as yaml from "js-yaml";
import * as analysisPaths from "./analysis-paths";
import { CodeQL, getCodeQL } from "./codeql";
import {
CODEQL_VERSION_ANALYSIS_SUMMARY_V2,
CodeQL,
getCodeQL,
} from "./codeql";
import * as configUtils from "./config-utils";
import {
FeatureEnablement,
@ -389,7 +393,10 @@ export async function runQueries(
}
if (
!(await features.getValue(Feature.AnalysisSummaryV2Enabled, codeql))
!(await util.codeQlVersionAbove(
codeql,
CODEQL_VERSION_ANALYSIS_SUMMARY_V2,
))
) {
await runPrintLinesOfCode(language);
}

View file

@ -1005,29 +1005,45 @@ test("databaseInterpretResults() does not set --sarif-add-baseline-file-info for
const NEW_ANALYSIS_SUMMARY_TEST_CASES = [
{
featureEnabled: true,
codeqlVersion: "2.15.0",
githubVersion: {
type: util.GitHubVariant.DOTCOM,
},
flagPassed: true,
negativeFlagPassed: false,
},
{
featureEnabled: false,
codeqlVersion: "2.15.0",
githubVersion: {
type: util.GitHubVariant.GHES,
version: "3.9.0",
},
flagPassed: true,
negativeFlagPassed: false,
},
{
codeqlVersion: "2.15.0",
githubVersion: {
type: util.GitHubVariant.GHES,
version: "3.8.6",
},
flagPassed: false,
negativeFlagPassed: true,
},
{
featureEnabled: false,
codeqlVersion: "2.14.6",
githubVersion: {
type: util.GitHubVariant.DOTCOM,
},
flagPassed: false,
negativeFlagPassed: false,
},
];
for (const {
featureEnabled,
codeqlVersion,
flagPassed,
githubVersion,
negativeFlagPassed,
} of NEW_ANALYSIS_SUMMARY_TEST_CASES) {
test(`database interpret-results passes ${
@ -1036,9 +1052,9 @@ for (const {
: negativeFlagPassed
? "--no-new-analysis-summary"
: "nothing"
} for CodeQL CLI v${codeqlVersion} when the new analysis summary feature is ${
featureEnabled ? "enabled" : "disabled"
}`, async (t) => {
} for CodeQL CLI v${codeqlVersion} and ${
util.GitHubVariant[githubVersion.type]
} ${githubVersion.version ? ` ${githubVersion.version}` : ""}`, async (t) => {
const runnerConstructorStub = stubToolRunnerConstructor();
const codeqlObject = await codeql.getCodeQLForTesting();
sinon
@ -1054,8 +1070,8 @@ for (const {
"",
"-v",
"",
stubConfig,
createFeatures(featureEnabled ? [Feature.AnalysisSummaryV2Enabled] : []),
Object.assign({}, stubConfig, { gitHubVersion: githubVersion }),
createFeatures([]),
getRunnerLogger(true),
);
t.is(

View file

@ -4,6 +4,7 @@ import * as path from "path";
import * as core from "@actions/core";
import * as toolrunner from "@actions/exec/lib/toolrunner";
import * as yaml from "js-yaml";
import * as semver from "semver";
import {
getActionVersion,
@ -15,7 +16,6 @@ import type { Config } from "./config-utils";
import { EnvVar } from "./environment";
import {
CODEQL_VERSION_INTRA_LAYER_PARALLELISM,
CODEQL_VERSION_ANALYSIS_SUMMARY_V2,
CodeQLDefaultVersionInfo,
Feature,
FeatureEnablement,
@ -362,6 +362,11 @@ export const CODEQL_VERSION_LANGUAGE_BASELINE_CONFIG = "2.14.2";
*/
export const CODEQL_VERSION_LANGUAGE_ALIASING = "2.14.4";
/**
* Versions 2.15.0+ of the CodeQL CLI support new analysis summaries.
*/
export const CODEQL_VERSION_ANALYSIS_SUMMARY_V2 = "2.15.0";
/**
* Set up CodeQL CLI access.
*
@ -925,7 +930,16 @@ export async function getCodeQLForCmd(
} else if (await util.codeQlVersionAbove(this, "2.12.4")) {
codeqlArgs.push("--no-sarif-include-diagnostics");
}
if (await features.getValue(Feature.AnalysisSummaryV2Enabled, this)) {
if (
// Analysis summary v2 links to the status page, so check the GHES version we're running on
// supports the status page.
(config.gitHubVersion.type !== util.GitHubVariant.GHES ||
semver.gte(config.gitHubVersion.version, "3.9.0")) &&
(await util.codeQlVersionAbove(
this,
CODEQL_VERSION_ANALYSIS_SUMMARY_V2,
))
) {
codeqlArgs.push("--new-analysis-summary");
} else if (
await util.codeQlVersionAbove(this, CODEQL_VERSION_ANALYSIS_SUMMARY_V2)

View file

@ -24,11 +24,6 @@ export const CODEQL_VERSION_BUNDLE_SEMANTICALLY_VERSIONED = "2.13.4";
*/
export const CODEQL_VERSION_INTRA_LAYER_PARALLELISM = "2.14.6";
/**
* Versions 2.15.0+ of the CodeQL CLI support new analysis summaries.
*/
export const CODEQL_VERSION_ANALYSIS_SUMMARY_V2 = "2.15.0";
/**
* Versions 2.15.0+ of the CodeQL CLI support sub-language file coverage information.
*/
@ -54,7 +49,6 @@ export interface FeatureEnablement {
* Each value of this enum should end with `_enabled`.
*/
export enum Feature {
AnalysisSummaryV2Enabled = "analysis_summary_v2_enabled",
CliConfigFileEnabled = "cli_config_file_enabled",
CodeqlJavaLombokEnabled = "codeql_java_lombok_enabled",
CppDependencyInstallation = "cpp_dependency_installation_enabled",
@ -71,11 +65,6 @@ export const featureConfig: Record<
Feature,
{ envVar: string; minimumVersion: string | undefined; defaultValue: boolean }
> = {
[Feature.AnalysisSummaryV2Enabled]: {
envVar: "CODEQL_ACTION_ANALYSIS_SUMMARY_V2",
minimumVersion: CODEQL_VERSION_ANALYSIS_SUMMARY_V2,
defaultValue: false,
},
[Feature.CodeqlJavaLombokEnabled]: {
envVar: "CODEQL_JAVA_LOMBOK",
minimumVersion: "2.14.0",