Fix empty message with empty SARIF path
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import * as Sarif from "sarif";
|
||||
import type { HighlightedRegion } from "../variant-analysis/shared/analysis-result";
|
||||
import { ResolvableLocationValue } from "../common/bqrs-cli-types";
|
||||
import { isEmptyPath } from "./bqrs-utils";
|
||||
|
||||
export interface SarifLink {
|
||||
dest: number;
|
||||
@@ -111,6 +112,9 @@ export function parseSarifLocation(
|
||||
return { hint: "no artifact location" };
|
||||
if (physicalLocation.artifactLocation.uri === undefined)
|
||||
return { hint: "artifact location has no uri" };
|
||||
if (isEmptyPath(physicalLocation.artifactLocation.uri)) {
|
||||
return { hint: "artifact location has empty uri" };
|
||||
}
|
||||
|
||||
// This is not necessarily really an absolute uri; it could either be a
|
||||
// file uri or a relative uri.
|
||||
|
||||
@@ -389,6 +389,22 @@ WithCodeFlows.args = {
|
||||
message: { text: "id : String" },
|
||||
},
|
||||
},
|
||||
{
|
||||
location: {
|
||||
physicalLocation: {
|
||||
artifactLocation: {
|
||||
uri: "file:/",
|
||||
index: 5,
|
||||
},
|
||||
region: {
|
||||
startLine: 13,
|
||||
startColumn: 25,
|
||||
endColumn: 54,
|
||||
},
|
||||
},
|
||||
message: { text: "id : String" },
|
||||
},
|
||||
},
|
||||
{
|
||||
location: {
|
||||
physicalLocation: {
|
||||
|
||||
@@ -76,6 +76,36 @@ describe("parsing sarif", () => {
|
||||
).toEqual({
|
||||
hint: "artifact location has no uri",
|
||||
});
|
||||
expect(
|
||||
parseSarifLocation(
|
||||
{
|
||||
physicalLocation: {
|
||||
artifactLocation: {
|
||||
uri: "",
|
||||
index: 5,
|
||||
},
|
||||
},
|
||||
},
|
||||
"",
|
||||
),
|
||||
).toEqual({
|
||||
hint: "artifact location has empty uri",
|
||||
});
|
||||
expect(
|
||||
parseSarifLocation(
|
||||
{
|
||||
physicalLocation: {
|
||||
artifactLocation: {
|
||||
uri: "file:/",
|
||||
index: 5,
|
||||
},
|
||||
},
|
||||
},
|
||||
"",
|
||||
),
|
||||
).toEqual({
|
||||
hint: "artifact location has empty uri",
|
||||
});
|
||||
});
|
||||
|
||||
it("should parse a sarif location with no region and no file protocol", () => {
|
||||
|
||||
Reference in New Issue
Block a user