Skip to content

Commit 40a77df

Browse files
authored
Merge pull request #3018 from github/koesie10/fix-empty-location
Fix empty message with empty SARIF path
2 parents 9a97b7b + 06b6595 commit 40a77df

File tree

4 files changed

+51
-0
lines changed

4 files changed

+51
-0
lines changed

extensions/ql-vscode/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
- Fix a bug where the "View Query Log" action for a query history item was not working. [#2984](https://github.com/github/vscode-codeql/pull/2984)
88
- Add a command to sort items in the databases view by language. [#2993](https://github.com/github/vscode-codeql/pull/2993)
99
- Fix not being able to open the results directory or evaluator log for a cancelled local query run. [#2996](https://github.com/github/vscode-codeql/pull/2996)
10+
- Fix empty row in alert path when the SARIF location was empty. [#3018](https://github.com/github/vscode-codeql/pull/3018)
1011

1112
## 1.9.2 - 12 October 2023
1213

extensions/ql-vscode/src/common/sarif-utils.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import * as Sarif from "sarif";
22
import type { HighlightedRegion } from "../variant-analysis/shared/analysis-result";
33
import { ResolvableLocationValue } from "../common/bqrs-cli-types";
4+
import { isEmptyPath } from "./bqrs-utils";
45

56
export interface SarifLink {
67
dest: number;
@@ -111,6 +112,9 @@ export function parseSarifLocation(
111112
return { hint: "no artifact location" };
112113
if (physicalLocation.artifactLocation.uri === undefined)
113114
return { hint: "artifact location has no uri" };
115+
if (isEmptyPath(physicalLocation.artifactLocation.uri)) {
116+
return { hint: "artifact location has empty uri" };
117+
}
114118

115119
// This is not necessarily really an absolute uri; it could either be a
116120
// file uri or a relative uri.

extensions/ql-vscode/src/stories/results/AlertTable.stories.tsx

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -389,6 +389,22 @@ WithCodeFlows.args = {
389389
message: { text: "id : String" },
390390
},
391391
},
392+
{
393+
location: {
394+
physicalLocation: {
395+
artifactLocation: {
396+
uri: "file:/",
397+
index: 5,
398+
},
399+
region: {
400+
startLine: 13,
401+
startColumn: 25,
402+
endColumn: 54,
403+
},
404+
},
405+
message: { text: "id : String" },
406+
},
407+
},
392408
{
393409
location: {
394410
physicalLocation: {

extensions/ql-vscode/test/unit-tests/common/sarif-utils.test.ts

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,36 @@ describe("parsing sarif", () => {
7676
).toEqual({
7777
hint: "artifact location has no uri",
7878
});
79+
expect(
80+
parseSarifLocation(
81+
{
82+
physicalLocation: {
83+
artifactLocation: {
84+
uri: "",
85+
index: 5,
86+
},
87+
},
88+
},
89+
"",
90+
),
91+
).toEqual({
92+
hint: "artifact location has empty uri",
93+
});
94+
expect(
95+
parseSarifLocation(
96+
{
97+
physicalLocation: {
98+
artifactLocation: {
99+
uri: "file:/",
100+
index: 5,
101+
},
102+
},
103+
},
104+
"",
105+
),
106+
).toEqual({
107+
hint: "artifact location has empty uri",
108+
});
79109
});
80110

81111
it("should parse a sarif location with no region and no file protocol", () => {

0 commit comments

Comments
 (0)