Skip to content

Commit 7d4dc4a

Browse files
committed
Unconditionally disable combining SARIF files for GHES 3.18
1 parent b694213 commit 7d4dc4a

File tree

6 files changed

+90
-18
lines changed

6 files changed

+90
-18
lines changed

lib/upload-lib.js

Lines changed: 14 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/upload-lib.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/upload-lib.test.js

Lines changed: 20 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/upload-lib.test.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/upload-lib.test.ts

Lines changed: 41 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -486,7 +486,7 @@ test("throwIfCombineSarifFilesDisabled when on GHES 3.14", async (t) => {
486486
await t.notThrowsAsync(
487487
uploadLib.throwIfCombineSarifFilesDisabled(
488488
[createMockSarif("abc", "def"), createMockSarif("abc", "def")],
489-
createFeatures([Feature.DisableCombineSarifFiles]),
489+
createFeatures([]),
490490
{
491491
type: GitHubVariant.GHES,
492492
version: "3.14.0",
@@ -495,11 +495,50 @@ test("throwIfCombineSarifFilesDisabled when on GHES 3.14", async (t) => {
495495
);
496496
});
497497

498+
test("throwIfCombineSarifFilesDisabled when on GHES 3.17", async (t) => {
499+
await t.notThrowsAsync(
500+
uploadLib.throwIfCombineSarifFilesDisabled(
501+
[createMockSarif("abc", "def"), createMockSarif("abc", "def")],
502+
createFeatures([]),
503+
{
504+
type: GitHubVariant.GHES,
505+
version: "3.17.0",
506+
},
507+
),
508+
);
509+
});
510+
511+
test("throwIfCombineSarifFilesDisabled when on GHES 3.18 pre", async (t) => {
512+
await t.throwsAsync(
513+
uploadLib.throwIfCombineSarifFilesDisabled(
514+
[createMockSarif("abc", "def"), createMockSarif("abc", "def")],
515+
createFeatures([]),
516+
{
517+
type: GitHubVariant.GHES,
518+
version: "3.18.0.pre1",
519+
},
520+
),
521+
);
522+
});
523+
524+
test("throwIfCombineSarifFilesDisabled when on GHES 3.18 alpha", async (t) => {
525+
await t.throwsAsync(
526+
uploadLib.throwIfCombineSarifFilesDisabled(
527+
[createMockSarif("abc", "def"), createMockSarif("abc", "def")],
528+
createFeatures([]),
529+
{
530+
type: GitHubVariant.GHES,
531+
version: "3.18.0-alpha.1",
532+
},
533+
),
534+
);
535+
});
536+
498537
test("throwIfCombineSarifFilesDisabled when on GHES 3.18", async (t) => {
499538
await t.throwsAsync(
500539
uploadLib.throwIfCombineSarifFilesDisabled(
501540
[createMockSarif("abc", "def"), createMockSarif("abc", "def")],
502-
createFeatures([Feature.DisableCombineSarifFiles]),
541+
createFeatures([]),
503542
{
504543
type: GitHubVariant.GHES,
505544
version: "3.18.0",

src/upload-lib.ts

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -175,20 +175,26 @@ async function shouldDisableCombineSarifFiles(
175175
features: FeatureEnablement,
176176
githubVersion: GitHubVersion,
177177
) {
178-
// Never block on GHES versions before 3.18.0
179-
if (
180-
githubVersion.type === GitHubVariant.GHES &&
181-
semver.lt(githubVersion.version, "3.18.0")
182-
) {
183-
return false;
178+
if (githubVersion.type === GitHubVariant.GHES) {
179+
// Never block on GHES versions before 3.18.
180+
if (semver.lt(githubVersion.version, "3.18.0-0")) {
181+
return false;
182+
}
183+
} else {
184+
// Never block when the feature flag is disabled.
185+
if (!(await features.getValue(Feature.DisableCombineSarifFiles))) {
186+
return false;
187+
}
184188
}
185189

186190
if (areAllRunsUnique(sarifObjects)) {
187191
// If all runs are unique, we can safely combine them.
188192
return false;
189193
}
190194

191-
return features.getValue(Feature.DisableCombineSarifFiles);
195+
// Combining SARIF files is not supported and Code Scanning will return an
196+
// error if multiple runs with the same category are uploaded.
197+
return true;
192198
}
193199

194200
// Takes a list of paths to sarif files and combines them together using the

0 commit comments

Comments
 (0)