Reject all file URIs

This commit is contained in:
Robert
2023-05-02 17:05:42 +01:00
parent 5ff5384551
commit e8403cf5d2

View File

@@ -172,7 +172,14 @@ function getFilePath(
physicalLocation: sarif.PhysicalLocation,
): string | undefined {
const filePath = physicalLocation.artifactLocation?.uri;
if (filePath === undefined || filePath === "" || filePath === "file:/") {
// We expect the location uri value to be a relative file path, with no scheme.
// We only need to support output from CodeQL here, so we can be quite strict,
// even though the SARIF spec supports many more types of URI.
if (
filePath === undefined ||
filePath === "" ||
filePath.startsWith("file:")
) {
return undefined;
}
return filePath;