Skip to content

Commit 37ea6e6

Browse files
committed
Undo some uneeded changes
1 parent 833e1b0 commit 37ea6e6

File tree

3 files changed

+32
-15
lines changed

3 files changed

+32
-15
lines changed

src/setup-codeql.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -338,7 +338,7 @@ test.serial(
338338

339339
// Afterwards, ensure that we see the expected messages in the log.
340340
checkExpectedLogMessages(t, loggedMessages, [
341-
"Using the latest CodeQL CLI nightly, as requested.",
341+
"Using the latest CodeQL CLI nightly, as requested by 'tools: nightly'.",
342342
`Bundle version ${expectedDate} is not in SemVer format. Will treat it as pre-release ${expectedVersion}.`,
343343
`Attempting to obtain CodeQL tools. CLI version: unknown, bundle tag name: ${expectedTag}`,
344344
`Using CodeQL CLI sourced from ${expectedURL}`,
@@ -455,7 +455,7 @@ test.serial(
455455

456456
// Check that key messages we would expect to find in the log are present.
457457
const expectedMessages: string[] = [
458-
`Attempting to use the latest CodeQL CLI version in the toolcache, as requested.`,
458+
`Attempting to use the latest CodeQL CLI version in the toolcache, as requested by 'tools: toolcache'.`,
459459
`CLI version ${latestToolcacheVersion} is the latest version in the toolcache.`,
460460
`Using CodeQL CLI version ${latestToolcacheVersion} from toolcache at ${latestVersionPath}`,
461461
];
@@ -540,7 +540,7 @@ test.serial(
540540
{ GITHUB_EVENT_NAME: "dynamic" },
541541
[],
542542
[
543-
`Attempting to use the latest CodeQL CLI version in the toolcache, as requested.`,
543+
`Attempting to use the latest CodeQL CLI version in the toolcache, as requested by 'tools: toolcache'.`,
544544
`Found no CodeQL CLI in the toolcache, ignoring 'tools: toolcache'...`,
545545
],
546546
);

src/setup-codeql.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -359,7 +359,9 @@ export async function getCodeQLSource(
359359
),
360360
);
361361
} else {
362-
logger.info(`Using the latest CodeQL CLI nightly, as requested.`);
362+
logger.info(
363+
`Using the latest CodeQL CLI nightly, as requested by 'tools: ${toolsInput}'.`,
364+
);
363365
}
364366
toolsInput = await getNightlyToolsUrl(logger);
365367
}
@@ -399,7 +401,7 @@ export async function getCodeQLSource(
399401

400402
// We only allow `toolsInput === "toolcache"` for `dynamic` events. In general, using `toolsInput === "toolcache"`
401403
// can lead to alert wobble and so it shouldn't be used for an analysis where results are intended to be uploaded.
402-
// We also allow this in test mode or when the input comes from a repository property.
404+
// We also allow this in test mode.
403405
const allowToolcacheValueFF = await features.getValue(
404406
Feature.AllowToolcacheInput,
405407
);
@@ -410,7 +412,7 @@ export async function getCodeQLSource(
410412
// and use that. We perform this check here since we can set `cliVersion` directly and don't want to default to
411413
// the linked version.
412414
logger.info(
413-
`Attempting to use the latest CodeQL CLI version in the toolcache, as requested.`,
415+
`Attempting to use the latest CodeQL CLI version in the toolcache, as requested by 'tools: ${toolsInput}'.`,
414416
);
415417

416418
latestToolcacheVersion = getLatestToolcacheVersion(logger);

src/upload-lib.ts

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,16 @@ const GENERIC_404_MSG =
4747
// Checks whether the deprecation warning for combining SARIF files should be shown.
4848
export async function shouldShowCombineSarifFilesDeprecationWarning(
4949
sarifObjects: Array<Partial<sarif.Log>>,
50+
githubVersion: GitHubVersion,
5051
) {
52+
// Do not show this warning on GHES versions before 3.14.0
53+
if (
54+
githubVersion.type === GitHubVariant.GHES &&
55+
satisfiesGHESVersion(githubVersion.version, "<3.14", true)
56+
) {
57+
return false;
58+
}
59+
5160
// Only give a deprecation warning when not all runs are unique and
5261
// we haven't already shown the warning.
5362
return (
@@ -122,7 +131,12 @@ async function combineSarifFilesUsingCLI(
122131
"Not all SARIF files were produced by CodeQL. Merging files in the action.",
123132
);
124133

125-
if (await shouldShowCombineSarifFilesDeprecationWarning(sarifObjects)) {
134+
if (
135+
await shouldShowCombineSarifFilesDeprecationWarning(
136+
sarifObjects,
137+
gitHubVersion,
138+
)
139+
) {
126140
logger.warning(
127141
`Uploading multiple SARIF runs with the same category is deprecated ${deprecationWarningMessage}. Please update your workflow to upload a single run per category. ${deprecationMoreInformationMessage}`,
128142
);
@@ -883,12 +897,6 @@ export async function waitForProcessing(
883897
);
884898
break;
885899
}
886-
if (!response) {
887-
logger.warning(
888-
"Unable to check analysis status due to missing response. It should still be processed in the background.",
889-
);
890-
break;
891-
}
892900
const status = response.data.processing_status as ProcessingStatus;
893901
logger.info(`Analysis upload status is ${status}.`);
894902

@@ -1045,7 +1053,7 @@ function sanitize(str?: string) {
10451053
return (str ?? "_").replace(/[^a-zA-Z0-9_]/g, "_").toLocaleUpperCase();
10461054
}
10471055

1048-
export function filterAlertsByDiffRange(
1056+
function filterAlertsByDiffRange(
10491057
logger: Logger,
10501058
sarifLog: Partial<sarif.Log>,
10511059
): Partial<sarif.Log> {
@@ -1058,6 +1066,8 @@ export function filterAlertsByDiffRange(
10581066
return sarifLog;
10591067
}
10601068

1069+
const checkoutPath = actionsUtil.getRequiredInput("checkout_path");
1070+
10611071
for (const run of sarifLog.runs) {
10621072
if (run.results) {
10631073
run.results = run.results.filter((result) => {
@@ -1072,14 +1082,19 @@ export function filterAlertsByDiffRange(
10721082
if (!locationUri || locationStartLine === undefined) {
10731083
return false;
10741084
}
1085+
// CodeQL always uses forward slashes as the path separator, so on Windows we
1086+
// need to replace any backslashes with forward slashes.
1087+
const locationPath = path
1088+
.join(checkoutPath, locationUri)
1089+
.replaceAll(path.sep, "/");
10751090
// Alert filtering here replicates the same behavior as the restrictAlertsTo
10761091
// extensible predicate in CodeQL. See the restrictAlertsTo documentation
10771092
// https://codeql.github.com/codeql-standard-libraries/csharp/codeql/util/AlertFiltering.qll/predicate.AlertFiltering$restrictAlertsTo.3.html
10781093
// for more details, such as why the filtering applies only to the first line
10791094
// of an alert location.
10801095
return diffRanges.some(
10811096
(range) =>
1082-
range.path === locationUri &&
1097+
range.path === locationPath &&
10831098
((range.startLine <= locationStartLine &&
10841099
range.endLine >= locationStartLine) ||
10851100
(range.startLine === 0 && range.endLine === 0)),

0 commit comments

Comments
 (0)