Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Internal Content is not properly displayed #544

Open
jnix-abk opened this issue Jan 2, 2024 · 0 comments
Open

Internal Content is not properly displayed #544

jnix-abk opened this issue Jan 2, 2024 · 0 comments

Comments

@jnix-abk
Copy link

jnix-abk commented Jan 2, 2024

I'm trying to get internal content to display in VS code and the code that prepares the artifact locations does not align with the code that consumes the artifact location.

// A shorter more transparent URI format would be:
// `sarif://${encodeURIComponent(result._log._uri)}/${result._run._index}/${anyArtLoc.index}/${uri?.file ?? 'Untitled'}`
// However between workspace.openTextDocument() and registerTextDocumentContentProvider/provideTextDocumentContent()
// VS Code fails to maintain the authority value (possibly due to an encoding bug).
const uriContents = runArtCon?.text || runArtCon?.binary
? encodeURI(`sarif:${encodeURIComponent(result._log._uri)}/${result._run._index}/${anyArtLoc.index}/${uri?.file ?? 'Untitled'}`)
: undefined;
return [uri, uriBase, uriContents];

Notice that Line 194 refers to links as sarif:// and Line 198 refers to them as sarif:. This causes the consuming code to not recognize internal references (which are required to be sarif://):
// Sarif-scheme URIs are owned/created by us, so we know they exist.
if (artifactUri.startsWith('sarif://')) return Uri.parse(artifactUri, true);

The Virtual Document handler expects the links to be sarif: otherwise the extra forward slashes break the link parsing.

disposables.push(workspace.registerTextDocumentContentProvider('sarif', {
provideTextDocumentContent: (uri, token) => {
const [logUriEncoded, runIndex, artifactIndex] = uri.path.split('/');

Debugging this myself, I altered Line 117 in uriRebaser.ts to check just for sarif:. I am not sure if this is the correct fix, but I was able to embed content and have it work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant