Skip to content

Commit

Permalink
Only pass --new-analysis-summary if it is not default behavior
Browse files Browse the repository at this point in the history
  • Loading branch information
Henry Mercer committed Apr 3, 2024
1 parent eeaea14 commit eda4878
Show file tree
Hide file tree
Showing 9 changed files with 40 additions and 49 deletions.
11 changes: 2 additions & 9 deletions lib/codeql.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lib/codeql.js.map

Large diffs are not rendered by default.

28 changes: 14 additions & 14 deletions lib/codeql.test.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lib/codeql.test.js.map

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions lib/tools-features.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lib/tools-features.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

28 changes: 14 additions & 14 deletions src/codeql.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import {
makeVersionInfo,
createTestConfig,
} from "./testing-utils";
import { ToolsFeature } from "./tools-features";
import * as util from "./util";
import { initializeEnvironment } from "./util";

Expand Down Expand Up @@ -772,33 +773,34 @@ test("does not pass a qlconfig to the CLI when it is undefined", async (t: Execu

const NEW_ANALYSIS_SUMMARY_TEST_CASES = [
{
codeqlVersion: "2.15.0",
codeqlVersion: makeVersionInfo("2.15.0", {
[ToolsFeature.AnalysisSummaryV2IsDefault]: true,
}),
githubVersion: {
type: util.GitHubVariant.DOTCOM,
},
flagPassed: true,
flagPassed: false,
negativeFlagPassed: false,
},
{
codeqlVersion: "2.15.0",
codeqlVersion: makeVersionInfo("2.15.0"),
githubVersion: {
type: util.GitHubVariant.GHES,
version: "3.9.0",
type: util.GitHubVariant.DOTCOM,
},
flagPassed: true,
negativeFlagPassed: false,
},
{
codeqlVersion: "2.15.0",
codeqlVersion: makeVersionInfo("2.15.0"),
githubVersion: {
type: util.GitHubVariant.GHES,
version: "3.8.6",
version: "3.9.0",
},
flagPassed: false,
negativeFlagPassed: true,
flagPassed: true,
negativeFlagPassed: false,
},
{
codeqlVersion: "2.14.6",
codeqlVersion: makeVersionInfo("2.14.6"),
githubVersion: {
type: util.GitHubVariant.DOTCOM,
},
Expand All @@ -819,14 +821,12 @@ for (const {
: negativeFlagPassed
? "--no-new-analysis-summary"
: "nothing"
} for CodeQL CLI v${codeqlVersion} and ${
} for CodeQL version ${JSON.stringify(codeqlVersion)} and ${
util.GitHubVariant[githubVersion.type]
} ${githubVersion.version ? ` ${githubVersion.version}` : ""}`, async (t) => {
const runnerConstructorStub = stubToolRunnerConstructor();
const codeqlObject = await codeql.getCodeQLForTesting();
sinon
.stub(codeqlObject, "getVersion")
.resolves(makeVersionInfo(codeqlVersion));
sinon.stub(codeqlObject, "getVersion").resolves(codeqlVersion);
// safeWhich throws because of the test CodeQL object.
sinon.stub(safeWhich, "safeWhich").resolves("");
await codeqlObject.databaseInterpretResults(
Expand Down
14 changes: 5 additions & 9 deletions src/codeql.ts
Original file line number Diff line number Diff line change
Expand Up @@ -890,20 +890,16 @@ export async function getCodeQLForCmd(
codeqlArgs.push("--no-sarif-include-diagnostics");
}
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,
))
)) &&
!isSupportedToolsFeature(
await this.getVersion(),
ToolsFeature.AnalysisSummaryV2IsDefault,
)
) {
codeqlArgs.push("--new-analysis-summary");
} else if (
await util.codeQlVersionAbove(this, CODEQL_VERSION_ANALYSIS_SUMMARY_V2)
) {
codeqlArgs.push("--no-new-analysis-summary");
}
codeqlArgs.push(databasePath);
if (querySuitePaths) {
Expand Down
1 change: 1 addition & 0 deletions src/tools-features.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import type { VersionInfo } from "./codeql";

export enum ToolsFeature {
AnalysisSummaryV2IsDefault = "analysisSummaryV2Default",
BuildModeOption = "buildModeOption",
IndirectTracingSupportsStaticBinaries = "indirectTracingSupportsStaticBinaries",
InformsAboutUnsupportedPathFilters = "informsAboutUnsupportedPathFilters",
Expand Down

0 comments on commit eda4878

Please sign in to comment.