Add failing test when a related location is undefined

This commit is contained in:
Robert
2023-08-04 11:58:58 +01:00
parent 7530920a0b
commit fef55e3ec5

View File

@@ -720,6 +720,33 @@ describe("SARIF processing", () => {
expectNoParsingError(result);
expect(actualCodeSnippet).not.toBeUndefined();
});
it("should be able to handle when a location has no uri", () => {
const sarif = buildValidSarifLog();
sarif.runs![0].results![0].message.text = "message [String](1)";
sarif.runs![0].results![0].relatedLocations = [
{
id: 1,
physicalLocation: {
artifactLocation: {
uri: "file:/modules/java.base/java/lang/String.class",
index: 1,
},
},
message: {
text: "String",
},
},
];
const result = extractAnalysisAlerts(sarif, fakefileLinkPrefix);
const actualCodeSnippet = result.alerts[0].codeSnippet;
expect(result).toBeTruthy();
expectNoParsingError(result);
expect(actualCodeSnippet).not.toBeUndefined();
});
});
function expectResultParsingError(msg: string) {