Add failing test when a related location is undefined
This commit is contained in:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user