Skip to content

Commit fef55e3

Browse files
Add failing test when a related location is undefined
1 parent 7530920 commit fef55e3

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

extensions/ql-vscode/test/unit-tests/sarif-processing.test.ts

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -720,6 +720,33 @@ describe("SARIF processing", () => {
720720
expectNoParsingError(result);
721721
expect(actualCodeSnippet).not.toBeUndefined();
722722
});
723+
724+
it("should be able to handle when a location has no uri", () => {
725+
const sarif = buildValidSarifLog();
726+
sarif.runs![0].results![0].message.text = "message [String](1)";
727+
sarif.runs![0].results![0].relatedLocations = [
728+
{
729+
id: 1,
730+
physicalLocation: {
731+
artifactLocation: {
732+
uri: "file:/modules/java.base/java/lang/String.class",
733+
index: 1,
734+
},
735+
},
736+
message: {
737+
text: "String",
738+
},
739+
},
740+
];
741+
742+
const result = extractAnalysisAlerts(sarif, fakefileLinkPrefix);
743+
744+
const actualCodeSnippet = result.alerts[0].codeSnippet;
745+
746+
expect(result).toBeTruthy();
747+
expectNoParsingError(result);
748+
expect(actualCodeSnippet).not.toBeUndefined();
749+
});
723750
});
724751

725752
function expectResultParsingError(msg: string) {

0 commit comments

Comments
 (0)