vscode-codeql/extensions/ql-vscode
Shati Patel 4c7c1cb0e6
v1.8.1 (#2216)
2023-03-23 11:00:29 +00:00
..
.storybook Add additional Storybook VSCode themes 2022-11-29 16:49:04 +01:00
gulpfile.ts Do not copy `node_modules` when packaging 2023-03-08 16:18:55 +01:00
media Merge pull request #2007 from github/nora/query-history-sort-button 2023-01-26 10:43:20 +01:00
patches Use `Proxy` for `_VSCODE_NODE_MODULES` 2022-12-08 18:47:03 +01:00
scripts Rename `remote-queries` directories to `variant-analysis` 2023-02-17 11:38:24 +01:00
src Merge pull request #2212 from github/robertbrignull/app_executeCommand 2023-03-23 10:28:36 +00:00
syntaxes Fix comment 2022-08-23 16:42:57 -04:00
test Remove app.executeCommand 2023-03-22 17:13:12 +00:00
.eslintignore Combine ESLint configurations 2023-01-30 16:43:19 +01:00
.eslintrc.js Enable eslint rule to disallow awaiting a non-thenable type 2023-02-14 17:10:16 +00:00
.npmrc Add comment to .npmrc file for Storybook option 2022-09-08 09:22:08 +02:00
.nvmrc Release prep v1.7.1 2022-10-12 10:56:30 -07:00
.prettierignore Minor polish to the "bump CLI" automation (#1996) 2023-01-20 18:42:20 +00:00
.prettierrc Add Prettier 2022-11-16 19:04:17 +01:00
.vscodeignore Bundle extension files using ESBuild 2023-01-11 10:42:24 +02:00
CHANGELOG.md v1.8.1 (#2216) 2023-03-23 11:00:29 +00:00
README.md Renamed Run Query command (#1962) 2023-01-16 15:48:06 +00:00
databases-schema.json Added version to db config (#2029) 2023-02-02 11:50:16 +00:00
jest.config.js Create new activated-extension test suite 2023-02-08 11:52:55 +00:00
language-configuration.json Fix bad indentation on paste 2020-06-04 07:42:01 -07:00
package-lock.json Add styled-components as a top level dependency 2023-03-17 14:19:22 +00:00
package.json Add styled-components as a top level dependency 2023-03-17 14:19:22 +00:00
snippets.json Add some commonly used QL snippets 2021-03-17 08:43:00 -07:00
supported_cli_versions.json Bump CLI version from v2.12.4 to v2.12.5 for integration tests (#2197) 2023-03-21 16:27:58 +00:00
tsconfig.json Remove fs mocking from no-workspace tests 2023-01-11 10:43:24 +02:00
tsconfig.lint.json Combine ESLint configurations 2023-01-30 16:43:19 +01:00

README.md

CodeQL extension for Visual Studio Code

This project is an extension for Visual Studio Code that adds rich language support for CodeQL and allows you to easily find problems in codebases. In particular, the extension:

  • Enables you to use CodeQL to query databases generated from source code.
  • Shows the flow of data through the results of path queries, which is essential for triaging security results.
  • Provides an easy way to run queries from the large, open source repository of CodeQL security queries.
  • Adds IntelliSense to support you writing and editing your own CodeQL query and library files.

To see what has changed in the last few versions of the extension, see the Changelog.

Quick start overview

The information in this README file describes the quickest way to start using CodeQL. For information about other configurations, see the separate CodeQL help.

Quick start: Installing and configuring the extension

  1. Install the extension.
    Note: vscode-codeql installs the following dependencies for required functionality: Test Adapter Converter, Test Explorer UI.

  2. Check access to the CodeQL CLI.

  3. Clone the CodeQL starter workspace.

Quick start: Using CodeQL

  1. Import a database from GitHub.
  2. Run a query.

Quick start: Installing and configuring the extension

Installing the extension

The CodeQL extension requires a minimum of Visual Studio Code 1.39. Older versions are not supported.

  1. Install and open Visual Studio Code.
  2. Open the Extensions view (press Ctrl+Shift+X or Cmd+Shift+X).
  3. At the top of the Extensions view, type CodeQL in the box labeled Search Extensions in Marketplace.
  4. Locate the CodeQL extension and select Install. This will install the extension from the Visual Studio Marketplace.

Checking access to the CodeQL CLI

The extension uses the CodeQL CLI to compile and run queries. The extension automatically manages access to the CLI for you by default (recommended). To check for updates to the CodeQL CLI, you can use the CodeQL: Check for CLI Updates command.

If you want to override the default behavior and use a CodeQL CLI that's already on your machine, see Configuring access to the CodeQL CLI.

If you have any difficulty with CodeQL CLI access, see the CodeQL Extension Log in the Output view for any error messages.

Cloning the CodeQL starter workspace

When you're working with CodeQL, you need access to the standard CodeQL libraries and queries. Initially, we recommend that you clone and use the ready-to-use starter workspace. This includes libraries and queries for the main supported languages, with folders set up ready for your custom queries. After cloning the workspace (use git clone --recursive), you can use it in the same way as any other VS Code workspace—with the added advantage that you can easily update the CodeQL libraries.

For information about configuring an existing workspace for CodeQL, see the documentation.

Upgrading CodeQL standard libraries

You can easily keep up-to-date with the latest changes to the CodeQL standard libraries.

If you're using the CodeQL starter workspace, you can pull in the latest standard libraries by running:

git pull
git submodule update --recursive

in the starter workspace directory.

If you're using your own clone of the CodeQL standard libraries, you can do a git pull from where you have the libraries checked out.

Quick start: Using CodeQL

You can find all the commands contributed by the extension in the Command Palette (Ctrl+Shift+P or Cmd+Shift+P) by typing CodeQL, many of them are also accessible through the interface, and via keyboard shortcuts.

Importing a database from GitHub

While you can use the CodeQL CLI to create your own databases, the simplest way to start is by downloading a database from GitHub.com.

  1. Find a project that you're interested in on GitHub.com, for example Apache Kafka.
  2. Copy the link to that project, for example https://github.com/apache/kafka.
  3. In VS Code, open the Command Palette and choose the CodeQL: Download Database from GitHub command.
  4. Paste the link you copied earlier.
  5. Select the language for the database you want to download (only required if the project has databases for multiple languages).
  6. Once the CodeQL database has been imported, it is displayed in the Databases view.

For more information, see Choosing a database on codeql.github.com.

Running a query

The instructions below assume that you're using the CodeQL starter workspace, or that you've added the CodeQL libraries and queries repository to your workspace.

  1. Expand the ql folder and locate a query to run. The standard queries are grouped by target language and then type, for example: ql/java/ql/src/Likely Bugs.
  2. Open a query (.ql) file.
  3. Right-click in the query window and select CodeQL: Run Query on Selected Database. Alternatively, open the Command Palette (Ctrl+Shift+P or Cmd+Shift+P), type Run Query, then select CodeQL: Run Query on Selected Database.

The CodeQL extension runs the query on the current database using the CLI and reports progress in the bottom right corner of the application. When the results are ready, they're displayed in the CodeQL Query Results view. Use the dropdown menu to choose between different forms of result output.

If there are any problems running a query, a notification is displayed in the bottom right corner of the application. In addition to the error message, the notification includes details of how to fix the problem.

Keyboard navigation

If you wish to navigate the query results from your keyboard, you can bind shortcuts to the CodeQL: Navigate Up/Down/Left/Right in Result Viewer commands.

What next?

For more information about the CodeQL extension, see the documentation. Otherwise, you could:

License

The CodeQL extension for Visual Studio Code is licensed under the MIT License. The version of CodeQL used by the CodeQL extension is subject to the GitHub CodeQL Terms & Conditions.

Data and Telemetry

If you specifically opt-in to permit GitHub to do so, GitHub will collect usage data and metrics for the purposes of helping the core developers to improve the CodeQL extension for VS Code. This data will not be shared with any parties outside of GitHub. IP addresses and installation IDs will be retained for a maximum of 30 days. Anonymous data will be retained for a maximum of 180 days. For more information about telemetry, see the documentation.