vscode-codeql icon indicating copy to clipboard operation
vscode-codeql copied to clipboard

Unable to view source code files in a CodeQL database over SSH remote session

Open electricworry opened this issue 3 years ago • 3 comments

Describe the bug When connecting from VSCode (Linux) to a remote Linux server over SSH, it is not possible to view the source files contained in a CodeQL database. This includes browsing the archive in the Explorer, and also following links in CodeQL results. An error such as the following will be shown:

Unable to open 'format_g726.c (read-only)': Unable to read file 'codeql-zip-archive://0-46/home/electricworry/projects/fuzzing/asterisk-db/src.zip/home/electricworry/projects/fuzzing/asterisk/formats/format_g726.c' (TypeError: Cannot read property 'pipes' of undefined).

Version CodeQL extension version: 1.4.8 CodeQL CLI version: 2.4.6 Platform: linux x64

Version: 1.56.2 Commit: 054a9295330880ed74ceaedda236253b4f39a335 Date: 2021-05-12T16:45:26.313Z Electron: 12.0.4 Chrome: 89.0.4389.114 Node.js: 14.16.0 V8: 8.9.255.24-electron.0 OS: Linux x64 5.8.0-53-generic

To reproduce

  • Install latest vscode from debian repositories (currently 1.56.2).
  • Install Remote SSH and CodeQL extensions.
  • Connect to a remote Linux host.
  • Add a codeql database folder (such as one present on the remote host)
  • In the Explorer, expand the database. Files are browsable. But select any file and an error will be thrown.

Expected behavior The source file should be opened.

Additional context This works correctly when working locally on both Linux hosts. It's only when working over SSH remotely that I have experienced this.

electricworry avatar May 27 '21 14:05 electricworry

Thanks for reporting. We are aware that the extension does not work well when used with the remote ssh extension. When we fix these issues, we will be sure that your use case is working as well.

aeisenberg avatar May 27 '21 17:05 aeisenberg

Hmm, is there a way we could disable the Choose Database from Archive / codeQLDatabases.chooseDatabaseArchive command in the UI just for remote users?

https://code.visualstudio.com/api/advanced-topics/remote-extensions#varying-behaviors-when-running-remotely-or-in-the-codespaces-browser-editor

I tried to see if I could add this myself, but not sure how to do it when the UI button is referenced here in a JSON file (instead of TypeScript):

https://github.com/github/vscode-codeql/blob/f856e3ac2c97aa364cfcd7a5982995f7c0c04d18/extensions/ql-vscode/package.json#L315-L322

Manouchehri avatar Aug 28 '21 04:08 Manouchehri

That code snippet is the declaration of the command. The command is bound to an action in this code:

https://github.com/github/vscode-codeql/blob/7eb12e000427d37a6a4dac817070e803adc3e529/extensions/ql-vscode/src/databases-ui.ts#L275-L283

If you wanted to change behaviour depending on the workspace kind, you would wrap the code above in some sort of if statement.

aeisenberg avatar Aug 30 '21 04:08 aeisenberg