microsoft / sarif-vscode-extension

SARIF Microsoft Visual Studio Code extension
MIT License
110 stars 49 forks source link

Extension-provided uriBase is ignored #506

Closed 50Wliu closed 1 year ago

50Wliu commented 1 year ago

The SARIF VS Code extension provides an extensibility point for other extensions to add their own uriBases when resolving SARIF artifact locations: https://github.com/microsoft/sarif-vscode-extension/blob/main/src/extension/index.d.ts#L15

However, in practice, this never gets used because the extension unconditionally prepends the workspace URI to the artifact location before the code to prepend the custom URI base is ever reached. https://github.com/microsoft/sarif-vscode-extension/blob/main/src/shared/index.ts#L204

That is to say, if I have a relative SARIF location my/file/path and I provide a URI base of /absolute/base/ while in the /absolute/base/repo workspace: Expected: SARIF location resolves to /absolute/base/my/file/path Actual: Extension tries to look up /absolute/base/repo/my/file/path as well as /absolute/base/absolute/base/repo/my/file/path and fails to locate the file

50Wliu commented 1 year ago

For a bit more context - in our extension, we are adding support for a large mono-repo in which developers exclusively work in subfolders (i.e., they have /absolute/src/nested/folder open as their workspace) but static analysis runs at the root. Thus, when we provide the SARIFs, their relative locations are src/nested/folder/file.txt. Our intention is to provide the correct URI base of /absolute/ so that the relative paths resolve correctly, but instead what we're seeing is that SARIF VS Code is trying to resolve the paths to /absolute/src/nested/folder/src/nested/folder/file.txt and more-or-less ignoring the uriBase we provided.