Remove redundant version checks

Remove version checks that always return true given the new minimum version of CodeQL.
This commit is contained in:
Henry Mercer
2025-01-15 17:59:15 +00:00
parent bd76a92ebe
commit 40a203a0ea
14 changed files with 21 additions and 187 deletions

View File

@@ -9,11 +9,7 @@ import * as yaml from "js-yaml";
import * as actionsUtil from "./actions-util";
import { getApiClient } from "./api-client";
import { setupCppAutobuild } from "./autobuild";
import {
CODEQL_VERSION_ANALYSIS_SUMMARY_V2,
CodeQL,
getCodeQL,
} from "./codeql";
import { CodeQL, getCodeQL } from "./codeql";
import * as configUtils from "./config-utils";
import { addDiagnostic, makeDiagnostic } from "./diagnostics";
import { EnvVar } from "./environment";
@@ -613,15 +609,6 @@ export async function runQueries(
}
statusReport["event_reports"].push(perQueryAlertCountEventReport);
}
if (
!(await util.codeQlVersionAtLeast(
codeql,
CODEQL_VERSION_ANALYSIS_SUMMARY_V2,
))
) {
await runPrintLinesOfCode(language);
}
} catch (e) {
statusReport.analyze_failure_language = language;
throw new CodeQLAnalysisError(
@@ -682,11 +669,6 @@ export async function runQueries(
}
return perQueryAlertCounts;
}
async function runPrintLinesOfCode(language: Language): Promise<string> {
const databasePath = util.getCodeQLDatabasePath(config, language);
return await codeql.databasePrintBaseline(databasePath);
}
}
export async function runFinalize(

View File

@@ -791,14 +791,6 @@ const NEW_ANALYSIS_SUMMARY_TEST_CASES = [
flagPassed: true,
negativeFlagPassed: false,
},
{
codeqlVersion: makeVersionInfo("2.14.6"),
githubVersion: {
type: util.GitHubVariant.DOTCOM,
},
flagPassed: false,
negativeFlagPassed: false,
},
];
for (const {
@@ -965,7 +957,7 @@ test("runTool recognizes fatal internal errors", async (t) => {
await codeqlObject.databaseRunQueries(stubConfig.dbLocation, []),
{
instanceOf: CliError,
message: `Encountered a fatal error while running "codeql-for-testing database run-queries --expect-discarded-cache --min-disk-free=1024 -v --intra-layer-parallelism". Exit code was 1 and error was: Oops! A fatal internal error occurred. Details:
message: `Encountered a fatal error while running "codeql-for-testing database run-queries --expect-discarded-cache --intra-layer-parallelism --min-disk-free=1024 -v". Exit code was 1 and error was: Oops! A fatal internal error occurred. Details:
com.semmle.util.exception.CatastrophicError: An error occurred while evaluating ControlFlowGraph::ControlFlow::Root.isRootOf/1#dispred#f610e6ed/2@86282cc8
Severe disk cache trouble (corruption or out of space) at /home/runner/work/_temp/codeql_databases/go/db-go/default/cache/pages/28/33.pack: Failed to write item to disk. See the logs for more details.`,
},

View File

@@ -4,7 +4,6 @@ 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 {
CommandInvocationError,
@@ -18,7 +17,6 @@ import { type Config } from "./config-utils";
import { DocUrl } from "./doc-url";
import { EnvVar } from "./environment";
import {
CODEQL_VERSION_FINE_GRAINED_PARALLELISM,
CodeQLDefaultVersionInfo,
Feature,
FeatureEnablement,
@@ -304,21 +302,6 @@ const EXTRACTION_DEBUG_MODE_VERBOSITY = "progress++";
* flag is older than the oldest supported version above, it may be removed.
*/
/**
* 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.
*/
export const CODEQL_VERSION_SUBLANGUAGE_FILE_COVERAGE = "2.15.0";
/**
* Versions 2.15.2+ of the CodeQL CLI support the `--sarif-include-query-help` option.
*/
const CODEQL_VERSION_INCLUDE_QUERY_HELP = "2.15.2";
/**
* Versions 2.17.1+ of the CodeQL CLI support the `--cache-cleanup` option.
*/
@@ -602,19 +585,6 @@ export async function getCodeQLForCmd(
extraArgs.push(`--qlconfig-file=${qlconfigFile}`);
}
extraArgs.push("--calculate-language-specific-baseline");
if (await isSublanguageFileCoverageEnabled(config, this)) {
extraArgs.push("--sublanguage-file-coverage");
} else if (
await util.codeQlVersionAtLeast(
this,
CODEQL_VERSION_SUBLANGUAGE_FILE_COVERAGE,
)
) {
extraArgs.push("--no-sublanguage-file-coverage");
}
const overwriteFlag = isSupportedToolsFeature(
await this.getVersion(),
ToolsFeature.ForceOverwrite,
@@ -631,7 +601,9 @@ export async function getCodeQLForCmd(
"--db-cluster",
config.dbLocation,
`--source-root=${sourceRoot}`,
"--calculate-language-specific-baseline",
"--extractor-include-aliases",
"--sublanguage-file-coverage",
...extraArgs,
...getExtraOptionsFromEnv(["database", "init"], {
ignoringOptions: ["--overwrite"],
@@ -820,20 +792,13 @@ export async function getCodeQLForCmd(
...flags,
databasePath,
"--expect-discarded-cache",
"--intra-layer-parallelism",
"--min-disk-free=1024", // Try to leave at least 1GB free
"-v",
...getExtraOptionsFromEnv(["database", "run-queries"], {
ignoringOptions: ["--expect-discarded-cache"],
}),
];
if (
await util.codeQlVersionAtLeast(
this,
CODEQL_VERSION_FINE_GRAINED_PARALLELISM,
)
) {
codeqlArgs.push("--intra-layer-parallelism");
}
await runCli(cmd, codeqlArgs);
},
async databaseInterpretResults(
@@ -867,7 +832,8 @@ export async function getCodeQLForCmd(
config,
)}`,
"--sarif-group-rules-by-pack",
...(await getCodeScanningQueryHelpArguments(this)),
"--sarif-include-query-help=always",
"--sublanguage-file-coverage",
...(await getJobRunUuidSarifOptions(this)),
...getExtraOptionsFromEnv(["database", "interpret-results"]),
];
@@ -877,26 +843,12 @@ export async function getCodeQLForCmd(
if (automationDetailsId !== undefined) {
codeqlArgs.push("--sarif-category", automationDetailsId);
}
if (await isSublanguageFileCoverageEnabled(config, this)) {
codeqlArgs.push("--sublanguage-file-coverage");
} else if (
await util.codeQlVersionAtLeast(
this,
CODEQL_VERSION_SUBLANGUAGE_FILE_COVERAGE,
)
) {
codeqlArgs.push("--no-sublanguage-file-coverage");
}
if (shouldExportDiagnostics) {
codeqlArgs.push("--sarif-include-diagnostics");
} else {
codeqlArgs.push("--no-sarif-include-diagnostics");
}
if (
(await util.codeQlVersionAtLeast(
this,
CODEQL_VERSION_ANALYSIS_SUMMARY_V2,
)) &&
!isSupportedToolsFeature(
await this.getVersion(),
ToolsFeature.AnalysisSummaryV2IsDefault,
@@ -1333,32 +1285,6 @@ export function getGeneratedCodeScanningConfigPath(config: Config): string {
return path.resolve(config.tempDir, "user-config.yaml");
}
async function isSublanguageFileCoverageEnabled(
config: Config,
codeql: CodeQL,
) {
return (
// Sub-language file coverage is first supported in GHES 3.12.
(config.gitHubVersion.type !== util.GitHubVariant.GHES ||
semver.gte(config.gitHubVersion.version, "3.12.0")) &&
(await util.codeQlVersionAtLeast(
codeql,
CODEQL_VERSION_SUBLANGUAGE_FILE_COVERAGE,
))
);
}
async function getCodeScanningQueryHelpArguments(
codeql: CodeQL,
): Promise<string[]> {
if (
await util.codeQlVersionAtLeast(codeql, CODEQL_VERSION_INCLUDE_QUERY_HELP)
) {
return ["--sarif-include-query-help=always"];
}
return ["--sarif-add-query-help"];
}
function getExtractionVerbosityArguments(
enableDebugLogging: boolean,
): string[] {

View File

@@ -14,12 +14,6 @@ import * as util from "./util";
const DEFAULT_VERSION_FEATURE_FLAG_PREFIX = "default_codeql_version_";
const DEFAULT_VERSION_FEATURE_FLAG_SUFFIX = "_enabled";
/**
* Evaluator fine-grained parallelism (aka intra-layer parallelism) is only safe to enable in 2.15.1 onwards.
* (Some earlier versions recognize the command-line flag, but they contain a bug which makes it unsafe to use).
*/
export const CODEQL_VERSION_FINE_GRAINED_PARALLELISM = "2.15.1";
/**
* The first version of the CodeQL Bundle that shipped with zstd-compressed bundles.
*/