Skip to content

Instantly share code, notes, and snippets.

@aeisenberg
Last active March 9, 2022 21:58
Show Gist options
  • Save aeisenberg/833c463c0bdbbf91f15b00ef637eb09b to your computer and use it in GitHub Desktop.
Save aeisenberg/833c463c0bdbbf91f15b00ef637eb09b to your computer and use it in GitHub Desktop.
How to get codeql working in codespaces

About Codespaces

Codespaces is a product from GitHub that allows users to use a hosted version of VS Code to edit their GitHub repositories online.

Getting CodeQL running in codespaces

  1. Fork the vscode-codeql-starter repo.
  2. Create and open a codespace on the main branch.
    vscode-codeql-starter
  3. Open the workspace file vscode-codeql-starter.code-workspace and make sure codespaces reloads so that it is using that workspace file. (This may happen automatically.)
  4. Install a QL database archive from somewhere on the internet or from your local machine (see below...)

If you want to use a database from LGTM

  1. In your browser, navigate to a project on LGTM, for example: https://lgtm.com/projects/g/jasmine/jasmine/
  2. Copy the project's URL.
  3. In VS Code, run the CodeQL: Download Database from LGTM command.
  4. Paste the project's URL when prompted.
  5. If prompted, select the language of the database you are downloading.
  6. The database will then be downloaded and installed into your workspace.

If you want to use a locally created database

  1. Zip a database on your local machine
  2. Drag and drop the zip file to the explorer tree in your codespace
  3. Right click on the uploaded file, and choose CodeQL: Set Current Database

If you want to use a database downloaded from somewhere on the internet

  1. In the databases view, click on the cloud icon and enter the url of the database you want to download

Note: must be a zip file, and must be publicly accessible.

(Optional) Use a custom version of the extension

If you want to run a custom version of the extension to grab some not-yet-released features:

  1. Get the download link of the extension to install
  2. Download to your local machine
  3. Drag and drop the zip file to the codespace
  4. Unzip the file to get a single file with a vsix extension
  5. In the .devcontainer/devcontainer.json file, delete the github.vscode-codeql line
  6. Run the command "Extensions: Install from VSIX"
  7. Select the unzipped vsix file
  8. You will need to reload the page after install
  9. Verify that your version of the extension is correct in the extensions tab.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment