Compare commits
137 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
728b8ca0fd | ||
|
|
edd5734de8 | ||
|
|
88a4cc528e | ||
|
|
a732f19a3d | ||
|
|
18c9333f37 | ||
|
|
010000b878 | ||
|
|
7b5f7499b4 | ||
|
|
292bec2ea5 | ||
|
|
910a877d06 | ||
|
|
80023f1304 | ||
|
|
8e8247e986 | ||
|
|
d92e0b5568 | ||
|
|
d3c1e7688e | ||
|
|
3e9c58869c | ||
|
|
c0a8c7affd | ||
|
|
f2575e4d4a | ||
|
|
87315b8f33 | ||
|
|
a338683a71 | ||
|
|
a541b11a37 | ||
|
|
e2771a8922 | ||
|
|
16e09b7ae9 | ||
|
|
1c1dbc95c7 | ||
|
|
dd9fafc27c | ||
|
|
7172505e25 | ||
|
|
7b99bdfc88 | ||
|
|
bb16454ab7 | ||
|
|
70529a81f3 | ||
|
|
7db6bc8228 | ||
|
|
41fab207dc | ||
|
|
a8bad9ecb8 | ||
|
|
17901bee0c | ||
|
|
e7d041af68 | ||
|
|
9afd676c1e | ||
|
|
7bf719f632 | ||
|
|
32622b1b9f | ||
|
|
8262ecf990 | ||
|
|
0817abd6ac | ||
|
|
821ec9b8f7 | ||
|
|
b0328b03a0 | ||
|
|
2d7d6fb873 | ||
|
|
b7201c04dc | ||
|
|
8db488563b | ||
|
|
fac5f98d80 | ||
|
|
fccec96926 | ||
|
|
8cadd3dcab | ||
|
|
d9e1a6f82a | ||
|
|
f47a88dcb1 | ||
|
|
8cab3e9c6f | ||
|
|
165f3957ed | ||
|
|
3e4eeeb8fd | ||
|
|
038e0a3c63 | ||
|
|
3e7084f65d | ||
|
|
18bb4b0231 | ||
|
|
8cb5661330 | ||
|
|
f6f2b99c67 | ||
|
|
b2c82029f6 | ||
|
|
d18b524c81 | ||
|
|
6be2c8bb95 | ||
|
|
c289f1f66f | ||
|
|
c2717d7725 | ||
|
|
74e42b86a6 | ||
|
|
6db514843b | ||
|
|
c8d64e4c35 | ||
|
|
0e4c3be404 | ||
|
|
dd1bdf54bb | ||
|
|
c01772848c | ||
|
|
ab09cdb66d | ||
|
|
d92edfb058 | ||
|
|
1e86e08851 | ||
|
|
c505996ca0 | ||
|
|
0796893017 | ||
|
|
6fdfade1ed | ||
|
|
e31f8b73ac | ||
|
|
f38d0fd08e | ||
|
|
579aba5abb | ||
|
|
31066be29e | ||
|
|
3bbecb248b | ||
|
|
691c9af1f7 | ||
|
|
a137a72e02 | ||
|
|
a98e3bc9ae | ||
|
|
4ffab3c16d | ||
|
|
bb3aa79dad | ||
|
|
7f34fcaa1c | ||
|
|
e42a39e5ec | ||
|
|
bd22878ec8 | ||
|
|
8dd1b9f44e | ||
|
|
2da70d774d | ||
|
|
2fddc9cff1 | ||
|
|
11d9bdc8e1 | ||
|
|
7d23a833b1 | ||
|
|
258322057f | ||
|
|
6ded193891 | ||
|
|
bb6b90646f | ||
|
|
fece068800 | ||
|
|
de8b7d44cd | ||
|
|
432c5c9ae7 | ||
|
|
59433af8be | ||
|
|
c6928d3159 | ||
|
|
fd26e02ed3 | ||
|
|
de381804f6 | ||
|
|
2f92477bd9 | ||
|
|
926ab92dfe | ||
|
|
36484fcea6 | ||
|
|
89e7b03d4a | ||
|
|
c3e3390647 | ||
|
|
010ae64da3 | ||
|
|
bd3702121f | ||
|
|
043d17d454 | ||
|
|
1c7cad0151 | ||
|
|
e0383b3f9a | ||
|
|
0d972d7916 | ||
|
|
ab020f24ae | ||
|
|
81cbf26910 | ||
|
|
2e2f101131 | ||
|
|
610d40c99c | ||
|
|
adf6f66517 | ||
|
|
8f84989d98 | ||
|
|
22c9386123 | ||
|
|
53e1794b50 | ||
|
|
307d6d7c7f | ||
|
|
a0e60fb154 | ||
|
|
8b5bdbb6ef | ||
|
|
0ad9cdd5ac | ||
|
|
c3b2e9d478 | ||
|
|
c20bbd9606 | ||
|
|
6080a0d585 | ||
|
|
9fda320589 | ||
|
|
143b51ef82 | ||
|
|
51d4c87af4 | ||
|
|
be5efc01ee | ||
|
|
08a30c454a | ||
|
|
1377969213 | ||
|
|
41f1aae71d | ||
|
|
62cae6ead1 | ||
|
|
39e3627e06 | ||
|
|
43586c91d9 | ||
|
|
31414b7506 |
21
.github/workflows/codeql.yml
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
name: "Code Scanning - CodeQL"
|
||||
|
||||
on:
|
||||
push:
|
||||
schedule:
|
||||
- cron: '0 0 * * 0'
|
||||
|
||||
jobs:
|
||||
codeql:
|
||||
strategy:
|
||||
fail-fast: false
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v2
|
||||
|
||||
- name: Initialize CodeQL
|
||||
uses: github/codeql-action/init@v1
|
||||
|
||||
- name: Perform CodeQL Analysis
|
||||
uses: github/codeql-action/analyze@v1
|
||||
18
.github/workflows/main.yml
vendored
@@ -18,11 +18,12 @@ jobs:
|
||||
with:
|
||||
node-version: '10.18.1'
|
||||
|
||||
- name: Install dependencies
|
||||
run: node common/scripts/install-run-rush.js install
|
||||
shell: bash
|
||||
|
||||
- name: Build
|
||||
run: |
|
||||
cd build
|
||||
npm install
|
||||
npm run build-ci
|
||||
run: node common/scripts/install-run-rush.js build
|
||||
shell: bash
|
||||
|
||||
- name: Prepare artifacts
|
||||
@@ -55,11 +56,12 @@ jobs:
|
||||
node-version: '10.18.1'
|
||||
|
||||
# We have to build the dependencies in `lib` before running any tests.
|
||||
- name: Install dependencies
|
||||
run: node common/scripts/install-run-rush.js install
|
||||
shell: bash
|
||||
|
||||
- name: Build
|
||||
run: |
|
||||
cd build
|
||||
npm install
|
||||
npm run build-ci
|
||||
run: node common/scripts/install-run-rush.js build
|
||||
shell: bash
|
||||
|
||||
- name: Lint
|
||||
|
||||
10
.github/workflows/release.yml
vendored
@@ -33,12 +33,12 @@ jobs:
|
||||
with:
|
||||
node-version: '10.18.1'
|
||||
|
||||
- name: Install dependencies
|
||||
run: node common/scripts/install-run-rush.js install
|
||||
shell: bash
|
||||
|
||||
- name: Build
|
||||
run: |
|
||||
cd build
|
||||
npm install
|
||||
# Release build instead of dev build.
|
||||
npm run build-release
|
||||
run: node common/scripts/install-run-rush.js build --release
|
||||
shell: bash
|
||||
|
||||
- name: Prepare artifacts
|
||||
|
||||
3
.vscode/launch.json
vendored
@@ -8,8 +8,7 @@
|
||||
"request": "launch",
|
||||
"runtimeExecutable": "${execPath}",
|
||||
"args": [
|
||||
"--extensionDevelopmentPath=${workspaceRoot}/dist/vscode-codeql",
|
||||
"${workspaceRoot}/../vscode-codeql-starter/vscode-codeql-starter.code-workspace"
|
||||
"--extensionDevelopmentPath=${workspaceRoot}/dist/vscode-codeql"
|
||||
],
|
||||
"stopOnEntry": false,
|
||||
"sourceMaps": true,
|
||||
|
||||
4
.vscode/settings.json
vendored
@@ -32,5 +32,7 @@
|
||||
"eslint.options": {
|
||||
// This is necessary so that eslint can properly resolve its plugins
|
||||
"resolvePluginsRelativeTo": "./extensions/ql-vscode"
|
||||
}
|
||||
},
|
||||
// Force this to false since this will cause too many changes on each commit
|
||||
"editor.formatOnSave": false
|
||||
}
|
||||
|
||||
@@ -1,12 +0,0 @@
|
||||
GitHub Actions Build directory
|
||||
===
|
||||
|
||||
The point of this directory is to allow us to do a local installation *of* the rush
|
||||
tool, since
|
||||
- installing globally is not permitted on github actions
|
||||
- installing locally in the root directory of the repo creates `node_modules` there,
|
||||
and rush itself gives error messages since it thinks `node_modules` is not supposed
|
||||
to exist, since rush is supposed to be managing subproject dependencies.
|
||||
|
||||
Running rush from a subdirectory searches parent directories for `rush.json`
|
||||
and does the build starting from that file's location.
|
||||
1293
build/package-lock.json
generated
@@ -1,17 +0,0 @@
|
||||
{
|
||||
"name": "build",
|
||||
"version": "1.0.0",
|
||||
"description": "",
|
||||
"main": "index.js",
|
||||
"dependencies": {
|
||||
"@microsoft/rush": "^5.10.3"
|
||||
},
|
||||
"devDependencies": {},
|
||||
"scripts": {
|
||||
"test": "echo \"Error: no test specified\" && exit 1",
|
||||
"build": "rush update && rush build",
|
||||
"build-ci": "rush install && rush build",
|
||||
"build-release": "rush install && rush build --release"
|
||||
},
|
||||
"author": "GitHub"
|
||||
}
|
||||
600
common/config/rush/pnpm-lock.yaml
generated
@@ -26,11 +26,9 @@ module.exports = {
|
||||
"@typescript-eslint/no-explicit-any": "off",
|
||||
"prefer-const": ["warn", {"destructuring": "all"}],
|
||||
"indent": "off",
|
||||
"@typescript-eslint/indent": ["error", 2, {
|
||||
"SwitchCase": 1,
|
||||
"FunctionDeclaration": { "body": 1, "parameters": 1 }
|
||||
}],
|
||||
"@typescript-eslint/indent": "off",
|
||||
"@typescript-eslint/no-throw-literal": "error",
|
||||
"no-useless-escape": 0
|
||||
"no-useless-escape": 0,
|
||||
"semi": 2
|
||||
},
|
||||
};
|
||||
|
||||
@@ -1,6 +1,39 @@
|
||||
# CodeQL for Visual Studio Code: Changelog
|
||||
|
||||
## 1.1.2
|
||||
## 1.2.1 - 29 May 2020
|
||||
|
||||
- Better formatting and autoindentation when adding QLDoc comments to `.ql` and `.qll` files.
|
||||
- Allow for more flexibility when opening a database in the workspace. A user can now choose the actual database folder, or the nested `db-*` folder.
|
||||
- Add query history menu command for viewing corresponding SARIF file.
|
||||
- Add ability for users to download databases directly from LGTM.com.
|
||||
|
||||
## 1.2.0 - 19 May 2020
|
||||
|
||||
- Enable 'Go to Definition' and 'Go to References' on source archive
|
||||
files in CodeQL databases. This is handled by a CodeQL query.
|
||||
- Fix adding database archive files on Windows.
|
||||
- Enable adding remote and local database archive files from the
|
||||
command palette.
|
||||
|
||||
## 1.1.5 - 15 May 2020
|
||||
|
||||
- Links in results are no longer underlined and monospaced.
|
||||
- Add the ability to choose a database either from an archive, a folder, or from the internet.
|
||||
- New icons for commands on the databases view.
|
||||
|
||||
## 1.1.4 - 13 May 2020
|
||||
|
||||
- Add the ability to download and install databases archives from the internet.
|
||||
|
||||
## 1.1.3 - 8 May 2020
|
||||
|
||||
- Add a suggestion in alerts view to view raw results, when there are
|
||||
raw results but no alerts.
|
||||
- Add the ability to rename databases in the database view.
|
||||
- Add the ability to open the directory in the filesystem
|
||||
of a database.
|
||||
|
||||
## 1.1.2 - 28 April 2020
|
||||
|
||||
- Implement syntax highlighting for the new `unique` aggregate.
|
||||
- Implement XML syntax highlighting for `.qhelp` files.
|
||||
@@ -49,7 +82,7 @@
|
||||
## 1.0.3 - 13 January 2020
|
||||
|
||||
- Reduce the frequency of CodeQL CLI update checks to help avoid hitting GitHub API limits of 60 requests per
|
||||
hour for unauthenticated IPs.
|
||||
hour for unauthenticated IPs.
|
||||
- Fix sorting of result sets with names containing special characters.
|
||||
|
||||
## 1.0.2 - 13 December 2019
|
||||
@@ -58,8 +91,7 @@ hour for unauthenticated IPs.
|
||||
- Allow customization of query history labels from settings and from
|
||||
query history view context menu.
|
||||
- Show number of results in results view.
|
||||
- Add commands `CodeQL: Show Next Step on Path` and `CodeQL: Show
|
||||
Previous Step on Path` for navigating the steps on the currently
|
||||
- Add commands `CodeQL: Show Next Step on Path` and `CodeQL: Show Previous Step on Path` for navigating the steps on the currently
|
||||
shown path result.
|
||||
|
||||
## 1.0.1 - 21 November 2019
|
||||
|
||||
@@ -2,10 +2,10 @@
|
||||
|
||||
This project is an extension for Visual Studio Code that adds rich language support for [CodeQL](https://help.semmle.com/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](https://github.com/Semmle/ql).
|
||||
* Adds IntelliSense to support you writing and editing your own CodeQL query and library files.
|
||||
- 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](https://github.com/github/codeql).
|
||||
- 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](https://github.com/github/vscode-codeql/blob/master/extensions/ql-vscode/CHANGELOG.md).
|
||||
|
||||
@@ -14,18 +14,18 @@ To see what has changed in the last few versions of the extension, see the [Chan
|
||||
The information in this `README` file describes the quickest way to start using CodeQL.
|
||||
For information about other configurations, see the separate [CodeQL help](https://help.semmle.com/codeql/codeql-for-vscode.html).
|
||||
|
||||
**Quick start: Installing and configuring the extension**
|
||||
### Quick start: Installing and configuring the extension
|
||||
|
||||
1. [Install the extension](#installing-the-extension).
|
||||
1. [Check access to the CodeQL CLI](#checking-access-to-the-codeql-cli).
|
||||
1. [Clone the CodeQL starter workspace](#cloning-the-codeql-starter-workspace).
|
||||
|
||||
**Quick start: Using CodeQL**
|
||||
### Quick start: Using CodeQL
|
||||
|
||||
1. [Import a database from LGTM](#importing-a-database-from-lgtm).
|
||||
1. [Run a query](#running-a-query).
|
||||
|
||||
-----
|
||||
---
|
||||
|
||||
## Quick start: Installing and configuring the extension
|
||||
|
||||
@@ -49,11 +49,26 @@ If you have any difficulty with CodeQL CLI access, see the **CodeQL Extension Lo
|
||||
### 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, https://github.com/github/vscode-codeql-starter/.
|
||||
Initially, we recommend that you clone and use the ready-to-use [starter workspace](https://github.com/github/vscode-codeql-starter/).
|
||||
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](https://help.semmle.com/codeql/codeql-for-vscode/procedures/setting-up.html#updating-an-existing-workspace-for-codeql).
|
||||
|
||||
## Upgrading CodeQL standard libraries
|
||||
|
||||
You can easily keep up-to-date with the latest changes to the [CodeQL standard libraries](https://github.com/github/codeql).
|
||||
|
||||
If you're using the [CodeQL starter workspace](https://github.com/github/vscode-codeql-starter/), you can pull in the latest standard libraries by running:
|
||||
|
||||
```shell
|
||||
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.
|
||||
@@ -62,16 +77,13 @@ You can find all the commands contributed by the extension in the Command Palett
|
||||
|
||||
While you can use the [CodeQL CLI to create your own databases](https://help.semmle.com/codeql/codeql-cli/procedures/create-codeql-database.html), the simplest way to start is by downloading a database from LGTM.com.
|
||||
|
||||
1. Log in to LGTM.com.
|
||||
1. Find a project you're interested in and display the **Integrations** tab (for example, [Apache Kafka](https://lgtm.com/projects/g/apache/kafka/ci/)).
|
||||
1. Scroll to the **CodeQL databases for local analysis** section at the bottom of the page.
|
||||
1. Download databases for the languages that you want to explore.
|
||||
1. Unzip the databases.
|
||||
1. For each database that you want to import:
|
||||
1. In the VS Code sidebar, go to **CodeQL** > **Databases** and click **+**.
|
||||
1. Browse to the unzipped database folder (the parent folder that contains `db-<language>` and `src`) and select **Choose database** to add it.
|
||||
|
||||
When the import is complete, each CodeQL database is displayed in the CodeQL sidebar under **Databases**.
|
||||
1. Open [LGTM.com](https://lgtm.com/#explore) in your browser.
|
||||
1. Search for a project you're interested in, for example [Apache Kafka](https://lgtm.com/projects/g/apache/kafka).
|
||||
1. Copy the link to that project, for example `https://lgtm.com/projects/g/apache/kafka`.
|
||||
1. In VS Code, open the Command Palette and choose the **CodeQL: Download Database from LGTM** command.
|
||||
1. Paste the link you copied earlier.
|
||||
1. Select the language for the database you want to download (only required if the project has databases for multiple languages).
|
||||
1. Once the CodeQL database has been imported, it is displayed in the Databases view.
|
||||
|
||||
### Running a query
|
||||
|
||||
@@ -79,7 +91,7 @@ The instructions below assume that you're using the CodeQL starter workspace, or
|
||||
|
||||
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`.
|
||||
1. Open a query (`.ql`) file.
|
||||
3. Right-click in the query window and select **CodeQL: Run Query**. Alternatively, open the Command Palette (**Ctrl+Shift+P** or **Cmd+Shift+P**), type `Run Query`, then select **CodeQL: Run Query**.
|
||||
1. Right-click in the query window and select **CodeQL: Run Query**. Alternatively, open the Command Palette (**Ctrl+Shift+P** or **Cmd+Shift+P**), type `Run Query`, then select **CodeQL: Run Query**.
|
||||
|
||||
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.
|
||||
@@ -90,10 +102,10 @@ If there are any problems running a query, a notification is displayed in the bo
|
||||
|
||||
For more information about the CodeQL extension, [see the documentation](https://help.semmle.com/codeql/codeql-for-vscode.html). Otherwise, you could:
|
||||
|
||||
* [Create a database for a different codebase](https://help.semmle.com/codeql/codeql-cli/procedures/create-codeql-database.html).
|
||||
* [Try out variant analysis](https://help.semmle.com/QL/learn-ql/ql-training.html).
|
||||
* [Learn more about CodeQL](https://help.semmle.com/QL/learn-ql/).
|
||||
* [Read how security researchers use CodeQL to find CVEs](https://securitylab.github.com/research).
|
||||
- [Create a database for a different codebase](https://help.semmle.com/codeql/codeql-cli/procedures/create-codeql-database.html).
|
||||
- [Try out variant analysis](https://help.semmle.com/QL/learn-ql/ql-training.html).
|
||||
- [Learn more about CodeQL](https://help.semmle.com/QL/learn-ql/).
|
||||
- [Read how security researchers use CodeQL to find CVEs](https://securitylab.github.com/research).
|
||||
|
||||
## License
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ export const config: webpack.Configuration = {
|
||||
path: path.resolve(__dirname, '..', 'out'),
|
||||
filename: "[name].js"
|
||||
},
|
||||
devtool: 'source-map',
|
||||
devtool: "inline-source-map",
|
||||
resolve: {
|
||||
extensions: ['.js', '.ts', '.tsx', '.json']
|
||||
},
|
||||
|
||||
@@ -1,72 +1,38 @@
|
||||
{
|
||||
"comments": {
|
||||
// symbol used for single line comment. Remove this entry if your language does not support line comments
|
||||
"lineComment": "//",
|
||||
// symbols used for start and end a block comment. Remove this entry if your language does not support block comments
|
||||
"blockComment": [
|
||||
"/*",
|
||||
"*/"
|
||||
]
|
||||
},
|
||||
// symbols used as brackets
|
||||
"brackets": [
|
||||
[
|
||||
"{",
|
||||
"}"
|
||||
],
|
||||
[
|
||||
"[",
|
||||
"]"
|
||||
],
|
||||
[
|
||||
"(",
|
||||
")"
|
||||
]
|
||||
],
|
||||
// symbols that are auto closed when typing
|
||||
"autoClosingPairs": [
|
||||
[
|
||||
"{",
|
||||
"}"
|
||||
],
|
||||
[
|
||||
"[",
|
||||
"]"
|
||||
],
|
||||
[
|
||||
"(",
|
||||
")"
|
||||
],
|
||||
[
|
||||
"\"",
|
||||
"\""
|
||||
],
|
||||
[
|
||||
"'",
|
||||
"'"
|
||||
]
|
||||
],
|
||||
// symbols that that can be used to surround a selection
|
||||
"surroundingPairs": [
|
||||
[
|
||||
"{",
|
||||
"}"
|
||||
],
|
||||
[
|
||||
"[",
|
||||
"]"
|
||||
],
|
||||
[
|
||||
"(",
|
||||
")"
|
||||
],
|
||||
[
|
||||
"\"",
|
||||
"\""
|
||||
],
|
||||
[
|
||||
"'",
|
||||
"'"
|
||||
]
|
||||
]
|
||||
}
|
||||
"comments": {
|
||||
"lineComment": "//",
|
||||
"blockComment": ["/*", "*/"]
|
||||
},
|
||||
"brackets": [
|
||||
["{", "}"],
|
||||
["[", "]"],
|
||||
["(", ")"]
|
||||
],
|
||||
"autoClosingPairs": [
|
||||
{ "open": "{", "close": "}" },
|
||||
{ "open": "[", "close": "]" },
|
||||
{ "open": "(", "close": ")" },
|
||||
{ "open": "'", "close": "'", "notIn": ["string", "comment"] },
|
||||
{ "open": "\"", "close": "\"", "notIn": ["string"] },
|
||||
{ "open": "/**", "close": " */", "notIn": ["string"] }
|
||||
],
|
||||
"autoCloseBefore": ";:.=}])> \n\t",
|
||||
"surroundingPairs": [
|
||||
["{", "}"],
|
||||
["[", "]"],
|
||||
["(", ")"],
|
||||
["'", "'"],
|
||||
["\"", "\""]
|
||||
],
|
||||
"folding": {
|
||||
"markers": {
|
||||
"start": "^\\s*//\\s*#?region\\b",
|
||||
"end": "^\\s*//\\s*#?endregion\\b"
|
||||
}
|
||||
},
|
||||
"wordPattern": "(-?\\d*\\.\\d\\w*)|([^\\~\\!\\@\\#\\%\\^\\&\\*\\(\\)\\-\\=\\+\\[\\{\\]\\}\\\\\\|\\;\\:\\'\\\"\\.\\<\\>\\/\\?\\s]+)",
|
||||
"indentationRules": {
|
||||
"increaseIndentPattern": "^((?!.*?\\/\\*).*\\*/)?\\s*[\\}\\]].*$",
|
||||
"decreaseIndentPattern": "^((?!\\/\\/).)*(\\{[^}\"']*|\\([^)\"']*|\\[[^\\]\"']*)$"
|
||||
}
|
||||
}
|
||||
|
||||
5
extensions/ql-vscode/media/dark/archive-plus.svg
Normal file
@@ -0,0 +1,5 @@
|
||||
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<path fill-rule="evenodd" clip-rule="evenodd" d="M14.5 1H1.5L1 1.5V4.5L1.5 5H2V13.5L2.5 14H13.5L14 13.5V5H14.5L15 4.5V1.5L14.5 1ZM13.5 4H2.5H2V2H14V4H13.5ZM3 13V5H13V13H3ZM11 7H5V8H11V7Z" fill="#C5C5C5"/>
|
||||
<line y2="12" x2="8" y1="12" x1="16" stroke-width="1" stroke="green" fill="none"/>
|
||||
<line y2="8" x2="12" y1="16" x1="12" stroke-width="1" stroke="green" fill="none"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 473 B |
3
extensions/ql-vscode/media/dark/cloud-download.svg
Normal file
@@ -0,0 +1,3 @@
|
||||
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<path fill-rule="evenodd" clip-rule="evenodd" d="M11.9565 6H12.0064C12.8004 6 13.5618 6.31607 14.1232 6.87868C14.6846 7.44129 15 8.20435 15 9C15 9.79565 14.6846 10.5587 14.1232 11.1213C13.5618 11.6839 12.8004 12 12.0064 12V11C12.5357 11 13.0434 10.7893 13.4176 10.4142C13.7919 10.0391 14.0021 9.53044 14.0021 9C14.0021 8.46957 13.7919 7.96086 13.4176 7.58579C13.0434 7.21072 12.5357 7 12.0064 7H11.0924L10.9687 6.143C10.8938 5.60541 10.6456 5.10711 10.2618 4.72407C9.87801 4.34103 9.37977 4.09427 8.84303 4.02143C8.30629 3.94859 7.76051 4.05365 7.2889 4.3206C6.81729 4.58754 6.44573 5.00173 6.23087 5.5L5.89759 6.262L5.08933 6.073C4.90382 6.02699 4.71364 6.0025 4.52255 6C3.86093 6 3.22641 6.2634 2.75858 6.73224C2.29075 7.20108 2.02792 7.83696 2.02792 8.5C2.02792 9.16304 2.29075 9.79893 2.75858 10.2678C3.22641 10.7366 3.86093 11 4.52255 11H5.02148V12H4.52255C4.02745 12.0043 3.5371 11.903 3.08403 11.7029C2.63096 11.5028 2.22553 11.2084 1.89461 10.8394C1.5637 10.4703 1.31488 10.0349 1.16465 9.56211C1.01442 9.08932 0.966217 8.58992 1.02324 8.09704C1.08026 7.60416 1.24121 7.12906 1.4954 6.70326C1.74959 6.27745 2.09121 5.91068 2.49762 5.62727C2.90402 5.34385 3.36591 5.15027 3.85264 5.05937C4.33938 4.96847 4.83984 4.98232 5.32083 5.1C5.6241 4.40501 6.14511 3.82799 6.80496 3.45635C7.4648 3.08472 8.22753 2.9387 8.9776 3.04044C9.72768 3.14217 10.4242 3.4861 10.9618 4.02014C11.4993 4.55418 11.8485 5.24923 11.9565 6ZM6.70719 11.1214L8.0212 12.4354V7H9.01506V12.3992L10.2929 11.1214L11 11.8285L8.85356 13.9749H8.14645L6.00008 11.8285L6.70719 11.1214Z" fill="#C5C5C5"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 1.6 KiB |
5
extensions/ql-vscode/media/dark/folder-opened-plus.svg
Normal file
@@ -0,0 +1,5 @@
|
||||
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<path d="M0.5 14H12.5L12.98 13.63L15.61 6.63L15.13 6H13V3.5L12.5 3H6.70996L5.84998 2.15002L5.5 2H0.5L0 2.5V13.5L0.5 14ZM1 3H5.29004L6.15002 3.84998L6.5 4H12V6H8.5L8.15002 6.15002L7.29004 7H2.5L2.03003 7.33997L1.03003 10.42L1 3ZM12.13 13H1.18994L2.85999 8H7.5L7.84998 7.84998L8.70996 7H14.5L12.13 13Z" fill="#C5C5C5"/>
|
||||
<line y2="12" x2="8" y1="12" x1="16" stroke-width="1" stroke="green" fill="none"/>
|
||||
<line y2="8" x2="12" y1="16" x1="12" stroke-width="1" stroke="green" fill="none"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 586 B |
5
extensions/ql-vscode/media/dark/lgtm-plus.svg
Normal file
@@ -0,0 +1,5 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 32 32" fill="none">
|
||||
<path d="M16.010 6.49c-3.885 0-7.167 0.906-9.328 2.813-0.063-0.12-0.109-0.219-0.188-0.339-0.224-0.365-0.438-0.776-1.104-1.188-0.411-0.26-0.87-0.438-1.349-0.516-0.208-0.021-0.422-0.021-0.63 0l0.135-0.016c-1.214 0-1.922 0.724-2.385 1.354-0.458 0.625-0.755 1.328-0.948 2.099-0.38 1.542-0.385 3.536 1.083 5.026 0.766 0.781 1.667 1.151 2.484 1.37 0.156 0.042 0.297 0.052 0.448 0.083 0.531 2.521 2.104 4.656 4.208 5.839v0.005c1.24 0.693 2.417 1.010 3.297 1.349 1.234 0.479 2.536 1 4.052 1.135l0.078 0.005h0.198c1.745 0 3.063-0.703 4.203-1.141 0.875-0.333 2.052-0.641 3.302-1.344 0.578-0.323 1.115-0.719 1.594-1.172 1.318-1.234 2.229-2.839 2.625-4.599 1.115-0.182 2.141-0.719 2.922-1.536 1.464-1.484 1.458-3.479 1.078-5.021-0.193-0.771-0.49-1.474-0.948-2.099-0.458-0.63-1.172-1.354-2.385-1.354l0.135 0.016c-0.208-0.021-0.422-0.021-0.63 0-0.479 0.078-0.938 0.255-1.344 0.516-0.667 0.411-0.88 0.823-1.104 1.182-0.073 0.12-0.12 0.219-0.188 0.333-2.156-1.901-5.432-2.802-9.313-2.802zM16.042 8.313c4.745 0 8.016 1.422 9.411 3.964 0.839-0.323 1.453-2.521 2.146-2.948 0.563-0.344 0.885-0.26 0.885-0.26 1.271 0 2.578 3.729 0.953 5.38-0.859 0.875-2.443 1.12-3.229 1.057-0.063 2.542-1.542 4.833-3.5 5.932-1 0.563-2.068 0.854-3.063 1.234-1.229 0.469-2.38 1.016-3.547 1.016h-0.125c-1.161-0.099-2.318-0.542-3.547-1.016-0.995-0.38-2.068-0.682-3.063-1.24-1.948-1.099-3.427-3.391-3.49-5.927-0.781 0.068-2.385-0.177-3.245-1.057-1.625-1.651-0.318-5.38 0.948-5.38 0 0 0.328-0.083 0.885 0.26 0.698 0.427 1.318 2.646 2.161 2.953 1.391-2.547 4.667-3.969 9.417-3.969zM10.875 11.422c-2.276-0.042-4.146 1.792-4.146 4.068 0 2.281 1.87 4.115 4.146 4.073 5.328-0.099 5.328-8.047 0-8.141zM21.208 11.422c-5.427 0-5.427 8.141 0 8.141s5.427-8.141 0-8.141zM11.453 13.708c2.349 0.063 2.349 3.552 0 3.615-1.182 0-2.042-1.115-1.75-2.255 0.318 0.771 1.469 0.547 1.464-0.292 0-0.406-0.318-0.745-0.729-0.76 0.302-0.203 0.656-0.313 1.016-0.307zM20.641 13.708c2.344 0.063 2.344 3.552 0 3.615-1.182 0-2.047-1.115-1.755-2.255 0.229 0.552 0.979 0.641 1.328 0.146 0.344-0.49 0.010-1.167-0.589-1.193 0.297-0.208 0.651-0.313 1.016-0.313zM15.359 19.906c-0.318 0.026-0.5 0.193-0.5 0.635 0 0.281 0.182 0.484 0.5 0.484 0.229 0 0.266-0.323 0.047-0.375-0.031-0.005-0.172-0.057-0.172-0.182 0-0.12 0-0.167 0.24-0.198 0.104-0.016 0.156-0.141 0.125-0.24s-0.125-0.135-0.24-0.125zM16.724 19.906c-0.115-0.005-0.208 0.026-0.24 0.125s0.021 0.224 0.125 0.24c0.24 0.031 0.24 0.078 0.24 0.198 0 0.125-0.141 0.177-0.172 0.182-0.219 0.052-0.182 0.375 0.042 0.375 0.323 0 0.51-0.203 0.51-0.484 0-0.443-0.188-0.609-0.505-0.635z" fill="#C5C5C5"/>
|
||||
<line y2="24" x2="16" y1="26" x1="32" stroke-width="2" stroke="green" fill="none"/>
|
||||
<line y2="16" x2="24" y1="32" x1="24" stroke-width="1" stroke="green" fill="none"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 2.8 KiB |
5
extensions/ql-vscode/media/light/archive-plus.svg
Normal file
@@ -0,0 +1,5 @@
|
||||
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<path fill-rule="evenodd" clip-rule="evenodd" d="M14.5 1H1.5L1 1.5V4.5L1.5 5H2V13.5L2.5 14H13.5L14 13.5V5H14.5L15 4.5V1.5L14.5 1ZM13.5 4H2.5H2V2H14V4H13.5ZM3 13V5H13V13H3ZM11 7H5V8H11V7Z" fill="#424242"/>
|
||||
<line y2="12" x2="8" y1="12" x1="16" stroke-width="1" stroke="green" fill="none"/>
|
||||
<line y2="8" x2="12" y1="16" x1="12" stroke-width="1" stroke="green" fill="none"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 473 B |
3
extensions/ql-vscode/media/light/cloud-download.svg
Normal file
@@ -0,0 +1,3 @@
|
||||
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<path fill-rule="evenodd" clip-rule="evenodd" d="M11.9565 6H12.0064C12.8004 6 13.5618 6.31607 14.1232 6.87868C14.6846 7.44129 15 8.20435 15 9C15 9.79565 14.6846 10.5587 14.1232 11.1213C13.5618 11.6839 12.8004 12 12.0064 12V11C12.5357 11 13.0434 10.7893 13.4176 10.4142C13.7919 10.0391 14.0021 9.53044 14.0021 9C14.0021 8.46957 13.7919 7.96086 13.4176 7.58579C13.0434 7.21072 12.5357 7 12.0064 7H11.0924L10.9687 6.143C10.8938 5.60541 10.6456 5.10711 10.2618 4.72407C9.87801 4.34103 9.37977 4.09427 8.84303 4.02143C8.30629 3.94859 7.76051 4.05365 7.2889 4.3206C6.81729 4.58754 6.44573 5.00173 6.23087 5.5L5.89759 6.262L5.08933 6.073C4.90382 6.02699 4.71364 6.0025 4.52255 6C3.86093 6 3.22641 6.2634 2.75858 6.73224C2.29075 7.20108 2.02792 7.83696 2.02792 8.5C2.02792 9.16304 2.29075 9.79893 2.75858 10.2678C3.22641 10.7366 3.86093 11 4.52255 11H5.02148V12H4.52255C4.02745 12.0043 3.5371 11.903 3.08403 11.7029C2.63096 11.5028 2.22553 11.2084 1.89461 10.8394C1.5637 10.4703 1.31488 10.0349 1.16465 9.56211C1.01442 9.08932 0.966217 8.58992 1.02324 8.09704C1.08026 7.60416 1.24121 7.12906 1.4954 6.70326C1.74959 6.27745 2.09121 5.91068 2.49762 5.62727C2.90402 5.34385 3.36591 5.15027 3.85264 5.05937C4.33938 4.96847 4.83984 4.98232 5.32083 5.1C5.6241 4.40501 6.14511 3.82799 6.80496 3.45635C7.4648 3.08472 8.22753 2.9387 8.9776 3.04044C9.72768 3.14217 10.4242 3.4861 10.9618 4.02014C11.4993 4.55418 11.8485 5.24923 11.9565 6ZM6.70719 11.1214L8.0212 12.4354V7H9.01506V12.3992L10.2929 11.1214L11 11.8285L8.85356 13.9749H8.14645L6.00008 11.8285L6.70719 11.1214Z" fill="#424242"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 1.6 KiB |
12
extensions/ql-vscode/media/light/folder-opened-plus.svg
Normal file
@@ -0,0 +1,12 @@
|
||||
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<g clip-path="url(#clip0)">
|
||||
<path d="M0.499817 14H12.4998L12.9798 13.63L15.6098 6.63L15.1298 6H12.9998V3.5L12.4998 3H6.70978L5.84979 2.15002L5.49982 2H0.499817L-0.000183105 2.5V13.5L0.499817 14ZM0.999817 3H5.28986L6.14984 3.84998L6.49982 4H11.9998V6H8.49982L8.14984 6.15002L7.28986 7H2.49982L2.02985 7.33997L1.02985 10.42L0.999817 3ZM12.1298 13H1.18976L2.8598 8H7.49982L7.84979 7.84998L8.70978 7H14.4998L12.1298 13Z" fill="#424242"/>
|
||||
<line y2="12" x2="8" y1="12" x1="16" stroke-width="1" stroke="green" fill="none"/>
|
||||
<line y2="8" x2="12" y1="16" x1="12" stroke-width="1" stroke="green" fill="none"/>
|
||||
</g>
|
||||
<defs>
|
||||
<clipPath id="clip0">
|
||||
<path d="M-0.000183105 0H15.9998V16H-0.000183105V0Z" fill="white"/>
|
||||
</clipPath>
|
||||
</defs>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 824 B |
5
extensions/ql-vscode/media/light/lgtm-plus.svg
Normal file
@@ -0,0 +1,5 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 32 32" fill="none">
|
||||
<path d="M16.010 6.49c-3.885 0-7.167 0.906-9.328 2.813-0.063-0.12-0.109-0.219-0.188-0.339-0.224-0.365-0.438-0.776-1.104-1.188-0.411-0.26-0.87-0.438-1.349-0.516-0.208-0.021-0.422-0.021-0.63 0l0.135-0.016c-1.214 0-1.922 0.724-2.385 1.354-0.458 0.625-0.755 1.328-0.948 2.099-0.38 1.542-0.385 3.536 1.083 5.026 0.766 0.781 1.667 1.151 2.484 1.37 0.156 0.042 0.297 0.052 0.448 0.083 0.531 2.521 2.104 4.656 4.208 5.839v0.005c1.24 0.693 2.417 1.010 3.297 1.349 1.234 0.479 2.536 1 4.052 1.135l0.078 0.005h0.198c1.745 0 3.063-0.703 4.203-1.141 0.875-0.333 2.052-0.641 3.302-1.344 0.578-0.323 1.115-0.719 1.594-1.172 1.318-1.234 2.229-2.839 2.625-4.599 1.115-0.182 2.141-0.719 2.922-1.536 1.464-1.484 1.458-3.479 1.078-5.021-0.193-0.771-0.49-1.474-0.948-2.099-0.458-0.63-1.172-1.354-2.385-1.354l0.135 0.016c-0.208-0.021-0.422-0.021-0.63 0-0.479 0.078-0.938 0.255-1.344 0.516-0.667 0.411-0.88 0.823-1.104 1.182-0.073 0.12-0.12 0.219-0.188 0.333-2.156-1.901-5.432-2.802-9.313-2.802zM16.042 8.313c4.745 0 8.016 1.422 9.411 3.964 0.839-0.323 1.453-2.521 2.146-2.948 0.563-0.344 0.885-0.26 0.885-0.26 1.271 0 2.578 3.729 0.953 5.38-0.859 0.875-2.443 1.12-3.229 1.057-0.063 2.542-1.542 4.833-3.5 5.932-1 0.563-2.068 0.854-3.063 1.234-1.229 0.469-2.38 1.016-3.547 1.016h-0.125c-1.161-0.099-2.318-0.542-3.547-1.016-0.995-0.38-2.068-0.682-3.063-1.24-1.948-1.099-3.427-3.391-3.49-5.927-0.781 0.068-2.385-0.177-3.245-1.057-1.625-1.651-0.318-5.38 0.948-5.38 0 0 0.328-0.083 0.885 0.26 0.698 0.427 1.318 2.646 2.161 2.953 1.391-2.547 4.667-3.969 9.417-3.969zM10.875 11.422c-2.276-0.042-4.146 1.792-4.146 4.068 0 2.281 1.87 4.115 4.146 4.073 5.328-0.099 5.328-8.047 0-8.141zM21.208 11.422c-5.427 0-5.427 8.141 0 8.141s5.427-8.141 0-8.141zM11.453 13.708c2.349 0.063 2.349 3.552 0 3.615-1.182 0-2.042-1.115-1.75-2.255 0.318 0.771 1.469 0.547 1.464-0.292 0-0.406-0.318-0.745-0.729-0.76 0.302-0.203 0.656-0.313 1.016-0.307zM20.641 13.708c2.344 0.063 2.344 3.552 0 3.615-1.182 0-2.047-1.115-1.755-2.255 0.229 0.552 0.979 0.641 1.328 0.146 0.344-0.49 0.010-1.167-0.589-1.193 0.297-0.208 0.651-0.313 1.016-0.313zM15.359 19.906c-0.318 0.026-0.5 0.193-0.5 0.635 0 0.281 0.182 0.484 0.5 0.484 0.229 0 0.266-0.323 0.047-0.375-0.031-0.005-0.172-0.057-0.172-0.182 0-0.12 0-0.167 0.24-0.198 0.104-0.016 0.156-0.141 0.125-0.24s-0.125-0.135-0.24-0.125zM16.724 19.906c-0.115-0.005-0.208 0.026-0.24 0.125s0.021 0.224 0.125 0.24c0.24 0.031 0.24 0.078 0.24 0.198 0 0.125-0.141 0.177-0.172 0.182-0.219 0.052-0.182 0.375 0.042 0.375 0.323 0 0.51-0.203 0.51-0.484 0-0.443-0.188-0.609-0.505-0.635z" fill="#424242"/>
|
||||
<line y2="24" x2="16" y1="26" x1="32" stroke-width="2" stroke="green" fill="none"/>
|
||||
<line y2="16" x2="24" y1="32" x1="24" stroke-width="1" stroke="green" fill="none"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 2.8 KiB |
@@ -4,7 +4,7 @@
|
||||
"description": "CodeQL for Visual Studio Code",
|
||||
"author": "GitHub",
|
||||
"private": true,
|
||||
"version": "1.1.2",
|
||||
"version": "1.2.1",
|
||||
"publisher": "GitHub",
|
||||
"license": "MIT",
|
||||
"icon": "media/VS-marketplace-CodeQL-icon.png",
|
||||
@@ -27,8 +27,15 @@
|
||||
"onView:codeQLQueryHistory",
|
||||
"onView:test-explorer",
|
||||
"onCommand:codeQL.checkForUpdatesToCLI",
|
||||
"onCommand:codeQL.chooseDatabase",
|
||||
"onCommand:codeQLDatabases.chooseDatabaseFolder",
|
||||
"onCommand:codeQLDatabases.chooseDatabaseArchive",
|
||||
"onCommand:codeQLDatabases.chooseDatabaseInternet",
|
||||
"onCommand:codeQLDatabases.chooseDatabaseLgtm",
|
||||
"onCommand:codeQL.setCurrentDatabase",
|
||||
"onCommand:codeQL.chooseDatabaseFolder",
|
||||
"onCommand:codeQL.chooseDatabaseArchive",
|
||||
"onCommand:codeQL.chooseDatabaseInternet",
|
||||
"onCommand:codeQL.chooseDatabaseLgtm",
|
||||
"onCommand:codeQLDatabases.chooseDatabase",
|
||||
"onCommand:codeQLDatabases.setCurrentDatabase",
|
||||
"onCommand:codeQL.quickQuery",
|
||||
@@ -80,9 +87,6 @@
|
||||
},
|
||||
{
|
||||
"id": "xml",
|
||||
"aliases": [
|
||||
"qhelp"
|
||||
],
|
||||
"extensions": [
|
||||
".qhelp"
|
||||
]
|
||||
@@ -175,11 +179,35 @@
|
||||
"title": "CodeQL: Quick Query"
|
||||
},
|
||||
{
|
||||
"command": "codeQL.chooseDatabase",
|
||||
"title": "CodeQL: Choose Database",
|
||||
"command": "codeQLDatabases.chooseDatabaseFolder",
|
||||
"title": "Choose Database from Folder",
|
||||
"icon": {
|
||||
"light": "media/light/plus.svg",
|
||||
"dark": "media/dark/plus.svg"
|
||||
"light": "media/light/folder-opened-plus.svg",
|
||||
"dark": "media/dark/folder-opened-plus.svg"
|
||||
}
|
||||
},
|
||||
{
|
||||
"command": "codeQLDatabases.chooseDatabaseArchive",
|
||||
"title": "Choose Database from Archive",
|
||||
"icon": {
|
||||
"light": "media/light/archive-plus.svg",
|
||||
"dark": "media/dark/archive-plus.svg"
|
||||
}
|
||||
},
|
||||
{
|
||||
"command": "codeQLDatabases.chooseDatabaseInternet",
|
||||
"title": "Download Database",
|
||||
"icon": {
|
||||
"light": "media/light/cloud-download.svg",
|
||||
"dark": "media/dark/cloud-download.svg"
|
||||
}
|
||||
},
|
||||
{
|
||||
"command": "codeQLDatabases.chooseDatabaseLgtm",
|
||||
"title": "Download from LGTM",
|
||||
"icon": {
|
||||
"light": "media/light/lgtm-plus.svg",
|
||||
"dark": "media/dark/lgtm-plus.svg"
|
||||
}
|
||||
},
|
||||
{
|
||||
@@ -206,6 +234,30 @@
|
||||
"command": "codeQLDatabases.upgradeDatabase",
|
||||
"title": "Upgrade Database"
|
||||
},
|
||||
{
|
||||
"command": "codeQLDatabases.renameDatabase",
|
||||
"title": "Rename Database"
|
||||
},
|
||||
{
|
||||
"command": "codeQLDatabases.openDatabaseFolder",
|
||||
"title": "Show Database Directory"
|
||||
},
|
||||
{
|
||||
"command": "codeQL.chooseDatabaseFolder",
|
||||
"title": "CodeQL: Choose Database from Folder"
|
||||
},
|
||||
{
|
||||
"command": "codeQL.chooseDatabaseArchive",
|
||||
"title": "CodeQL: Choose Database from Archive"
|
||||
},
|
||||
{
|
||||
"command": "codeQL.chooseDatabaseInternet",
|
||||
"title": "CodeQL: Download Database"
|
||||
},
|
||||
{
|
||||
"command": "codeQL.chooseDatabaseLgtm",
|
||||
"title": "CodeQL: Download Database from LGTM"
|
||||
},
|
||||
{
|
||||
"command": "codeQLDatabases.sortByName",
|
||||
"title": "Sort by Name",
|
||||
@@ -246,6 +298,10 @@
|
||||
"command": "codeQLQueryHistory.showQueryText",
|
||||
"title": "Show Query Text"
|
||||
},
|
||||
{
|
||||
"command": "codeQLQueryHistory.viewSarif",
|
||||
"title": "View SARIF"
|
||||
},
|
||||
{
|
||||
"command": "codeQLQueryResults.nextPathStep",
|
||||
"title": "CodeQL: Show Next Step on Path"
|
||||
@@ -284,7 +340,22 @@
|
||||
"group": "navigation"
|
||||
},
|
||||
{
|
||||
"command": "codeQL.chooseDatabase",
|
||||
"command": "codeQLDatabases.chooseDatabaseFolder",
|
||||
"when": "view == codeQLDatabases",
|
||||
"group": "navigation"
|
||||
},
|
||||
{
|
||||
"command": "codeQLDatabases.chooseDatabaseArchive",
|
||||
"when": "view == codeQLDatabases",
|
||||
"group": "navigation"
|
||||
},
|
||||
{
|
||||
"command": "codeQLDatabases.chooseDatabaseInternet",
|
||||
"when": "view == codeQLDatabases",
|
||||
"group": "navigation"
|
||||
},
|
||||
{
|
||||
"command": "codeQLDatabases.chooseDatabaseLgtm",
|
||||
"when": "view == codeQLDatabases",
|
||||
"group": "navigation"
|
||||
}
|
||||
@@ -305,6 +376,16 @@
|
||||
"group": "9_qlCommands",
|
||||
"when": "view == codeQLDatabases"
|
||||
},
|
||||
{
|
||||
"command": "codeQLDatabases.renameDatabase",
|
||||
"group": "9_qlCommands",
|
||||
"when": "view == codeQLDatabases"
|
||||
},
|
||||
{
|
||||
"command": "codeQLDatabases.openDatabaseFolder",
|
||||
"group": "9_qlCommands",
|
||||
"when": "view == codeQLDatabases"
|
||||
},
|
||||
{
|
||||
"command": "codeQLQueryHistory.openQuery",
|
||||
"group": "9_qlCommands",
|
||||
@@ -330,6 +411,11 @@
|
||||
"group": "9_qlCommands",
|
||||
"when": "view == codeQLQueryHistory"
|
||||
},
|
||||
{
|
||||
"command": "codeQLQueryHistory.viewSarif",
|
||||
"group": "9_qlCommands",
|
||||
"when": "view == codeQLQueryHistory && viewItem == interpretedResultsItem"
|
||||
},
|
||||
{
|
||||
"command": "codeQLTests.showOutputDifferences",
|
||||
"group": "qltest@1",
|
||||
@@ -345,7 +431,7 @@
|
||||
{
|
||||
"command": "codeQL.setCurrentDatabase",
|
||||
"group": "9_qlCommands",
|
||||
"when": "resourceScheme == codeql-zip-archive || explorerResourceIsFolder"
|
||||
"when": "resourceScheme == codeql-zip-archive || explorerResourceIsFolder || resourceExtname == .zip"
|
||||
},
|
||||
{
|
||||
"command": "codeQL.runQuery",
|
||||
@@ -370,6 +456,14 @@
|
||||
"command": "codeQLDatabases.setCurrentDatabase",
|
||||
"when": "false"
|
||||
},
|
||||
{
|
||||
"command": "codeQLDatabases.renameDatabase",
|
||||
"when": "false"
|
||||
},
|
||||
{
|
||||
"command": "codeQLDatabases.openDatabaseFolder",
|
||||
"when": "false"
|
||||
},
|
||||
{
|
||||
"command": "codeQLDatabases.sortByName",
|
||||
"when": "false"
|
||||
@@ -382,6 +476,26 @@
|
||||
"command": "codeQLDatabases.removeDatabase",
|
||||
"when": "false"
|
||||
},
|
||||
{
|
||||
"command": "codeQLDatabases.chooseDatabaseFolder",
|
||||
"when": "false"
|
||||
},
|
||||
{
|
||||
"command": "codeQLDatabases.chooseDatabaseArchive",
|
||||
"when": "false"
|
||||
},
|
||||
{
|
||||
"command": "codeQLDatabases.chooseDatabaseInternet",
|
||||
"when": "false"
|
||||
},
|
||||
{
|
||||
"command": "codeQLDatabases.chooseDatabaseLgtm",
|
||||
"when": "false"
|
||||
},
|
||||
{
|
||||
"command": "codeQLDatabases.upgradeDatabase",
|
||||
"when": "false"
|
||||
},
|
||||
{
|
||||
"command": "codeQLQueryHistory.openQuery",
|
||||
"when": "false"
|
||||
@@ -402,6 +516,10 @@
|
||||
"command": "codeQLQueryHistory.showQueryText",
|
||||
"when": "false"
|
||||
},
|
||||
{
|
||||
"command": "codeQLQueryHistory.viewSarif",
|
||||
"when": "false"
|
||||
},
|
||||
{
|
||||
"command": "codeQLQueryHistory.setLabel",
|
||||
"when": "false"
|
||||
@@ -448,9 +566,10 @@
|
||||
"preintegration": "rm -rf ./out/vscode-tests && gulp",
|
||||
"integration": "node ./out/vscode-tests/run-integration-tests.js",
|
||||
"update-vscode": "node ./node_modules/vscode/bin/install",
|
||||
"postinstall": "node ./node_modules/vscode/bin/install",
|
||||
"postinstall": "npm rebuild && node ./node_modules/vscode/bin/install",
|
||||
"format": "tsfmt -r",
|
||||
"lint": "eslint src test --ext .ts,.tsx"
|
||||
"lint": "eslint src test --ext .ts,.tsx",
|
||||
"format-staged": "lint-staged"
|
||||
},
|
||||
"dependencies": {
|
||||
"child-process-promise": "^2.2.1",
|
||||
@@ -467,8 +586,8 @@
|
||||
"tmp": "^0.1.0",
|
||||
"tree-kill": "~1.2.2",
|
||||
"unzipper": "~0.10.5",
|
||||
"vscode-jsonrpc": "^4.0.0",
|
||||
"vscode-languageclient": "^5.2.1",
|
||||
"vscode-jsonrpc": "^5.0.1",
|
||||
"vscode-languageclient": "^6.1.3",
|
||||
"vscode-test-adapter-api": "~1.7.0",
|
||||
"vscode-test-adapter-util": "~0.7.0",
|
||||
"minimist": "~1.2.5"
|
||||
@@ -514,7 +633,7 @@
|
||||
"typescript-config": "^0.0.1",
|
||||
"typescript-formatter": "^7.2.2",
|
||||
"vsce": "^1.65.0",
|
||||
"vscode-test": "^1.0.0",
|
||||
"vscode-test": "^1.4.0",
|
||||
"webpack": "^4.38.0",
|
||||
"webpack-cli": "^3.3.2",
|
||||
"eslint": "~6.8.0",
|
||||
@@ -527,6 +646,23 @@
|
||||
"@types/sinon-chai": "~3.2.3",
|
||||
"proxyquire": "~2.1.3",
|
||||
"@types/proxyquire": "~1.3.28",
|
||||
"eslint-plugin-react": "~7.19.0"
|
||||
"eslint-plugin-react": "~7.19.0",
|
||||
"husky": "~4.2.5",
|
||||
"lint-staged": "~10.2.2",
|
||||
"prettier": "~2.0.5"
|
||||
},
|
||||
"husky": {
|
||||
"hooks": {
|
||||
"pre-commit": "npm run format-staged",
|
||||
"pre-push": "npm run lint"
|
||||
}
|
||||
},
|
||||
"lint-staged": {
|
||||
"./**/*.{json,css,scss,md}": [
|
||||
"prettier --write"
|
||||
],
|
||||
"./**/*.{ts,tsx}": [
|
||||
"tsfmt -r"
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
103
extensions/ql-vscode/src/adapt.ts
Normal file
@@ -0,0 +1,103 @@
|
||||
import { DecodedBqrsChunk, ResultSetSchema, ColumnKind, Column, ColumnValue } from "./bqrs-cli-types";
|
||||
import { LocationValue, ResultSetSchema as AdaptedSchema, ColumnSchema, ColumnType, LocationStyle } from 'semmle-bqrs';
|
||||
|
||||
// FIXME: This is a temporary bit of impedance matching to convert
|
||||
// from the types provided by ./bqrs-cli-types, to the types used by
|
||||
// the view layer.
|
||||
//
|
||||
// The reason that it is benign for now is that it is only used by
|
||||
// feature-flag-guarded codepaths that won't be encountered by normal
|
||||
// users. It is not yet guaranteed to produce correct output for raw
|
||||
// results.
|
||||
//
|
||||
// Eventually, the view layer should be refactored to directly accept data
|
||||
// of types coming from bqrs-cli-types, and this file can be deleted.
|
||||
|
||||
export type ResultRow = ResultValue[];
|
||||
|
||||
export interface ResultElement {
|
||||
label: string;
|
||||
location?: LocationValue;
|
||||
}
|
||||
|
||||
export interface ResultUri {
|
||||
uri: string;
|
||||
}
|
||||
|
||||
export type ResultValue = ResultElement | ResultUri | string;
|
||||
|
||||
export interface RawResultSet {
|
||||
readonly schema: AdaptedSchema;
|
||||
readonly rows: readonly ResultRow[];
|
||||
}
|
||||
|
||||
function adaptKind(kind: ColumnKind): ColumnType {
|
||||
// XXX what about 'u'?
|
||||
if (kind === 'e') {
|
||||
return { type: 'e', primitiveType: 's', locationStyle: LocationStyle.FivePart, hasLabel: true };
|
||||
}
|
||||
else {
|
||||
return { type: kind };
|
||||
}
|
||||
}
|
||||
|
||||
function adaptColumn(col: Column): ColumnSchema {
|
||||
return { name: col.name!, type: adaptKind(col.kind) };
|
||||
}
|
||||
|
||||
export function adaptSchema(schema: ResultSetSchema): AdaptedSchema {
|
||||
return {
|
||||
columns: schema.columns.map(adaptColumn),
|
||||
name: schema.name,
|
||||
tupleCount: schema.rows,
|
||||
version: 0,
|
||||
};
|
||||
}
|
||||
|
||||
export function adaptValue(val: ColumnValue): ResultValue {
|
||||
// XXX taking a lot of incorrect shortcuts here
|
||||
|
||||
if (typeof val === 'string') {
|
||||
return val;
|
||||
}
|
||||
|
||||
if (typeof val === 'number' || typeof val === 'boolean') {
|
||||
return val + '';
|
||||
}
|
||||
|
||||
const url = val.url;
|
||||
|
||||
if (typeof url === 'string') {
|
||||
return url;
|
||||
}
|
||||
|
||||
if (url === undefined) {
|
||||
return 'none';
|
||||
}
|
||||
|
||||
return {
|
||||
label: val.label || '',
|
||||
location: {
|
||||
t: LocationStyle.FivePart,
|
||||
lineStart: url.startLine,
|
||||
lineEnd: url.endLine,
|
||||
colStart: url.startColumn,
|
||||
colEnd: url.endColumn,
|
||||
// FIXME: This seems definitely wrong. Should we be using
|
||||
// something like the code in sarif-utils.ts?
|
||||
file: url.uri.replace(/file:/, ''),
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
export function adaptRow(row: ColumnValue[]): ResultRow {
|
||||
return row.map(adaptValue);
|
||||
}
|
||||
|
||||
export function adaptBqrs(schema: AdaptedSchema, page: DecodedBqrsChunk): RawResultSet {
|
||||
return {
|
||||
schema,
|
||||
rows: page.tuples.map(adaptRow),
|
||||
};
|
||||
}
|
||||
@@ -173,7 +173,7 @@ export class ArchiveFileSystemProvider implements vscode.FileSystemProvider {
|
||||
const ref = decodeSourceArchiveUri(uri);
|
||||
const archive = await this.getArchive(ref.sourceArchiveZipPath);
|
||||
const contents = archive.dirMap.get(ref.pathWithinSourceArchive);
|
||||
const result = contents === undefined ? [] : Array.from(contents.entries());
|
||||
const result = contents === undefined ? undefined : Array.from(contents.entries());
|
||||
if (result === undefined) {
|
||||
throw vscode.FileSystemError.FileNotFound(uri);
|
||||
}
|
||||
@@ -238,7 +238,7 @@ export class ArchiveFileSystemProvider implements vscode.FileSystemProvider {
|
||||
if (archive.dirMap.has(reqPath)) {
|
||||
return new Directory(reqPath);
|
||||
}
|
||||
throw vscode.FileSystemError.FileNotFound(uri);
|
||||
throw vscode.FileSystemError.FileNotFound(`uri '${uri.toString()}', interpreted as '${reqPath}' in archive '${ref.sourceArchiveZipPath}'`);
|
||||
}
|
||||
|
||||
private async _lookupAsFile(uri: vscode.Uri): Promise<File> {
|
||||
|
||||
@@ -34,7 +34,7 @@ export function tryParseVersionString(versionString: string): Version | undefine
|
||||
patchVersion: Number.parseInt(match[3], 10),
|
||||
prereleaseVersion: match[4],
|
||||
rawString: versionString,
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -165,7 +165,7 @@ export class CodeQLCliServer implements Disposable {
|
||||
// If the server is not running a command run this immediately
|
||||
// otherwise add to the front of the queue (as we want to run this after the next command()).
|
||||
if (this.commandInProcess) {
|
||||
this.commandQueue.unshift(callback)
|
||||
this.commandQueue.unshift(callback);
|
||||
} else {
|
||||
callback();
|
||||
}
|
||||
@@ -188,19 +188,19 @@ export class CodeQLCliServer implements Disposable {
|
||||
*/
|
||||
private async launchProcess(): Promise<child_process.ChildProcessWithoutNullStreams> {
|
||||
const config = await this.getCodeQlPath();
|
||||
return spawnServer(config, "CodeQL CLI Server", ["execute", "cli-server"], [], this.logger, _data => { /**/ })
|
||||
return spawnServer(config, "CodeQL CLI Server", ["execute", "cli-server"], [], this.logger, _data => { /**/ });
|
||||
}
|
||||
|
||||
private async runCodeQlCliInternal(command: string[], commandArgs: string[], description: string): Promise<string> {
|
||||
const stderrBuffers: Buffer[] = [];
|
||||
if (this.commandInProcess) {
|
||||
throw new Error("runCodeQlCliInternal called while cli was running")
|
||||
throw new Error("runCodeQlCliInternal called while cli was running");
|
||||
}
|
||||
this.commandInProcess = true;
|
||||
try {
|
||||
//Launch the process if it doesn't exist
|
||||
if (!this.process) {
|
||||
this.process = await this.launchProcess()
|
||||
this.process = await this.launchProcess();
|
||||
}
|
||||
// Grab the process so that typescript know that it is always defined.
|
||||
const process = this.process;
|
||||
@@ -230,8 +230,8 @@ export class CodeQLCliServer implements Disposable {
|
||||
// Listen for process exit.
|
||||
process.addListener("close", (code) => reject(code));
|
||||
// Write the command followed by a null terminator.
|
||||
process.stdin.write(JSON.stringify(args), "utf8")
|
||||
process.stdin.write(this.nullBuffer)
|
||||
process.stdin.write(JSON.stringify(args), "utf8");
|
||||
process.stdin.write(this.nullBuffer);
|
||||
});
|
||||
// Join all the data together
|
||||
const fullBuffer = Buffer.concat(stdoutBuffers);
|
||||
@@ -252,8 +252,8 @@ export class CodeQLCliServer implements Disposable {
|
||||
} finally {
|
||||
this.logger.log(Buffer.concat(stderrBuffers).toString("utf8"));
|
||||
// Remove the listeners we set up.
|
||||
process.stdout.removeAllListeners('data')
|
||||
process.stderr.removeAllListeners('data')
|
||||
process.stdout.removeAllListeners('data');
|
||||
process.stderr.removeAllListeners('data');
|
||||
process.removeAllListeners("close");
|
||||
}
|
||||
} finally {
|
||||
@@ -349,7 +349,7 @@ export class CodeQLCliServer implements Disposable {
|
||||
try {
|
||||
yield JSON.parse(event) as EventType;
|
||||
} catch (err) {
|
||||
throw new Error(`Parsing output of ${description} failed: ${err.stderr || err}`)
|
||||
throw new Error(`Parsing output of ${description} failed: ${err.stderr || err}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -375,11 +375,11 @@ export class CodeQLCliServer implements Disposable {
|
||||
} catch (err) {
|
||||
reject(err);
|
||||
}
|
||||
}
|
||||
};
|
||||
// If the server is not running a command, then run the given command immediately,
|
||||
// otherwise add to the queue
|
||||
if (this.commandInProcess) {
|
||||
this.commandQueue.push(callback)
|
||||
this.commandQueue.push(callback);
|
||||
} else {
|
||||
callback();
|
||||
}
|
||||
@@ -401,7 +401,7 @@ export class CodeQLCliServer implements Disposable {
|
||||
try {
|
||||
return JSON.parse(result) as OutputType;
|
||||
} catch (err) {
|
||||
throw new Error(`Parsing output of ${description} failed: ${err.stderr || err}`)
|
||||
throw new Error(`Parsing output of ${description} failed: ${err.stderr || err}`);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -535,12 +535,12 @@ export class CodeQLCliServer implements Disposable {
|
||||
try {
|
||||
output = await fs.readFile(interpretedResultsPath, 'utf8');
|
||||
} catch (err) {
|
||||
throw new Error(`Reading output of interpretation failed: ${err.stderr || err}`)
|
||||
throw new Error(`Reading output of interpretation failed: ${err.stderr || err}`);
|
||||
}
|
||||
try {
|
||||
return JSON.parse(output) as sarif.Log;
|
||||
} catch (err) {
|
||||
throw new Error(`Parsing output of interpretation failed: ${err.stderr || err}`)
|
||||
throw new Error(`Parsing output of interpretation failed: ${err.stderr || err}`);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -714,7 +714,7 @@ export async function runCodeQlCliCommand(codeQlPath: string, command: string[],
|
||||
logger.log(`CLI command succeeded.`);
|
||||
return result.stdout;
|
||||
} catch (err) {
|
||||
throw new Error(`${description} failed: ${err.stderr || err}`)
|
||||
throw new Error(`${description} failed: ${err.stderr || err}`);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -42,13 +42,14 @@ const ROOT_SETTING = new Setting('codeQL');
|
||||
// Enable experimental features
|
||||
|
||||
/**
|
||||
* This setting is deliberately not in package.json so that it does
|
||||
* not appear in the settings ui in vscode itself. If users want to
|
||||
* enable experimental features, they can add
|
||||
* "codeQl.experimentalFeatures" directly in their vscode settings
|
||||
* json file.
|
||||
* Any settings below are deliberately not in package.json so that
|
||||
* they do not appear in the settings ui in vscode itself. If users
|
||||
* want to enable experimental features, they can add them directly in
|
||||
* their vscode settings json file.
|
||||
*/
|
||||
export const EXPERIMENTAL_FEATURES_SETTING = new Setting('experimentalFeatures', ROOT_SETTING);
|
||||
|
||||
/* Advanced setting: used to enable bqrs parsing in the cli instead of in the webview. */
|
||||
export const EXPERIMENTAL_BQRS_SETTING = new Setting('experimentalBqrsParsing', ROOT_SETTING);
|
||||
|
||||
// Distribution configuration
|
||||
|
||||
|
||||
442
extensions/ql-vscode/src/databaseFetcher.ts
Normal file
@@ -0,0 +1,442 @@
|
||||
import fetch, { Response } from "node-fetch";
|
||||
import * as unzipper from "unzipper";
|
||||
import {
|
||||
Uri,
|
||||
ProgressOptions,
|
||||
ProgressLocation,
|
||||
commands,
|
||||
window,
|
||||
} from "vscode";
|
||||
import * as fs from "fs-extra";
|
||||
import * as path from "path";
|
||||
import { DatabaseManager, DatabaseItem } from "./databases";
|
||||
import {
|
||||
ProgressCallback,
|
||||
showAndLogErrorMessage,
|
||||
withProgress,
|
||||
showAndLogInformationMessage,
|
||||
} from "./helpers";
|
||||
import { logger } from "./logging";
|
||||
|
||||
/**
|
||||
* Prompts a user to fetch a database from a remote location. Database is assumed to be an archive file.
|
||||
*
|
||||
* @param databasesManager the DatabaseManager
|
||||
* @param storagePath where to store the unzipped database.
|
||||
*/
|
||||
export async function promptImportInternetDatabase(
|
||||
databasesManager: DatabaseManager,
|
||||
storagePath: string
|
||||
): Promise<DatabaseItem | undefined> {
|
||||
let item: DatabaseItem | undefined = undefined;
|
||||
|
||||
try {
|
||||
const databaseUrl = await window.showInputBox({
|
||||
prompt: "Enter URL of zipfile of database to download",
|
||||
});
|
||||
if (databaseUrl) {
|
||||
validateHttpsUrl(databaseUrl);
|
||||
|
||||
const progressOptions: ProgressOptions = {
|
||||
location: ProgressLocation.Notification,
|
||||
title: "Adding database from URL",
|
||||
cancellable: false,
|
||||
};
|
||||
await withProgress(
|
||||
progressOptions,
|
||||
async (progress) =>
|
||||
(item = await databaseArchiveFetcher(
|
||||
databaseUrl,
|
||||
databasesManager,
|
||||
storagePath,
|
||||
progress
|
||||
))
|
||||
);
|
||||
commands.executeCommand("codeQLDatabases.focus");
|
||||
}
|
||||
showAndLogInformationMessage(
|
||||
"Database downloaded and imported successfully."
|
||||
);
|
||||
} catch (e) {
|
||||
showAndLogErrorMessage(e.message);
|
||||
}
|
||||
|
||||
return item;
|
||||
}
|
||||
|
||||
/**
|
||||
* Prompts a user to fetch a database from lgtm.
|
||||
* User enters a project url and then the user is asked which language
|
||||
* to download (if there is more than one)
|
||||
*
|
||||
* @param databasesManager the DatabaseManager
|
||||
* @param storagePath where to store the unzipped database.
|
||||
*/
|
||||
export async function promptImportLgtmDatabase(
|
||||
databasesManager: DatabaseManager,
|
||||
storagePath: string
|
||||
): Promise<DatabaseItem | undefined> {
|
||||
let item: DatabaseItem | undefined = undefined;
|
||||
|
||||
try {
|
||||
const lgtmUrl = await window.showInputBox({
|
||||
prompt:
|
||||
"Enter the project URL on LGTM (e.g., https://lgtm.com/projects/g/github/codeql)",
|
||||
});
|
||||
if (!lgtmUrl) {
|
||||
return;
|
||||
}
|
||||
if (looksLikeLgtmUrl(lgtmUrl)) {
|
||||
const databaseUrl = await convertToDatabaseUrl(lgtmUrl);
|
||||
if (databaseUrl) {
|
||||
const progressOptions: ProgressOptions = {
|
||||
location: ProgressLocation.Notification,
|
||||
title: "Adding database from LGTM",
|
||||
cancellable: false,
|
||||
};
|
||||
await withProgress(
|
||||
progressOptions,
|
||||
async (progress) =>
|
||||
(item = await databaseArchiveFetcher(
|
||||
databaseUrl,
|
||||
databasesManager,
|
||||
storagePath,
|
||||
progress
|
||||
))
|
||||
);
|
||||
commands.executeCommand("codeQLDatabases.focus");
|
||||
}
|
||||
} else {
|
||||
throw new Error(`Invalid LGTM URL: ${lgtmUrl}`);
|
||||
}
|
||||
if (item) {
|
||||
showAndLogInformationMessage(
|
||||
"Database downloaded and imported successfully."
|
||||
);
|
||||
}
|
||||
} catch (e) {
|
||||
showAndLogErrorMessage(e.message);
|
||||
}
|
||||
|
||||
return item;
|
||||
}
|
||||
|
||||
/**
|
||||
* Imports a database from a local archive.
|
||||
*
|
||||
* @param databaseUrl the file url of the archive to import
|
||||
* @param databasesManager the DatabaseManager
|
||||
* @param storagePath where to store the unzipped database.
|
||||
*/
|
||||
export async function importArchiveDatabase(
|
||||
databaseUrl: string,
|
||||
databasesManager: DatabaseManager,
|
||||
storagePath: string
|
||||
): Promise<DatabaseItem | undefined> {
|
||||
let item: DatabaseItem | undefined = undefined;
|
||||
try {
|
||||
const progressOptions: ProgressOptions = {
|
||||
location: ProgressLocation.Notification,
|
||||
title: "Importing database from archive",
|
||||
cancellable: false,
|
||||
};
|
||||
await withProgress(
|
||||
progressOptions,
|
||||
async (progress) =>
|
||||
(item = await databaseArchiveFetcher(
|
||||
databaseUrl,
|
||||
databasesManager,
|
||||
storagePath,
|
||||
progress
|
||||
))
|
||||
);
|
||||
commands.executeCommand("codeQLDatabases.focus");
|
||||
|
||||
if (item) {
|
||||
showAndLogInformationMessage(
|
||||
"Database unzipped and imported successfully."
|
||||
);
|
||||
}
|
||||
} catch (e) {
|
||||
showAndLogErrorMessage(e.message);
|
||||
}
|
||||
return item;
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetches an archive database. The database might be on the internet
|
||||
* or in the local filesystem.
|
||||
*
|
||||
* @param databaseUrl URL from which to grab the database
|
||||
* @param databasesManager the DatabaseManager
|
||||
* @param storagePath where to store the unzipped database.
|
||||
* @param progressCallback optional callback to send progress messages to
|
||||
*/
|
||||
async function databaseArchiveFetcher(
|
||||
databaseUrl: string,
|
||||
databasesManager: DatabaseManager,
|
||||
storagePath: string,
|
||||
progressCallback?: ProgressCallback
|
||||
): Promise<DatabaseItem> {
|
||||
progressCallback?.({
|
||||
maxStep: 3,
|
||||
message: "Getting database",
|
||||
step: 1,
|
||||
});
|
||||
if (!storagePath) {
|
||||
throw new Error("No storage path specified.");
|
||||
}
|
||||
await fs.ensureDir(storagePath);
|
||||
const unzipPath = await getStorageFolder(storagePath, databaseUrl);
|
||||
|
||||
if (isFile(databaseUrl)) {
|
||||
await readAndUnzip(databaseUrl, unzipPath);
|
||||
} else {
|
||||
await fetchAndUnzip(databaseUrl, unzipPath, progressCallback);
|
||||
}
|
||||
|
||||
progressCallback?.({
|
||||
maxStep: 3,
|
||||
message: "Opening database",
|
||||
step: 3,
|
||||
});
|
||||
|
||||
// find the path to the database. The actual database might be in a sub-folder
|
||||
const dbPath = await findDirWithFile(
|
||||
unzipPath,
|
||||
".dbinfo",
|
||||
"codeql-database.yml"
|
||||
);
|
||||
if (dbPath) {
|
||||
const item = await databasesManager.openDatabase(Uri.file(dbPath));
|
||||
databasesManager.setCurrentDatabaseItem(item);
|
||||
return item;
|
||||
} else {
|
||||
throw new Error("Database not found in archive.");
|
||||
}
|
||||
}
|
||||
|
||||
async function getStorageFolder(storagePath: string, urlStr: string) {
|
||||
// we need to generate a folder name for the unzipped archive,
|
||||
// this needs to be human readable since we may use this name as the initial
|
||||
// name for the database
|
||||
const url = Uri.parse(urlStr);
|
||||
// MacOS has a max filename length of 255
|
||||
// and remove a few extra chars in case we need to add a counter at the end.
|
||||
let lastName = path.basename(url.path).substring(0, 250);
|
||||
if (lastName.endsWith(".zip")) {
|
||||
lastName = lastName.substring(0, lastName.length - 4);
|
||||
}
|
||||
|
||||
const realpath = await fs.realpath(storagePath);
|
||||
let folderName = path.join(realpath, lastName);
|
||||
|
||||
// avoid overwriting existing folders
|
||||
let counter = 0;
|
||||
while (await fs.pathExists(folderName)) {
|
||||
counter++;
|
||||
folderName = path.join(realpath, `${lastName}-${counter}`);
|
||||
if (counter > 100) {
|
||||
throw new Error("Could not find a unique name for downloaded database.");
|
||||
}
|
||||
}
|
||||
return folderName;
|
||||
}
|
||||
|
||||
function validateHttpsUrl(databaseUrl: string) {
|
||||
let uri;
|
||||
try {
|
||||
uri = Uri.parse(databaseUrl, true);
|
||||
} catch (e) {
|
||||
throw new Error(`Invalid url: ${databaseUrl}`);
|
||||
}
|
||||
|
||||
if (uri.scheme !== "https") {
|
||||
throw new Error("Must use https for downloading a database.");
|
||||
}
|
||||
}
|
||||
|
||||
async function readAndUnzip(databaseUrl: string, unzipPath: string) {
|
||||
const unzipStream = unzipper.Extract({
|
||||
path: unzipPath,
|
||||
});
|
||||
|
||||
await new Promise((resolve, reject) => {
|
||||
// we already know this is a file scheme
|
||||
const databaseFile = Uri.parse(databaseUrl).fsPath;
|
||||
const stream = fs.createReadStream(databaseFile);
|
||||
stream.on("error", reject);
|
||||
unzipStream.on("error", reject);
|
||||
unzipStream.on("close", resolve);
|
||||
stream.pipe(unzipStream);
|
||||
});
|
||||
}
|
||||
|
||||
async function fetchAndUnzip(
|
||||
databaseUrl: string,
|
||||
unzipPath: string,
|
||||
progressCallback?: ProgressCallback
|
||||
) {
|
||||
const response = await fetch(databaseUrl);
|
||||
|
||||
await checkForFailingResponse(response);
|
||||
|
||||
const unzipStream = unzipper.Extract({
|
||||
path: unzipPath,
|
||||
});
|
||||
progressCallback?.({
|
||||
maxStep: 3,
|
||||
message: "Unzipping database",
|
||||
step: 2,
|
||||
});
|
||||
await new Promise((resolve, reject) => {
|
||||
const handler = (err: Error) => {
|
||||
if (err.message.startsWith('invalid signature')) {
|
||||
reject(new Error('Not a valid archive.'));
|
||||
} else {
|
||||
reject(err);
|
||||
}
|
||||
};
|
||||
response.body.on("error", handler);
|
||||
unzipStream.on("error", handler);
|
||||
unzipStream.on("close", resolve);
|
||||
response.body.pipe(unzipStream);
|
||||
});
|
||||
}
|
||||
|
||||
async function checkForFailingResponse(response: Response): Promise<void | never> {
|
||||
if (response.ok) {
|
||||
return;
|
||||
}
|
||||
|
||||
// An error downloading the database. Attempt to extract the resaon behind it.
|
||||
const text = await response.text();
|
||||
let msg: string;
|
||||
try {
|
||||
const obj = JSON.parse(text);
|
||||
msg = obj.error || obj.message || obj.reason || JSON.stringify(obj, null, 2);
|
||||
} catch (e) {
|
||||
msg = text;
|
||||
}
|
||||
throw new Error(`Error downloading database.\n\nReason: ${msg}`);
|
||||
}
|
||||
|
||||
function isFile(databaseUrl: string) {
|
||||
return Uri.parse(databaseUrl).scheme === "file";
|
||||
}
|
||||
|
||||
/**
|
||||
* Recursively looks for a file in a directory. If the file exists, then returns the directory containing the file.
|
||||
*
|
||||
* @param dir The directory to search
|
||||
* @param toFind The file to recursively look for in this directory
|
||||
*
|
||||
* @returns the directory containing the file, or undefined if not found.
|
||||
*/
|
||||
// exported for testing
|
||||
export async function findDirWithFile(
|
||||
dir: string,
|
||||
...toFind: string[]
|
||||
): Promise<string | undefined> {
|
||||
if (!(await fs.stat(dir)).isDirectory()) {
|
||||
return;
|
||||
}
|
||||
const files = await fs.readdir(dir);
|
||||
if (toFind.some((file) => files.includes(file))) {
|
||||
return dir;
|
||||
}
|
||||
for (const file of files) {
|
||||
const newPath = path.join(dir, file);
|
||||
const result = await findDirWithFile(newPath, ...toFind);
|
||||
if (result) {
|
||||
return result;
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* The URL pattern is https://lgtm.com/projects/{provider}/{org}/{name}/{irrelevant-subpages}.
|
||||
* There are several possibilities for the provider: in addition to GitHub.com(g),
|
||||
* LGTM currently hosts projects from Bitbucket (b), GitLab (gl) and plain git (git).
|
||||
*
|
||||
* After the {provider}/{org}/{name} path components, there may be the components
|
||||
* related to sub pages.
|
||||
*
|
||||
* This function accepts any url that matches the patter above
|
||||
*
|
||||
* @param lgtmUrl The URL to the lgtm project
|
||||
*
|
||||
* @return true if this looks like an LGTM project url
|
||||
*/
|
||||
// exported for testing
|
||||
export function looksLikeLgtmUrl(lgtmUrl: string | undefined): lgtmUrl is string {
|
||||
if (!lgtmUrl) {
|
||||
return false;
|
||||
}
|
||||
|
||||
try {
|
||||
const uri = Uri.parse(lgtmUrl, true);
|
||||
if (uri.scheme !== "https") {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (uri.authority !== "lgtm.com" && uri.authority !== "www.lgtm.com") {
|
||||
return false;
|
||||
}
|
||||
|
||||
const paths = uri.path.split("/").filter((segment) => segment);
|
||||
return paths.length >= 4 && paths[0] === "projects";
|
||||
} catch (e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// exported for testing
|
||||
export async function convertToDatabaseUrl(lgtmUrl: string) {
|
||||
try {
|
||||
const uri = Uri.parse(lgtmUrl, true);
|
||||
const paths = ["api", "v1.0"].concat(
|
||||
uri.path.split("/").filter((segment) => segment)
|
||||
).slice(0, 6);
|
||||
const projectUrl = `https://lgtm.com/${paths.join("/")}`;
|
||||
const projectResponse = await fetch(projectUrl);
|
||||
const projectJson = await projectResponse.json();
|
||||
|
||||
if (projectJson.code === 404) {
|
||||
throw new Error();
|
||||
}
|
||||
|
||||
const language = await promptForLanguage(projectJson);
|
||||
if (!language) {
|
||||
return;
|
||||
}
|
||||
return `https://lgtm.com/${[
|
||||
"api",
|
||||
"v1.0",
|
||||
"snapshots",
|
||||
projectJson.id,
|
||||
language,
|
||||
].join("/")}`;
|
||||
} catch (e) {
|
||||
logger.log(`Error: ${e.message}`);
|
||||
throw new Error(`Invalid LGTM URL: ${lgtmUrl}`);
|
||||
}
|
||||
}
|
||||
|
||||
async function promptForLanguage(
|
||||
projectJson: any
|
||||
): Promise<string | undefined> {
|
||||
if (!projectJson?.languages?.length) {
|
||||
return;
|
||||
}
|
||||
if (projectJson.languages.length === 1) {
|
||||
return projectJson.languages[0].language;
|
||||
}
|
||||
|
||||
return await window.showQuickPick(
|
||||
projectJson.languages.map((lang: { language: string }) => lang.language), {
|
||||
placeHolder: "Select the database language to download:"
|
||||
}
|
||||
);
|
||||
}
|
||||
@@ -1,13 +1,15 @@
|
||||
import * as path from 'path';
|
||||
import { DisposableObject } from 'semmle-vscode-utils';
|
||||
import { commands, Event, EventEmitter, ExtensionContext, ProviderResult, TreeDataProvider, TreeItem, Uri, window } from 'vscode';
|
||||
import { commands, Event, EventEmitter, ExtensionContext, ProviderResult, TreeDataProvider, TreeItem, Uri, window, env } from 'vscode';
|
||||
import * as cli from './cli';
|
||||
import { DatabaseItem, DatabaseManager, getUpgradesDirectories } from './databases';
|
||||
import { getOnDiskWorkspaceFolders } from './helpers';
|
||||
import { getOnDiskWorkspaceFolders, showAndLogErrorMessage } from './helpers';
|
||||
import { logger } from './logging';
|
||||
import { clearCacheInDatabase, UserCancellationException } from './run-queries';
|
||||
import * as qsClient from './queryserver-client';
|
||||
import { upgradeDatabase } from './upgrades';
|
||||
import { importArchiveDatabase, promptImportInternetDatabase, promptImportLgtmDatabase } from './databaseFetcher';
|
||||
import * as fs from 'fs-extra';
|
||||
|
||||
type ThemableIconPath = { light: string; dark: string } | string;
|
||||
|
||||
@@ -94,7 +96,7 @@ class DatabaseTreeDataProvider extends DisposableObject
|
||||
public getChildren(element?: DatabaseItem): ProviderResult<DatabaseItem[]> {
|
||||
if (element === undefined) {
|
||||
return this.databaseManager.databaseItems.slice(0).sort((db1, db2) => {
|
||||
switch(this.sortOrder) {
|
||||
switch (this.sortOrder) {
|
||||
case SortOrder.NameAsc:
|
||||
return db1.name.localeCompare(db2.name);
|
||||
case SortOrder.NameDesc:
|
||||
@@ -147,12 +149,13 @@ function getFirst(list: Uri[] | undefined): Uri | undefined {
|
||||
* XXX: no validation is done other than checking the directory name
|
||||
* to make sure it really is a database directory.
|
||||
*/
|
||||
async function chooseDatabaseDir(): Promise<Uri | undefined> {
|
||||
async function chooseDatabaseDir(byFolder: boolean): Promise<Uri | undefined> {
|
||||
const chosen = await window.showOpenDialog({
|
||||
openLabel: 'Choose Database',
|
||||
canSelectFiles: true,
|
||||
canSelectFolders: true,
|
||||
canSelectMany: false
|
||||
openLabel: byFolder ? 'Choose Database folder' : 'Choose Database archive',
|
||||
canSelectFiles: !byFolder,
|
||||
canSelectFolders: byFolder,
|
||||
canSelectMany: false,
|
||||
filters: byFolder ? {} : { Archives: ['zip'] }
|
||||
});
|
||||
return getFirst(chosen);
|
||||
}
|
||||
@@ -164,14 +167,19 @@ export class DatabaseUI extends DisposableObject {
|
||||
ctx: ExtensionContext,
|
||||
private cliserver: cli.CodeQLCliServer,
|
||||
private databaseManager: DatabaseManager,
|
||||
private readonly queryServer: qsClient.QueryServerClient | undefined
|
||||
private readonly queryServer: qsClient.QueryServerClient | undefined,
|
||||
private readonly storagePath: string
|
||||
) {
|
||||
super();
|
||||
|
||||
this.treeDataProvider = this.push(new DatabaseTreeDataProvider(ctx, databaseManager));
|
||||
this.push(window.createTreeView('codeQLDatabases', { treeDataProvider: this.treeDataProvider }));
|
||||
|
||||
ctx.subscriptions.push(commands.registerCommand('codeQL.chooseDatabase', this.handleChooseDatabase));
|
||||
logger.log('Registering database panel commands.');
|
||||
ctx.subscriptions.push(commands.registerCommand('codeQLDatabases.chooseDatabaseFolder', this.handleChooseDatabaseFolder));
|
||||
ctx.subscriptions.push(commands.registerCommand('codeQLDatabases.chooseDatabaseArchive', this.handleChooseDatabaseArchive));
|
||||
ctx.subscriptions.push(commands.registerCommand('codeQLDatabases.chooseDatabaseInternet', this.handleChooseDatabaseInternet));
|
||||
ctx.subscriptions.push(commands.registerCommand('codeQLDatabases.chooseDatabaseLgtm', this.handleChooseDatabaseLgtm));
|
||||
ctx.subscriptions.push(commands.registerCommand('codeQL.setCurrentDatabase', this.handleSetCurrentDatabase));
|
||||
ctx.subscriptions.push(commands.registerCommand('codeQL.upgradeCurrentDatabase', this.handleUpgradeCurrentDatabase));
|
||||
ctx.subscriptions.push(commands.registerCommand('codeQL.clearCache', this.handleClearCache));
|
||||
@@ -180,14 +188,38 @@ export class DatabaseUI extends DisposableObject {
|
||||
ctx.subscriptions.push(commands.registerCommand('codeQLDatabases.sortByDateAdded', this.handleSortByDateAdded));
|
||||
ctx.subscriptions.push(commands.registerCommand('codeQLDatabases.removeDatabase', this.handleRemoveDatabase));
|
||||
ctx.subscriptions.push(commands.registerCommand('codeQLDatabases.upgradeDatabase', this.handleUpgradeDatabase));
|
||||
ctx.subscriptions.push(commands.registerCommand('codeQLDatabases.renameDatabase', this.handleRenameDatabase));
|
||||
ctx.subscriptions.push(commands.registerCommand('codeQLDatabases.openDatabaseFolder', this.handleOpenFolder));
|
||||
}
|
||||
|
||||
private handleMakeCurrentDatabase = async (databaseItem: DatabaseItem): Promise<void> => {
|
||||
await this.databaseManager.setCurrentDatabaseItem(databaseItem);
|
||||
}
|
||||
|
||||
private handleChooseDatabase = async (): Promise<DatabaseItem | undefined> => {
|
||||
return await this.chooseAndSetDatabase();
|
||||
handleChooseDatabaseFolder = async (): Promise<DatabaseItem | undefined> => {
|
||||
try {
|
||||
return await this.chooseAndSetDatabase(true);
|
||||
} catch (e) {
|
||||
showAndLogErrorMessage(e.message);
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
|
||||
handleChooseDatabaseArchive = async (): Promise<DatabaseItem | undefined> => {
|
||||
try {
|
||||
return await this.chooseAndSetDatabase(false);
|
||||
} catch (e) {
|
||||
showAndLogErrorMessage(e.message);
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
|
||||
handleChooseDatabaseInternet = async (): Promise<DatabaseItem | undefined> => {
|
||||
return await promptImportInternetDatabase(this.databaseManager, this.storagePath);
|
||||
}
|
||||
|
||||
handleChooseDatabaseLgtm = async (): Promise<DatabaseItem | undefined> => {
|
||||
return await promptImportLgtmDatabase(this.databaseManager, this.storagePath);
|
||||
}
|
||||
|
||||
private handleSortByName = async () => {
|
||||
@@ -265,6 +297,11 @@ export class DatabaseUI extends DisposableObject {
|
||||
}
|
||||
|
||||
private handleSetCurrentDatabase = async (uri: Uri): Promise<DatabaseItem | undefined> => {
|
||||
// Assume user has selected an archive if the file has a .zip extension
|
||||
if (uri.path.endsWith('.zip')) {
|
||||
return await importArchiveDatabase(uri.toString(true), this.databaseManager, this.storagePath);
|
||||
}
|
||||
|
||||
return await this.setCurrentDatabase(uri);
|
||||
}
|
||||
|
||||
@@ -272,6 +309,29 @@ export class DatabaseUI extends DisposableObject {
|
||||
this.databaseManager.removeDatabaseItem(databaseItem);
|
||||
}
|
||||
|
||||
private handleRenameDatabase = async (databaseItem: DatabaseItem): Promise<void> => {
|
||||
try {
|
||||
const newName = await window.showInputBox({
|
||||
prompt: 'Choose new database name',
|
||||
value: databaseItem.name
|
||||
});
|
||||
|
||||
if (newName) {
|
||||
this.databaseManager.renameDatabaseItem(databaseItem, newName);
|
||||
}
|
||||
} catch (e) {
|
||||
showAndLogErrorMessage(e.message);
|
||||
}
|
||||
}
|
||||
|
||||
private handleOpenFolder = async (databaseItem: DatabaseItem): Promise<void> => {
|
||||
try {
|
||||
await env.openExternal(databaseItem.databaseUri);
|
||||
} catch (e) {
|
||||
showAndLogErrorMessage(e.message);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the current database directory. If we don't already have a
|
||||
* current database, ask the user for one, and return that, or
|
||||
@@ -279,7 +339,7 @@ export class DatabaseUI extends DisposableObject {
|
||||
*/
|
||||
public async getDatabaseItem(): Promise<DatabaseItem | undefined> {
|
||||
if (this.databaseManager.currentDatabaseItem === undefined) {
|
||||
await this.chooseAndSetDatabase();
|
||||
await this.chooseAndSetDatabase(false);
|
||||
}
|
||||
|
||||
return this.databaseManager.currentDatabaseItem;
|
||||
@@ -299,13 +359,44 @@ export class DatabaseUI extends DisposableObject {
|
||||
* Ask the user for a database directory. Returns the chosen database, or `undefined` if the
|
||||
* operation was canceled.
|
||||
*/
|
||||
private async chooseAndSetDatabase(): Promise<DatabaseItem | undefined> {
|
||||
const uri = await chooseDatabaseDir();
|
||||
if (uri !== undefined) {
|
||||
return await this.setCurrentDatabase(uri);
|
||||
}
|
||||
else {
|
||||
private async chooseAndSetDatabase(byFolder: boolean): Promise<DatabaseItem | undefined> {
|
||||
const uri = await chooseDatabaseDir(byFolder);
|
||||
|
||||
if (!uri) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
if (byFolder) {
|
||||
const fixedUri = await this.fixDbUri(uri);
|
||||
// we are selecting a database folder
|
||||
return await this.setCurrentDatabase(fixedUri);
|
||||
}
|
||||
else {
|
||||
// we are selecting a database archive. Must unzip into a workspace-controlled area
|
||||
// before importing.
|
||||
return await importArchiveDatabase(uri.toString(true), this.databaseManager, this.storagePath);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Perform some heuristics to ensure a proper database location is chosen.
|
||||
*
|
||||
* 1. If the selected URI to add is a file, choose the containing directory
|
||||
* 2. If the selected URI is a directory matching db-*, choose the containing directory
|
||||
* 3. choose the current directory
|
||||
*
|
||||
* @param uri a URI that is a datbase folder or inside it
|
||||
*
|
||||
* @return the actual database folder found by using the heuristics above.
|
||||
*/
|
||||
private async fixDbUri(uri: Uri): Promise<Uri> {
|
||||
let dbPath = uri.fsPath;
|
||||
if ((await fs.stat(dbPath)).isFile()) {
|
||||
dbPath = path.dirname(dbPath);
|
||||
}
|
||||
if (path.basename(dbPath).startsWith('db-')) {
|
||||
dbPath = path.dirname(dbPath);
|
||||
}
|
||||
return Uri.file(dbPath);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -109,10 +109,11 @@ async function findDataset(parentDirectory: string): Promise<vscode.Uri> {
|
||||
return vscode.Uri.file(dbAbsolutePath);
|
||||
}
|
||||
|
||||
async function findSourceArchive(databasePath: string, silent = false):
|
||||
Promise<vscode.Uri | undefined> {
|
||||
async function findSourceArchive(
|
||||
databasePath: string, silent = false
|
||||
): Promise<vscode.Uri | undefined> {
|
||||
|
||||
const relativePaths = ['src', 'output/src_archive']
|
||||
const relativePaths = ['src', 'output/src_archive'];
|
||||
|
||||
for (const relativePath of relativePaths) {
|
||||
const basePath = path.join(databasePath, relativePath);
|
||||
@@ -203,7 +204,7 @@ export interface DatabaseItem {
|
||||
/** The URI of the database */
|
||||
readonly databaseUri: vscode.Uri;
|
||||
/** The name of the database to be displayed in the UI */
|
||||
readonly name: string;
|
||||
name: string;
|
||||
/** The URI of the database's source archive, or `undefined` if no source archive is to be used. */
|
||||
readonly sourceArchive: vscode.Uri | undefined;
|
||||
/**
|
||||
@@ -287,6 +288,10 @@ class DatabaseItemImpl implements DatabaseItem {
|
||||
}
|
||||
}
|
||||
|
||||
public set name(newName: string) {
|
||||
this.options.displayName = newName;
|
||||
}
|
||||
|
||||
public get sourceArchive(): vscode.Uri | undefined {
|
||||
if (this.options.ignoreSourceArchive || (this._contents === undefined)) {
|
||||
return undefined;
|
||||
@@ -459,12 +464,11 @@ function eventFired<T>(event: vscode.Event<T>, timeoutMs = 1000): Promise<T | un
|
||||
}
|
||||
|
||||
export class DatabaseManager extends DisposableObject {
|
||||
private readonly _onDidChangeDatabaseItem =
|
||||
this.push(new vscode.EventEmitter<DatabaseItem | undefined>());
|
||||
private readonly _onDidChangeDatabaseItem = this.push(new vscode.EventEmitter<DatabaseItem | undefined>());
|
||||
|
||||
readonly onDidChangeDatabaseItem = this._onDidChangeDatabaseItem.event;
|
||||
|
||||
private readonly _onDidChangeCurrentDatabaseItem =
|
||||
this.push(new vscode.EventEmitter<DatabaseItem | undefined>());
|
||||
private readonly _onDidChangeCurrentDatabaseItem = this.push(new vscode.EventEmitter<DatabaseItem | undefined>());
|
||||
readonly onDidChangeCurrentDatabaseItem = this._onDidChangeCurrentDatabaseItem.event;
|
||||
|
||||
private readonly _databaseItems: DatabaseItemImpl[] = [];
|
||||
@@ -565,7 +569,7 @@ export class DatabaseManager extends DisposableObject {
|
||||
};
|
||||
const item = new DatabaseItemImpl(vscode.Uri.parse(state.uri), undefined, fullOptions,
|
||||
(item) => {
|
||||
this._onDidChangeDatabaseItem.fire(item)
|
||||
this._onDidChangeDatabaseItem.fire(item);
|
||||
});
|
||||
await this.addDatabaseItem(item);
|
||||
|
||||
@@ -642,6 +646,12 @@ export class DatabaseManager extends DisposableObject {
|
||||
this._onDidChangeDatabaseItem.fire(undefined);
|
||||
}
|
||||
|
||||
public async renameDatabaseItem(item: DatabaseItem, newName: string) {
|
||||
item.name = newName;
|
||||
this.updatePersistedDatabaseList();
|
||||
this._onDidChangeDatabaseItem.fire(item);
|
||||
}
|
||||
|
||||
public removeDatabaseItem(item: DatabaseItem) {
|
||||
if (this._currentDatabaseItem == item)
|
||||
this._currentDatabaseItem = undefined;
|
||||
@@ -658,6 +668,14 @@ export class DatabaseManager extends DisposableObject {
|
||||
vscode.workspace.updateWorkspaceFolders(folderIndex, 1);
|
||||
}
|
||||
|
||||
// Delete folder from file system only if it is controlled by the extension
|
||||
if (this.isExtensionControlledLocation(item.databaseUri)) {
|
||||
logger.log(`Deleting database from filesystem.`);
|
||||
fs.remove(item.databaseUri.path).then(
|
||||
() => logger.log(`Deleted '${item.databaseUri.path}'`),
|
||||
e => logger.log(`Failed to delete '${item.databaseUri.path}'. Reason: ${e.message}`));
|
||||
}
|
||||
|
||||
this._onDidChangeDatabaseItem.fire(undefined);
|
||||
}
|
||||
|
||||
@@ -669,6 +687,11 @@ export class DatabaseManager extends DisposableObject {
|
||||
private updatePersistedDatabaseList(): void {
|
||||
this.ctx.workspaceState.update(DB_LIST, this._databaseItems.map(item => item.getPersistedState()));
|
||||
}
|
||||
|
||||
private isExtensionControlledLocation(uri: vscode.Uri) {
|
||||
const storagePath = this.ctx.storagePath || this.ctx.globalStoragePath;
|
||||
return uri.path.startsWith(storagePath);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -34,6 +34,13 @@ function tagOfKeyType(keyType: KeyType): string {
|
||||
}
|
||||
}
|
||||
|
||||
function nameOfKeyType(keyType: KeyType): string {
|
||||
switch (keyType) {
|
||||
case KeyType.DefinitionQuery: return "definitions";
|
||||
case KeyType.ReferenceQuery: return "references";
|
||||
}
|
||||
}
|
||||
|
||||
async function resolveQueries(cli: CodeQLCliServer, qlpack: string, keyType: KeyType): Promise<string[]> {
|
||||
const suiteFile = tmp.fileSync({ postfix: '.qls' }).name;
|
||||
const suiteYaml = { qlpack, include: { kind: 'definitions', 'tags contain': tagOfKeyType(keyType) } };
|
||||
@@ -41,7 +48,10 @@ async function resolveQueries(cli: CodeQLCliServer, qlpack: string, keyType: Key
|
||||
|
||||
const queries = await cli.resolveQueriesInSuite(suiteFile, helpers.getOnDiskWorkspaceFolders());
|
||||
if (queries.length === 0) {
|
||||
throw new Error("Couldn't find any queries for qlpack");
|
||||
vscode.window.showErrorMessage(
|
||||
`No ${nameOfKeyType(keyType)} queries (tagged "${tagOfKeyType(keyType)}") could be found in the current library path. It might be necessary to upgrade the CodeQL libraries.`
|
||||
);
|
||||
throw new Error(`Couldn't find any queries tagged ${tagOfKeyType(keyType)} for qlpack ${qlpack}`);
|
||||
}
|
||||
return queries;
|
||||
}
|
||||
@@ -70,7 +80,7 @@ export class TemplateQueryDefinitionProvider implements vscode.DefinitionProvide
|
||||
}
|
||||
|
||||
async getDefinitions(uriString: string): Promise<vscode.LocationLink[]> {
|
||||
return getLinksForUriString(this.cli, this.qs, this.dbm, uriString, (src, _dest) => src === uriString);
|
||||
return getLinksForUriString(this.cli, this.qs, this.dbm, uriString, KeyType.DefinitionQuery, (src, _dest) => src === uriString);
|
||||
}
|
||||
|
||||
async provideDefinition(document: vscode.TextDocument, position: vscode.Position, _token: vscode.CancellationToken): Promise<vscode.LocationLink[]> {
|
||||
@@ -97,7 +107,7 @@ export class TemplateQueryReferenceProvider implements vscode.ReferenceProvider
|
||||
}
|
||||
|
||||
async getReferences(uriString: string): Promise<FullLocationLink[]> {
|
||||
return getLinksForUriString(this.cli, this.qs, this.dbm, uriString, (_src, dest) => dest === uriString);
|
||||
return getLinksForUriString(this.cli, this.qs, this.dbm, uriString, KeyType.ReferenceQuery, (_src, dest) => dest === uriString);
|
||||
}
|
||||
|
||||
async provideReferences(document: vscode.TextDocument, position: vscode.Position, _context: vscode.ReferenceContext, _token: vscode.CancellationToken): Promise<vscode.Location[]> {
|
||||
@@ -146,6 +156,7 @@ async function getLinksForUriString(
|
||||
qs: QueryServerClient,
|
||||
dbm: DatabaseManager,
|
||||
uriString: string,
|
||||
keyType: KeyType,
|
||||
filter: (src: string, dest: string) => boolean
|
||||
) {
|
||||
const uri = decodeSourceArchiveUri(vscode.Uri.parse(uriString));
|
||||
@@ -157,8 +168,8 @@ async function getLinksForUriString(
|
||||
if (qlpack === undefined) {
|
||||
throw new Error("Can't infer qlpack from database source archive");
|
||||
}
|
||||
const links: FullLocationLink[] = []
|
||||
for (const query of await resolveQueries(cli, qlpack, KeyType.ReferenceQuery)) {
|
||||
const links: FullLocationLink[] = [];
|
||||
for (const query of await resolveQueries(cli, qlpack, keyType)) {
|
||||
const templates: messages.TemplateDefinitions = {
|
||||
[TEMPLATE_NAME]: {
|
||||
values: {
|
||||
|
||||
@@ -6,7 +6,7 @@ import * as unzipper from "unzipper";
|
||||
import * as url from "url";
|
||||
import { ExtensionContext, Event } from "vscode";
|
||||
import { DistributionConfig } from "./config";
|
||||
import { InvocationRateLimiter, InvocationRateLimiterResultKind, ProgressUpdate, showAndLogErrorMessage } from "./helpers";
|
||||
import { InvocationRateLimiter, InvocationRateLimiterResultKind, showAndLogErrorMessage } from "./helpers";
|
||||
import { logger } from "./logging";
|
||||
import * as helpers from "./helpers";
|
||||
import { getCodeQlCliVersion, tryParseVersionString, Version } from "./cli-version";
|
||||
@@ -42,9 +42,9 @@ const DEFAULT_DISTRIBUTION_REPOSITORY_NAME = "codeql-cli-binaries";
|
||||
export const DEFAULT_DISTRIBUTION_VERSION_CONSTRAINT: VersionConstraint = {
|
||||
description: "2.*.*",
|
||||
isVersionCompatible: (v: Version) => {
|
||||
return v.majorVersion === 2 && v.minorVersion >= 0
|
||||
return v.majorVersion === 2 && v.minorVersion >= 0;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
export interface DistributionProvider {
|
||||
getCodeQlPathWithoutVersionCheck(): Promise<string | undefined>;
|
||||
@@ -86,7 +86,7 @@ export class DistributionManager implements DistributionProvider {
|
||||
return {
|
||||
codeQlPath,
|
||||
kind: FindDistributionResultKind.UnknownCompatibilityDistribution,
|
||||
}
|
||||
};
|
||||
}
|
||||
return {
|
||||
codeQlPath,
|
||||
@@ -171,7 +171,7 @@ export class DistributionManager implements DistributionProvider {
|
||||
* Returns a failed promise if an unexpected error occurs during installation.
|
||||
*/
|
||||
public installExtensionManagedDistributionRelease(release: Release,
|
||||
progressCallback?: (p: ProgressUpdate) => void): Promise<void> {
|
||||
progressCallback?: helpers.ProgressCallback): Promise<void> {
|
||||
return this._extensionSpecificDistributionManager.installDistributionRelease(release, progressCallback);
|
||||
}
|
||||
|
||||
@@ -253,14 +253,14 @@ class ExtensionSpecificDistributionManager {
|
||||
* Returns a failed promise if an unexpected error occurs during installation.
|
||||
*/
|
||||
public async installDistributionRelease(release: Release,
|
||||
progressCallback?: (p: ProgressUpdate) => void): Promise<void> {
|
||||
progressCallback?: helpers.ProgressCallback): Promise<void> {
|
||||
await this.downloadDistribution(release, progressCallback);
|
||||
// Store the installed release within the global extension state.
|
||||
this.storeInstalledRelease(release);
|
||||
}
|
||||
|
||||
private async downloadDistribution(release: Release,
|
||||
progressCallback?: (p: ProgressUpdate) => void): Promise<void> {
|
||||
progressCallback?: helpers.ProgressCallback): Promise<void> {
|
||||
try {
|
||||
await this.removeDistribution();
|
||||
} catch (e) {
|
||||
@@ -480,7 +480,7 @@ export class ReleasesApiConsumer {
|
||||
// mechanism is provided.
|
||||
delete headers["authorization"];
|
||||
}
|
||||
return await this.makeRawRequest(redirectUrl, headers, redirectCount + 1)
|
||||
return await this.makeRawRequest(redirectUrl, headers, redirectCount + 1);
|
||||
}
|
||||
|
||||
return response;
|
||||
|
||||
@@ -3,7 +3,8 @@ import { LanguageClient } from 'vscode-languageclient';
|
||||
import { testExplorerExtensionId, TestHub } from 'vscode-test-adapter-api';
|
||||
import * as archiveFilesystemProvider from './archive-filesystem-provider';
|
||||
import { CodeQLCliServer } from './cli';
|
||||
import { DistributionConfigListener, QueryHistoryConfigListener, QueryServerConfigListener, EXPERIMENTAL_FEATURES_SETTING } from './config';
|
||||
import { DistributionConfigListener, QueryHistoryConfigListener, QueryServerConfigListener } from './config';
|
||||
import * as languageSupport from './languageSupport';
|
||||
import { DatabaseManager } from './databases';
|
||||
import { DatabaseUI } from './databases-ui';
|
||||
import { TemplateQueryDefinitionProvider, TemplateQueryReferenceProvider } from './definitions';
|
||||
@@ -60,8 +61,9 @@ function registerErrorStubs(excludedCommands: string[], stubGenerator: (command:
|
||||
|
||||
const extensionId = 'GitHub.vscode-codeql'; // TODO: Is there a better way of obtaining this?
|
||||
const extension = extensions.getExtension(extensionId);
|
||||
if (extension === undefined)
|
||||
if (extension === undefined) {
|
||||
throw new Error(`Can't find extension ${extensionId}`);
|
||||
}
|
||||
|
||||
const stubbedCommands: string[]
|
||||
= extension.packageJSON.contributes.commands.map((entry: { command: string }) => entry.command);
|
||||
@@ -77,6 +79,7 @@ export async function activate(ctx: ExtensionContext): Promise<void> {
|
||||
logger.log('Starting CodeQL extension');
|
||||
|
||||
initializeLogging(ctx);
|
||||
languageSupport.install();
|
||||
|
||||
const distributionConfigListener = new DistributionConfigListener();
|
||||
ctx.subscriptions.push(distributionConfigListener);
|
||||
@@ -249,31 +252,39 @@ async function activateWithInstalledDistribution(ctx: ExtensionContext, distribu
|
||||
// of activation.
|
||||
errorStubs.forEach(stub => stub.dispose());
|
||||
|
||||
logger.log('Initializing configuration listener...');
|
||||
const qlConfigurationListener = await QueryServerConfigListener.createQueryServerConfigListener(distributionManager);
|
||||
ctx.subscriptions.push(qlConfigurationListener);
|
||||
|
||||
logger.log('Initializing CodeQL cli server...');
|
||||
const cliServer = new CodeQLCliServer(distributionManager, logger);
|
||||
ctx.subscriptions.push(cliServer);
|
||||
|
||||
logger.log('Initializing query server client.');
|
||||
const qs = new qsClient.QueryServerClient(qlConfigurationListener, cliServer, {
|
||||
logger: queryServerLogger,
|
||||
}, task => Window.withProgress({ title: 'CodeQL query server', location: ProgressLocation.Window }, task));
|
||||
ctx.subscriptions.push(qs);
|
||||
await qs.startQueryServer();
|
||||
|
||||
logger.log('Initializing database manager.');
|
||||
const dbm = new DatabaseManager(ctx, qlConfigurationListener, logger);
|
||||
ctx.subscriptions.push(dbm);
|
||||
const databaseUI = new DatabaseUI(ctx, cliServer, dbm, qs);
|
||||
logger.log('Initializing database panel.');
|
||||
const databaseUI = new DatabaseUI(ctx, cliServer, dbm, qs, getContextStoragePath(ctx));
|
||||
ctx.subscriptions.push(databaseUI);
|
||||
|
||||
logger.log('Initializing query history manager.');
|
||||
const queryHistoryConfigurationListener = new QueryHistoryConfigListener();
|
||||
const qhm = new QueryHistoryManager(
|
||||
ctx,
|
||||
queryHistoryConfigurationListener,
|
||||
async item => showResultsForCompletedQuery(item, WebviewReveal.Forced)
|
||||
);
|
||||
logger.log('Initializing results panel interface.');
|
||||
const intm = new InterfaceManager(ctx, dbm, cliServer, queryServerLogger);
|
||||
ctx.subscriptions.push(intm);
|
||||
logger.log('Initializing source archive filesystem provider.');
|
||||
archiveFilesystemProvider.activate(ctx);
|
||||
|
||||
async function showResultsForCompletedQuery(query: CompletedQuery, forceReveal: WebviewReveal): Promise<void> {
|
||||
@@ -304,6 +315,7 @@ async function activateWithInstalledDistribution(ctx: ExtensionContext, distribu
|
||||
|
||||
ctx.subscriptions.push(tmpDirDisposal);
|
||||
|
||||
logger.log('Initializing CodeQL language server.');
|
||||
const client = new LanguageClient('CodeQL Language Server', () => spawnIdeServer(qlConfigurationListener), {
|
||||
documentSelector: [
|
||||
{ language: 'ql', scheme: 'file' },
|
||||
@@ -316,6 +328,7 @@ async function activateWithInstalledDistribution(ctx: ExtensionContext, distribu
|
||||
outputChannel: ideServerLogger.outputChannel
|
||||
}, true);
|
||||
|
||||
logger.log('Initializing QLTest interface.');
|
||||
const testExplorerExtension = extensions.getExtension<TestHub>(testExplorerExtensionId);
|
||||
if (testExplorerExtension) {
|
||||
const testHub = testExplorerExtension.exports;
|
||||
@@ -326,6 +339,7 @@ async function activateWithInstalledDistribution(ctx: ExtensionContext, distribu
|
||||
ctx.subscriptions.push(testUIService);
|
||||
}
|
||||
|
||||
logger.log('Registering top-level command palette commands.');
|
||||
ctx.subscriptions.push(commands.registerCommand('codeQL.runQuery', async (uri: Uri | undefined) => await compileAndRunQuery(false, uri)));
|
||||
ctx.subscriptions.push(commands.registerCommand('codeQL.quickEval', async (uri: Uri | undefined) => await compileAndRunQuery(true, uri)));
|
||||
ctx.subscriptions.push(commands.registerCommand('codeQL.quickQuery', async () => displayQuickQuery(ctx, cliServer, databaseUI)));
|
||||
@@ -333,25 +347,37 @@ async function activateWithInstalledDistribution(ctx: ExtensionContext, distribu
|
||||
await qs.restartQueryServer();
|
||||
helpers.showAndLogInformationMessage('CodeQL Query Server restarted.', { outputLogger: queryServerLogger });
|
||||
}));
|
||||
ctx.subscriptions.push(commands.registerCommand('codeQL.chooseDatabaseFolder', () => databaseUI.handleChooseDatabaseFolder()));
|
||||
ctx.subscriptions.push(commands.registerCommand('codeQL.chooseDatabaseArchive', () => databaseUI.handleChooseDatabaseArchive()));
|
||||
ctx.subscriptions.push(commands.registerCommand('codeQL.chooseDatabaseLgtm', () => databaseUI.handleChooseDatabaseLgtm()));
|
||||
ctx.subscriptions.push(commands.registerCommand('codeQL.chooseDatabaseInternet', () => databaseUI.handleChooseDatabaseInternet()));
|
||||
|
||||
logger.log('Starting language server.');
|
||||
ctx.subscriptions.push(client.start());
|
||||
|
||||
if (EXPERIMENTAL_FEATURES_SETTING.getValue()) {
|
||||
languages.registerDefinitionProvider(
|
||||
{ scheme: archiveFilesystemProvider.zipArchiveScheme },
|
||||
new TemplateQueryDefinitionProvider(cliServer, qs, dbm)
|
||||
);
|
||||
languages.registerReferenceProvider(
|
||||
{ scheme: archiveFilesystemProvider.zipArchiveScheme },
|
||||
new TemplateQueryReferenceProvider(cliServer, qs, dbm)
|
||||
);
|
||||
}
|
||||
// Jump-to-definition and find-references
|
||||
logger.log('Registering jump-to-definition handlers.');
|
||||
languages.registerDefinitionProvider(
|
||||
{ scheme: archiveFilesystemProvider.zipArchiveScheme },
|
||||
new TemplateQueryDefinitionProvider(cliServer, qs, dbm)
|
||||
);
|
||||
languages.registerReferenceProvider(
|
||||
{ scheme: archiveFilesystemProvider.zipArchiveScheme },
|
||||
new TemplateQueryReferenceProvider(cliServer, qs, dbm)
|
||||
);
|
||||
|
||||
logger.log('Successfully finished extension initialization.');
|
||||
}
|
||||
|
||||
function getContextStoragePath(ctx: ExtensionContext) {
|
||||
return ctx.storagePath || ctx.globalStoragePath;
|
||||
}
|
||||
|
||||
function initializeLogging(ctx: ExtensionContext): void {
|
||||
logger.init(ctx);
|
||||
queryServerLogger.init(ctx);
|
||||
ideServerLogger.init(ctx);
|
||||
const storagePath = getContextStoragePath(ctx);
|
||||
logger.init(storagePath);
|
||||
queryServerLogger.init(storagePath);
|
||||
ideServerLogger.init(storagePath);
|
||||
ctx.subscriptions.push(logger);
|
||||
ctx.subscriptions.push(queryServerLogger);
|
||||
ctx.subscriptions.push(ideServerLogger);
|
||||
|
||||
@@ -22,6 +22,8 @@ export interface ProgressUpdate {
|
||||
message: string;
|
||||
}
|
||||
|
||||
export type ProgressCallback = (p: ProgressUpdate) => void;
|
||||
|
||||
/**
|
||||
* This mediates between the kind of progress callbacks we want to
|
||||
* write (where we *set* current progress position and give
|
||||
@@ -114,7 +116,7 @@ async function internalShowAndLog(message: string, items: string[], outputLogger
|
||||
*/
|
||||
export async function showBinaryChoiceDialog(message: string): Promise<boolean> {
|
||||
const yesItem = { title: 'Yes', isCloseAffordance: false };
|
||||
const noItem = { title: 'No', isCloseAffordance: true }
|
||||
const noItem = { title: 'No', isCloseAffordance: true };
|
||||
const chosenItem = await Window.showInformationMessage(message, { modal: true }, yesItem, noItem);
|
||||
return chosenItem === yesItem;
|
||||
}
|
||||
@@ -138,7 +140,7 @@ export function getOnDiskWorkspaceFolders() {
|
||||
const diskWorkspaceFolders: string[] = [];
|
||||
for (const workspaceFolder of workspaceFolders) {
|
||||
if (workspaceFolder.uri.scheme === "file")
|
||||
diskWorkspaceFolders.push(workspaceFolder.uri.fsPath)
|
||||
diskWorkspaceFolders.push(workspaceFolder.uri.fsPath);
|
||||
}
|
||||
return diskWorkspaceFolders;
|
||||
}
|
||||
@@ -269,7 +271,7 @@ export async function getQlPackForDbscheme(cliServer: CodeQLCliServer, dbschemeP
|
||||
return {
|
||||
packName,
|
||||
packDir: dirs[0]
|
||||
}
|
||||
};
|
||||
});
|
||||
for (const { packDir, packName } of packs) {
|
||||
if (packDir !== undefined) {
|
||||
@@ -283,7 +285,7 @@ export async function getQlPackForDbscheme(cliServer: CodeQLCliServer, dbschemeP
|
||||
}
|
||||
|
||||
export async function resolveDatasetFolder(cliServer: CodeQLCliServer, datasetFolder: string): Promise<DatasetFolderInfo> {
|
||||
const dbschemes = await glob(path.join(datasetFolder, '*.dbscheme'))
|
||||
const dbschemes = await glob(path.join(datasetFolder, '*.dbscheme'));
|
||||
|
||||
if (dbschemes.length < 1) {
|
||||
throw new Error(`Can't find dbscheme for current database in ${datasetFolder}`);
|
||||
@@ -320,7 +322,7 @@ export class CachedOperation<U> {
|
||||
const fromCache = this.cached.get(t);
|
||||
if (fromCache !== undefined) {
|
||||
// Move to end of lru list
|
||||
this.lru.push(this.lru.splice(this.lru.findIndex(v => v === t), 1)[0])
|
||||
this.lru.push(this.lru.splice(this.lru.findIndex(v => v === t), 1)[0]);
|
||||
return fromCache;
|
||||
}
|
||||
// Otherwise check if in progress
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import * as sarif from 'sarif';
|
||||
import { ResolvableLocationValue } from 'semmle-bqrs';
|
||||
import { RawResultSet } from './adapt';
|
||||
|
||||
/**
|
||||
* Only ever show this many results per run in interpreted results.
|
||||
@@ -77,6 +78,12 @@ export interface SetStateMsg {
|
||||
* This is useful to prevent properties like scroll state being lost when rendering the sorted results after sorting a column.
|
||||
*/
|
||||
shouldKeepOldResultsWhileRendering: boolean;
|
||||
|
||||
/**
|
||||
* An experimental way of providing results from the extension.
|
||||
* Should be undefined unless config.EXPERIMENTAL_BQRS_SETTING is set to true.
|
||||
*/
|
||||
resultSets?: RawResultSet[];
|
||||
}
|
||||
|
||||
/** Advance to the next or previous path no in the path viewer */
|
||||
|
||||
@@ -16,6 +16,8 @@ import * as messages from './messages';
|
||||
import { CompletedQuery, interpretResults } from './query-results';
|
||||
import { QueryInfo, tmpDir } from './run-queries';
|
||||
import { parseSarifLocation, parseSarifPlainTextMessage } from './sarif-utils';
|
||||
import { adaptSchema, adaptBqrs, RawResultSet } from './adapt';
|
||||
import { EXPERIMENTAL_BQRS_SETTING } from './config';
|
||||
|
||||
/**
|
||||
* interface.ts
|
||||
@@ -136,6 +138,7 @@ export class InterfaceManager extends DisposableObject {
|
||||
this.handleSelectionChange.bind(this)
|
||||
)
|
||||
);
|
||||
logger.log('Registering path-step navigation commands.');
|
||||
this.push(
|
||||
vscode.commands.registerCommand(
|
||||
"codeQLQueryResults.nextPathStep",
|
||||
@@ -349,9 +352,7 @@ export class InterfaceManager extends DisposableObject {
|
||||
const showButton = "View Results";
|
||||
const queryName = results.queryName;
|
||||
const resultPromise = vscode.window.showInformationMessage(
|
||||
`Finished running query ${
|
||||
queryName.length > 0 ? ` “${queryName}”` : ""
|
||||
}.`,
|
||||
`Finished running query ${queryName.length > 0 ? ` "${queryName}"` : ""}.`,
|
||||
showButton
|
||||
);
|
||||
// Address this click asynchronously so we still update the
|
||||
@@ -363,6 +364,19 @@ export class InterfaceManager extends DisposableObject {
|
||||
});
|
||||
}
|
||||
|
||||
let resultSets: RawResultSet[] | undefined;
|
||||
|
||||
if (EXPERIMENTAL_BQRS_SETTING.getValue()) {
|
||||
resultSets = [];
|
||||
const schemas = await this.cliServer.bqrsInfo(results.query.resultsPaths.resultsPath);
|
||||
for (const schema of schemas["result-sets"]) {
|
||||
const chunk = await this.cliServer.bqrsDecode(results.query.resultsPaths.resultsPath, schema.name);
|
||||
const adaptedSchema = adaptSchema(schema);
|
||||
const resultSet = adaptBqrs(adaptedSchema, chunk);
|
||||
resultSets.push(resultSet);
|
||||
}
|
||||
}
|
||||
|
||||
await this.postMessage({
|
||||
t: "setState",
|
||||
interpretation,
|
||||
@@ -370,6 +384,7 @@ export class InterfaceManager extends DisposableObject {
|
||||
resultsPath: this.convertPathToWebviewUri(
|
||||
results.query.resultsPaths.resultsPath
|
||||
),
|
||||
resultSets,
|
||||
sortedResultsMap,
|
||||
database: results.database,
|
||||
shouldKeepOldResultsWhileRendering,
|
||||
@@ -387,7 +402,7 @@ export class InterfaceManager extends DisposableObject {
|
||||
const sarif = await interpretResults(
|
||||
this.cliServer,
|
||||
metadata,
|
||||
resultsPaths.resultsPath,
|
||||
resultsPaths,
|
||||
sourceInfo
|
||||
);
|
||||
// For performance reasons, limit the number of results we try
|
||||
@@ -425,7 +440,7 @@ export class InterfaceManager extends DisposableObject {
|
||||
): Promise<Interpretation | undefined> {
|
||||
let interpretation: Interpretation | undefined = undefined;
|
||||
if (
|
||||
(await query.hasInterpretedResults()) &&
|
||||
(await query.canHaveInterpretedResults()) &&
|
||||
query.quickEvalPosition === undefined // never do results interpretation if quickEval
|
||||
) {
|
||||
try {
|
||||
|
||||
52
extensions/ql-vscode/src/languageSupport.ts
Normal file
@@ -0,0 +1,52 @@
|
||||
import { IndentAction, languages } from "vscode";
|
||||
|
||||
|
||||
/**
|
||||
* OnEnterRules are available in language-configurations, but you cannot specify them in the language-configuration.json.
|
||||
* They can only be specified programmatically.
|
||||
*
|
||||
* Also, we should keep the language-configuration.json as a json file and register it in the package.json because
|
||||
* it is registered first, before the extension is activated, so language features are available quicker.
|
||||
*
|
||||
* See https://github.com/microsoft/vscode/issues/11514
|
||||
* See https://github.com/microsoft/vscode/blob/master/src/vs/editor/test/common/modes/supports/javascriptOnEnterRules.ts
|
||||
*/
|
||||
export function install() {
|
||||
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
||||
const langConfig = require('../language-configuration.json');
|
||||
// setLanguageConfiguration requires a regexp for the wordpattern, not a string
|
||||
langConfig.wordPattern = new RegExp(langConfig.wordPattern);
|
||||
langConfig.onEnterRules = onEnterRules;
|
||||
|
||||
languages.setLanguageConfiguration('ql', langConfig);
|
||||
languages.setLanguageConfiguration('qll', langConfig);
|
||||
languages.setLanguageConfiguration('dbscheme', langConfig);
|
||||
|
||||
}
|
||||
|
||||
const onEnterRules = [
|
||||
{
|
||||
// e.g. /** | */
|
||||
beforeText: /^\s*\/\*\*(?!\/)([^\*]|\*(?!\/))*$/,
|
||||
afterText: /^\s*\*\/$/,
|
||||
action: { indentAction: IndentAction.IndentOutdent, appendText: ' * ' }
|
||||
}, {
|
||||
// e.g. /** ...|
|
||||
beforeText: /^\s*\/\*\*(?!\/)([^\*]|\*(?!\/))*$/,
|
||||
action: { indentAction: IndentAction.None, appendText: ' * ' }
|
||||
}, {
|
||||
// e.g. * ...|
|
||||
beforeText: /^(\t|[ ])*[ ]\*([ ]([^\*]|\*(?!\/))*)?$/,
|
||||
oneLineAboveText: /^(\s*(\/\*\*|\*)).*/,
|
||||
action: { indentAction: IndentAction.None, appendText: '* ' }
|
||||
}, {
|
||||
// e.g. */|
|
||||
beforeText: /^(\t|[ ])*[ ]\*\/\s*$/,
|
||||
action: { indentAction: IndentAction.None, removeText: 1 }
|
||||
},
|
||||
{
|
||||
// e.g. *-----*/|
|
||||
beforeText: /^(\t|[ ])*[ ]\*[^/]*\*\/\s*$/,
|
||||
action: { indentAction: IndentAction.None, removeText: 1 }
|
||||
}
|
||||
];
|
||||
@@ -1,4 +1,4 @@
|
||||
import { window as Window, OutputChannel, Progress, ExtensionContext, Disposable } from 'vscode';
|
||||
import { window as Window, OutputChannel, Progress, Disposable } from 'vscode';
|
||||
import { DisposableObject } from 'semmle-vscode-utils';
|
||||
import * as fs from 'fs-extra';
|
||||
import * as path from 'path';
|
||||
@@ -47,8 +47,8 @@ export class OutputChannelLogger extends DisposableObject implements Logger {
|
||||
this.push(this.outputChannel);
|
||||
}
|
||||
|
||||
init(ctx: ExtensionContext): void {
|
||||
this.additionalLogLocationPath = path.join(ctx.storagePath || ctx.globalStoragePath, this.title);
|
||||
init(storagePath: string): void {
|
||||
this.additionalLogLocationPath = path.join(storagePath, this.title);
|
||||
|
||||
// clear out any old state from previous runs
|
||||
fs.remove(this.additionalLogLocationPath);
|
||||
|
||||
@@ -74,7 +74,7 @@ class HistoryTreeDataProvider implements vscode.TreeDataProvider<CompletedQuery>
|
||||
constructor(private ctx: ExtensionContext) {
|
||||
}
|
||||
|
||||
getTreeItem(element: CompletedQuery): vscode.TreeItem {
|
||||
async getTreeItem(element: CompletedQuery): Promise<vscode.TreeItem> {
|
||||
const it = new vscode.TreeItem(element.toString());
|
||||
|
||||
it.command = {
|
||||
@@ -83,6 +83,11 @@ class HistoryTreeDataProvider implements vscode.TreeDataProvider<CompletedQuery>
|
||||
arguments: [element],
|
||||
};
|
||||
|
||||
// Mark this query history item according to whether it has a
|
||||
// SARIF file so that we can make context menu items conditionally
|
||||
// available.
|
||||
it.contextValue = await element.query.hasInterpretedResults() ? 'interpretedResultsItem' : 'rawResultsItem';
|
||||
|
||||
if (!element.didRunSuccessfully) {
|
||||
it.iconPath = path.join(this.ctx.extensionPath, FAILED_QUERY_HISTORY_ITEM_ICON);
|
||||
}
|
||||
@@ -257,6 +262,22 @@ export class QueryHistoryManager {
|
||||
}
|
||||
}
|
||||
|
||||
async handleViewSarif(queryHistoryItem: CompletedQuery) {
|
||||
try {
|
||||
const hasInterpretedResults = await queryHistoryItem.query.canHaveInterpretedResults();
|
||||
if (hasInterpretedResults) {
|
||||
const textDocument = await vscode.workspace.openTextDocument(vscode.Uri.file(queryHistoryItem.query.resultsPaths.interpretedResultsPath));
|
||||
await vscode.window.showTextDocument(textDocument, vscode.ViewColumn.One);
|
||||
}
|
||||
else {
|
||||
const label = queryHistoryItem.getLabel();
|
||||
helpers.showAndLogInformationMessage(`Query ${label} has no interpreted results.`);
|
||||
}
|
||||
} catch (e) {
|
||||
helpers.showAndLogErrorMessage(e.message);
|
||||
}
|
||||
}
|
||||
|
||||
async getQueryText(queryHistoryItem: CompletedQuery): Promise<string> {
|
||||
if (queryHistoryItem.options.queryText) {
|
||||
return queryHistoryItem.options.queryText;
|
||||
@@ -290,11 +311,13 @@ export class QueryHistoryManager {
|
||||
this.updateTreeViewSelectionIfVisible();
|
||||
}
|
||||
});
|
||||
logger.log('Registering query history panel commands.');
|
||||
ctx.subscriptions.push(vscode.commands.registerCommand('codeQLQueryHistory.openQuery', this.handleOpenQuery));
|
||||
ctx.subscriptions.push(vscode.commands.registerCommand('codeQLQueryHistory.removeHistoryItem', this.handleRemoveHistoryItem.bind(this)));
|
||||
ctx.subscriptions.push(vscode.commands.registerCommand('codeQLQueryHistory.setLabel', this.handleSetLabel.bind(this)));
|
||||
ctx.subscriptions.push(vscode.commands.registerCommand('codeQLQueryHistory.showQueryLog', this.handleShowQueryLog.bind(this)));
|
||||
ctx.subscriptions.push(vscode.commands.registerCommand('codeQLQueryHistory.showQueryText', this.handleShowQueryText.bind(this)));
|
||||
ctx.subscriptions.push(vscode.commands.registerCommand('codeQLQueryHistory.viewSarif', this.handleViewSarif.bind(this)));
|
||||
ctx.subscriptions.push(vscode.commands.registerCommand('codeQLQueryHistory.itemClicked', async (item) => {
|
||||
return this.handleItemClicked(item);
|
||||
}));
|
||||
@@ -305,7 +328,7 @@ export class QueryHistoryManager {
|
||||
// displays query text in a read-only document
|
||||
vscode.workspace.registerTextDocumentContentProvider('codeql', {
|
||||
provideTextDocumentContent(uri: vscode.Uri): vscode.ProviderResult<string> {
|
||||
const params = new URLSearchParams(uri.query)
|
||||
const params = new URLSearchParams(uri.query);
|
||||
|
||||
return (
|
||||
JSON.parse(params.get('isQuickEval') || '') ? SHOW_QUERY_TEXT_QUICK_EVAL_MSG : SHOW_QUERY_TEXT_MSG
|
||||
|
||||
@@ -5,7 +5,7 @@ import * as cli from './cli';
|
||||
import * as sarif from 'sarif';
|
||||
import * as fs from 'fs-extra';
|
||||
import * as path from 'path';
|
||||
import { RawResultsSortState, SortedResultSetInfo, DatabaseInfo, QueryMetadata, InterpretedResultsSortState } from "./interface-types";
|
||||
import { RawResultsSortState, SortedResultSetInfo, DatabaseInfo, QueryMetadata, InterpretedResultsSortState, ResultsPaths } from "./interface-types";
|
||||
import { QueryHistoryConfig } from "./config";
|
||||
import { QueryHistoryItemOptions } from "./query-history";
|
||||
|
||||
@@ -54,13 +54,6 @@ export class CompletedQuery implements QueryWithResults {
|
||||
return helpers.getQueryName(this.query);
|
||||
}
|
||||
|
||||
/**
|
||||
* Holds if this query should produce interpreted results.
|
||||
*/
|
||||
canInterpretedResults(): Promise<boolean> {
|
||||
return this.query.dbItem.hasMetadataFile();
|
||||
}
|
||||
|
||||
get statusString(): string {
|
||||
switch (this.result.resultType) {
|
||||
case messages.QueryResultType.CANCELLATION:
|
||||
@@ -130,9 +123,8 @@ export class CompletedQuery implements QueryWithResults {
|
||||
/**
|
||||
* Call cli command to interpret results.
|
||||
*/
|
||||
export async function interpretResults(server: cli.CodeQLCliServer, metadata: QueryMetadata | undefined, resultsPath: string, sourceInfo?: cli.SourceInfo): Promise<sarif.Log> {
|
||||
const interpretedResultsPath = resultsPath + ".interpreted.sarif"
|
||||
|
||||
export async function interpretResults(server: cli.CodeQLCliServer, metadata: QueryMetadata | undefined, resultsPaths: ResultsPaths, sourceInfo?: cli.SourceInfo): Promise<sarif.Log> {
|
||||
const { resultsPath, interpretedResultsPath } = resultsPaths;
|
||||
if (await fs.pathExists(interpretedResultsPath)) {
|
||||
return JSON.parse(await fs.readFile(interpretedResultsPath, 'utf8'));
|
||||
}
|
||||
|
||||
@@ -82,7 +82,7 @@ export class QueryServerClient extends DisposableObject {
|
||||
if (this.serverProcess !== undefined) {
|
||||
this.disposeAndStopTracking(this.serverProcess);
|
||||
} else {
|
||||
this.logger.log('No server process to be stopped.')
|
||||
this.logger.log('No server process to be stopped.');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -136,13 +136,13 @@ export class QueryServerClient extends DisposableObject {
|
||||
this.evaluationResultCallbacks[res.runId](res);
|
||||
}
|
||||
return {};
|
||||
})
|
||||
});
|
||||
connection.onNotification(progress, res => {
|
||||
const callback = this.progressCallbacks[res.id];
|
||||
if (callback) {
|
||||
callback(res);
|
||||
}
|
||||
})
|
||||
});
|
||||
this.serverProcess = new ServerProcess(child, connection, this.opts.logger);
|
||||
// Ensure the server process is disposed together with this client.
|
||||
this.track(this.serverProcess);
|
||||
|
||||
@@ -87,7 +87,7 @@ export async function displayQuickQuery(ctx: ExtensionContext, cliServer: CodeQL
|
||||
return;
|
||||
}
|
||||
|
||||
const index = workspaceFolders.findIndex(folder => folder.name === QUICK_QUERY_WORKSPACE_FOLDER_NAME)
|
||||
const index = workspaceFolders.findIndex(folder => folder.name === QUICK_QUERY_WORKSPACE_FOLDER_NAME);
|
||||
if (index === -1)
|
||||
updateQuickQueryDir(queriesDir, workspaceFolders.length, 0);
|
||||
else
|
||||
|
||||
@@ -76,7 +76,7 @@ export class QueryInfo {
|
||||
): Promise<messages.EvaluationResult> {
|
||||
let result: messages.EvaluationResult | null = null;
|
||||
|
||||
const callbackId = qs.registerCallback(res => { result = res });
|
||||
const callbackId = qs.registerCallback(res => { result = res; });
|
||||
|
||||
const queryToRun: messages.QueryToRun = {
|
||||
resultsPath: this.resultsPaths.resultsPath,
|
||||
@@ -85,25 +85,25 @@ export class QueryInfo {
|
||||
templateValues: this.templates,
|
||||
id: callbackId,
|
||||
timeoutSecs: qs.config.timeoutSecs,
|
||||
}
|
||||
};
|
||||
const dataset: messages.Dataset = {
|
||||
dbDir: this.dataset.fsPath,
|
||||
workingSet: 'default'
|
||||
}
|
||||
};
|
||||
const params: messages.EvaluateQueriesParams = {
|
||||
db: dataset,
|
||||
evaluateId: callbackId,
|
||||
queries: [queryToRun],
|
||||
stopOnError: false,
|
||||
useSequenceHint: false
|
||||
}
|
||||
};
|
||||
try {
|
||||
await helpers.withProgress({
|
||||
location: vscode.ProgressLocation.Notification,
|
||||
title: "Running Query",
|
||||
cancellable: true,
|
||||
}, (progress, token) => {
|
||||
return qs.sendRequest(messages.runQueries, params, token, progress)
|
||||
return qs.sendRequest(messages.runQueries, params, token, progress);
|
||||
});
|
||||
} finally {
|
||||
qs.unRegisterCallback(callbackId);
|
||||
@@ -157,15 +157,22 @@ export class QueryInfo {
|
||||
}
|
||||
|
||||
/**
|
||||
* Holds if this query should produce interpreted results.
|
||||
* Holds if this query can in principle produce interpreted results.
|
||||
*/
|
||||
async hasInterpretedResults(): Promise<boolean> {
|
||||
async canHaveInterpretedResults(): Promise<boolean> {
|
||||
const hasMetadataFile = await this.dbItem.hasMetadataFile();
|
||||
if (!hasMetadataFile) {
|
||||
logger.log("Cannot produce interpreted results since the database does not have a .dbinfo or codeql-database.yml file.");
|
||||
}
|
||||
return hasMetadataFile;
|
||||
}
|
||||
|
||||
/**
|
||||
* Holds if this query actually has produced interpreted results.
|
||||
*/
|
||||
async hasInterpretedResults(): Promise<boolean> {
|
||||
return fs.pathExists(this.resultsPaths.interpretedResultsPath);
|
||||
}
|
||||
}
|
||||
|
||||
export interface QueryWithResults {
|
||||
@@ -263,7 +270,7 @@ async function checkDbschemeCompatibility(
|
||||
const { scripts, finalDbscheme } = await cliServer.resolveUpgrades(query.dbItem.contents.dbSchemeUri.fsPath, searchPath);
|
||||
const hash = async function(filename: string): Promise<string> {
|
||||
return crypto.createHash('sha256').update(await fs.readFile(filename)).digest('hex');
|
||||
}
|
||||
};
|
||||
|
||||
// At this point, we have learned about three dbschemes:
|
||||
|
||||
@@ -308,7 +315,7 @@ async function promptUserToSaveChanges(document: vscode.TextDocument): Promise<b
|
||||
else {
|
||||
const yesItem = { title: 'Yes', isCloseAffordance: false };
|
||||
const alwaysItem = { title: 'Always Save', isCloseAffordance: false };
|
||||
const noItem = { title: 'No', isCloseAffordance: true }
|
||||
const noItem = { title: 'No', isCloseAffordance: true };
|
||||
const message = 'Query file has unsaved changes. Save now?';
|
||||
const chosenItem = await vscode.window.showInformationMessage(message, { modal: true }, yesItem, alwaysItem, noItem);
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import * as Sarif from "sarif"
|
||||
import * as path from "path"
|
||||
import * as Sarif from "sarif";
|
||||
import * as path from "path";
|
||||
import { LocationStyle, ResolvableLocationValue } from "semmle-bqrs";
|
||||
|
||||
export interface SarifLink {
|
||||
|
||||
@@ -87,8 +87,7 @@ export class QLTestAdapter extends DisposableObject implements TestAdapter {
|
||||
private readonly _tests = this.push(
|
||||
new EventEmitter<TestLoadStartedEvent | TestLoadFinishedEvent>());
|
||||
private readonly _testStates = this.push(
|
||||
new EventEmitter<TestRunStartedEvent | TestRunFinishedEvent | TestSuiteEvent |
|
||||
TestEvent>());
|
||||
new EventEmitter<TestRunStartedEvent | TestRunFinishedEvent | TestSuiteEvent | TestEvent>());
|
||||
private readonly _autorun = this.push(new EventEmitter<void>());
|
||||
private runningTask?: vscode.CancellationTokenSource = undefined;
|
||||
|
||||
@@ -108,9 +107,7 @@ export class QLTestAdapter extends DisposableObject implements TestAdapter {
|
||||
return this._tests.event;
|
||||
}
|
||||
|
||||
public get testStates(): Event<TestRunStartedEvent | TestRunFinishedEvent | TestSuiteEvent |
|
||||
TestEvent> {
|
||||
|
||||
public get testStates(): Event<TestRunStartedEvent | TestRunFinishedEvent | TestSuiteEvent | TestEvent> {
|
||||
return this._testStates.event;
|
||||
}
|
||||
|
||||
@@ -118,9 +115,7 @@ export class QLTestAdapter extends DisposableObject implements TestAdapter {
|
||||
return this._autorun.event;
|
||||
}
|
||||
|
||||
private static createTestOrSuiteInfos(testNodes: readonly QLTestNode[]):
|
||||
(TestSuiteInfo | TestInfo)[] {
|
||||
|
||||
private static createTestOrSuiteInfos(testNodes: readonly QLTestNode[]): (TestSuiteInfo | TestInfo)[] {
|
||||
return testNodes.map((childNode) => {
|
||||
return QLTestAdapter.createTestOrSuiteInfo(childNode);
|
||||
});
|
||||
@@ -129,11 +124,9 @@ export class QLTestAdapter extends DisposableObject implements TestAdapter {
|
||||
private static createTestOrSuiteInfo(testNode: QLTestNode): TestSuiteInfo | TestInfo {
|
||||
if (testNode instanceof QLTestFile) {
|
||||
return QLTestAdapter.createTestInfo(testNode);
|
||||
}
|
||||
else if (testNode instanceof QLTestDirectory) {
|
||||
} else if (testNode instanceof QLTestDirectory) {
|
||||
return QLTestAdapter.createTestSuiteInfo(testNode, testNode.name);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
throw new Error('Unexpected test type.');
|
||||
}
|
||||
}
|
||||
@@ -148,9 +141,7 @@ export class QLTestAdapter extends DisposableObject implements TestAdapter {
|
||||
};
|
||||
}
|
||||
|
||||
private static createTestSuiteInfo(testDirectory: QLTestDirectory, label: string):
|
||||
TestSuiteInfo {
|
||||
|
||||
private static createTestSuiteInfo(testDirectory: QLTestDirectory, label: string): TestSuiteInfo {
|
||||
return {
|
||||
type: 'suite',
|
||||
id: testDirectory.path,
|
||||
|
||||
@@ -5,6 +5,7 @@ import { TestTreeNode } from './test-tree-node';
|
||||
import { DisposableObject, UIService } from 'semmle-vscode-utils';
|
||||
import { TestHub, TestController, TestAdapter, TestRunStartedEvent, TestRunFinishedEvent, TestEvent, TestSuiteEvent } from 'vscode-test-adapter-api';
|
||||
import { QLTestAdapter, getExpectedFile, getActualFile } from './test-adapter';
|
||||
import { logger } from './logging';
|
||||
|
||||
type VSCodeTestEvent = TestRunStartedEvent | TestRunFinishedEvent | TestSuiteEvent | TestEvent;
|
||||
|
||||
@@ -32,6 +33,7 @@ export class TestUIService extends UIService implements TestController {
|
||||
constructor(private readonly testHub: TestHub) {
|
||||
super();
|
||||
|
||||
logger.log('Registering CodeQL test panel commands.');
|
||||
this.registerCommand('codeQLTests.showOutputDifferences', this.showOutputDifferences);
|
||||
this.registerCommand('codeQLTests.acceptOutput', this.acceptOutput);
|
||||
|
||||
|
||||
@@ -80,7 +80,7 @@ async function checkAndConfirmDatabaseUpgrade(
|
||||
|
||||
const showLogItem: vscode.MessageItem = { title: 'No, Show Changes', isCloseAffordance: true };
|
||||
const yesItem = { title: 'Yes', isCloseAffordance: false };
|
||||
const noItem = { title: 'No', isCloseAffordance: true }
|
||||
const noItem = { title: 'No', isCloseAffordance: true };
|
||||
const dialogOptions: vscode.MessageItem[] = [yesItem, noItem];
|
||||
|
||||
let messageLines = descriptionMessage.split('\n');
|
||||
@@ -129,7 +129,7 @@ export async function upgradeDatabase(
|
||||
return;
|
||||
}
|
||||
finally {
|
||||
qs.logger.log('Done compiling database upgrade.')
|
||||
qs.logger.log('Done compiling database upgrade.');
|
||||
}
|
||||
|
||||
if (compileUpgradeResult.compiledUpgrades === undefined) {
|
||||
@@ -148,7 +148,7 @@ export async function upgradeDatabase(
|
||||
return;
|
||||
}
|
||||
finally {
|
||||
qs.logger.log('Done running database upgrade.')
|
||||
qs.logger.log('Done running database upgrade.');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -168,7 +168,7 @@ async function compileDatabaseUpgrade(
|
||||
const params: messages.CompileUpgradeParams = {
|
||||
upgrade: upgradeParams,
|
||||
upgradeTempDir: upgradesTmpDir.name
|
||||
}
|
||||
};
|
||||
|
||||
return helpers.withProgress({
|
||||
location: vscode.ProgressLocation.Notification,
|
||||
|
||||
@@ -69,6 +69,14 @@ export class PathTable extends React.Component<PathTableProps, PathTableState> {
|
||||
});
|
||||
}
|
||||
|
||||
renderNoResults(): JSX.Element {
|
||||
if (this.props.nonemptyRawResults) {
|
||||
return <span>No Alerts. See <a href='#' onClick={this.props.showRawResults}>raw results</a>.</span>;
|
||||
} else {
|
||||
return <span>No Alerts</span>;
|
||||
}
|
||||
}
|
||||
|
||||
render(): JSX.Element {
|
||||
const { databaseUri, resultSet } = this.props;
|
||||
|
||||
@@ -116,7 +124,7 @@ export class PathTable extends React.Component<PathTableProps, PathTableState> {
|
||||
...previousState,
|
||||
selectedPathNode: pathNodeKey
|
||||
}));
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
function renderSarifLocationWithText(text: string | undefined, loc: Sarif.Location, pathNodeKey: Keys.PathNode | undefined): JSX.Element | undefined {
|
||||
@@ -156,13 +164,14 @@ export class PathTable extends React.Component<PathTableProps, PathTableState> {
|
||||
return (e) => this.toggle(e, indices);
|
||||
};
|
||||
|
||||
const noResults = <span>No Results</span>; // TODO: Maybe make this look nicer
|
||||
if (resultSet.sarif.runs.length === 0 ||
|
||||
resultSet.sarif.runs[0].results === undefined ||
|
||||
resultSet.sarif.runs[0].results.length === 0) {
|
||||
return this.renderNoResults();
|
||||
}
|
||||
|
||||
let expansionIndex = 0;
|
||||
|
||||
if (resultSet.sarif.runs.length === 0) return noResults;
|
||||
if (resultSet.sarif.runs[0].results === undefined) return noResults;
|
||||
|
||||
resultSet.sarif.runs[0].results.forEach((result, resultIndex) => {
|
||||
const text = result.message.text || '[no text]';
|
||||
const msg: JSX.Element[] =
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import * as React from "react";
|
||||
import { renderLocation, ResultTableProps, zebraStripe, className, nextSortDirection } from "./result-table-utils";
|
||||
import { RawTableResultSet, ResultValue, vscode } from "./results";
|
||||
import { RawTableResultSet, vscode } from "./results";
|
||||
import { ResultValue } from "../adapt";
|
||||
import { SortDirection, RAW_RESULTS_LIMIT, RawResultsSortState } from "../interface-types";
|
||||
|
||||
export type RawTableProps = ResultTableProps & {
|
||||
@@ -88,7 +89,7 @@ export class RawTable extends React.Component<RawTableProps, {}> {
|
||||
*/
|
||||
function renderTupleValue(v: ResultValue, databaseUri: string): JSX.Element {
|
||||
if (typeof v === 'string') {
|
||||
return <span>{v}</span>
|
||||
return <span>{v}</span>;
|
||||
}
|
||||
else if ('uri' in v) {
|
||||
return <a href={v.uri}>{v.uri}</a>;
|
||||
|
||||
@@ -10,6 +10,18 @@ export interface ResultTableProps {
|
||||
metadata?: QueryMetadata;
|
||||
resultsPath: string | undefined;
|
||||
sortState?: RawResultsSortState;
|
||||
|
||||
/**
|
||||
* Holds if there are any raw results. When that is the case, we
|
||||
* want to direct users to pay attention to raw results if
|
||||
* interpreted results are empty.
|
||||
*/
|
||||
nonemptyRawResults: boolean;
|
||||
|
||||
/**
|
||||
* Callback to show raw results.
|
||||
*/
|
||||
showRawResults: () => void;
|
||||
}
|
||||
|
||||
export const className = 'vscode-codeql__result-table';
|
||||
@@ -66,7 +78,7 @@ export function renderLocation(loc: LocationValue | undefined, label: string | u
|
||||
return <span title={title}>{displayLabel}</span>;
|
||||
}
|
||||
}
|
||||
return <span />
|
||||
return <span />;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -83,7 +95,7 @@ export function zebraStripe(index: number, ...otherClasses: string[]): { classNa
|
||||
export function selectableZebraStripe(isSelected: boolean, index: number, ...otherClasses: string[]): { className: string } {
|
||||
return isSelected
|
||||
? { className: [selectedRowClassName, ...otherClasses].join(' ') }
|
||||
: zebraStripe(index, ...otherClasses)
|
||||
: zebraStripe(index, ...otherClasses);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -85,7 +85,7 @@ export class ResultTables
|
||||
}
|
||||
|
||||
private static getDefaultResultSet(resultSets: readonly ResultSet[]): string {
|
||||
const resultSetNames = resultSets.map(resultSet => resultSet.schema.name)
|
||||
const resultSetNames = resultSets.map(resultSet => resultSet.schema.name);
|
||||
// Choose first available result set from the array
|
||||
return [ALERTS_TABLE_NAME, SELECT_TABLE_NAME, resultSets[0].schema.name].filter(resultSetName => resultSetNames.includes(resultSetName))[0];
|
||||
}
|
||||
@@ -115,7 +115,7 @@ export class ResultTables
|
||||
|
||||
return <div className={alertExtrasClassName}>
|
||||
{displayProblemsAsAlertsToggle}
|
||||
</div>
|
||||
</div>;
|
||||
}
|
||||
|
||||
render(): React.ReactNode {
|
||||
@@ -123,6 +123,7 @@ export class ResultTables
|
||||
const resultSets = this.getResultSets();
|
||||
|
||||
const resultSet = resultSets.find(resultSet => resultSet.schema.name == selectedTable);
|
||||
const nonemptyRawResults = resultSets.some(resultSet => resultSet.t == 'RawResultSet' && resultSet.rows.length > 0);
|
||||
const numberOfResults = resultSet && renderResultCountString(resultSet);
|
||||
|
||||
return <div>
|
||||
@@ -149,7 +150,9 @@ export class ResultTables
|
||||
<ResultTable key={resultSet.schema.name} resultSet={resultSet}
|
||||
databaseUri={this.props.database.databaseUri}
|
||||
resultsPath={this.props.resultsPath}
|
||||
sortState={this.props.sortStates.get(resultSet.schema.name)} />
|
||||
sortState={this.props.sortStates.get(resultSet.schema.name)}
|
||||
nonemptyRawResults={nonemptyRawResults}
|
||||
showRawResults={() => { this.setState({ selectedTable: SELECT_TABLE_NAME }); }} />
|
||||
}
|
||||
</div>;
|
||||
}
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
import * as React from 'react';
|
||||
import * as Rdom from 'react-dom';
|
||||
import * as bqrs from 'semmle-bqrs';
|
||||
import { ElementBase, LocationValue, PrimitiveColumnValue, PrimitiveTypeKind, ResultSetSchema, tryGetResolvableLocation } from 'semmle-bqrs';
|
||||
import { ElementBase, PrimitiveColumnValue, PrimitiveTypeKind, ResultSetSchema, tryGetResolvableLocation } from 'semmle-bqrs';
|
||||
import { assertNever } from '../helpers-pure';
|
||||
import { DatabaseInfo, FromResultsViewMsg, Interpretation, IntoResultsViewMsg, SortedResultSetInfo, RawResultsSortState, NavigatePathMsg, QueryMetadata, ResultsPaths } from '../interface-types';
|
||||
import { EventHandlers as EventHandlerList } from './event-handler-list';
|
||||
import { ResultTables } from './result-tables';
|
||||
import { RawResultSet, ResultValue, ResultRow } from '../adapt';
|
||||
|
||||
/**
|
||||
* results.tsx
|
||||
@@ -23,19 +24,6 @@ interface VsCodeApi {
|
||||
declare const acquireVsCodeApi: () => VsCodeApi;
|
||||
export const vscode = acquireVsCodeApi();
|
||||
|
||||
export interface ResultElement {
|
||||
label: string;
|
||||
location?: LocationValue;
|
||||
}
|
||||
|
||||
export interface ResultUri {
|
||||
uri: string;
|
||||
}
|
||||
|
||||
export type ResultValue = ResultElement | ResultUri | string;
|
||||
|
||||
export type ResultRow = ResultValue[];
|
||||
|
||||
export type RawTableResultSet = { t: 'RawResultSet' } & RawResultSet;
|
||||
export type PathTableResultSet = { t: 'SarifResultSet'; readonly schema: ResultSetSchema; name: string } & Interpretation;
|
||||
|
||||
@@ -43,11 +31,6 @@ export type ResultSet =
|
||||
| RawTableResultSet
|
||||
| PathTableResultSet;
|
||||
|
||||
export interface RawResultSet {
|
||||
readonly schema: ResultSetSchema;
|
||||
readonly rows: readonly ResultRow[];
|
||||
}
|
||||
|
||||
async function* getChunkIterator(response: Response): AsyncIterableIterator<Uint8Array> {
|
||||
if (!response.ok) {
|
||||
throw new Error(`Failed to load results: (${response.status}) ${response.statusText}`);
|
||||
@@ -62,9 +45,7 @@ async function* getChunkIterator(response: Response): AsyncIterableIterator<Uint
|
||||
}
|
||||
}
|
||||
|
||||
function translatePrimitiveValue(value: PrimitiveColumnValue, type: PrimitiveTypeKind):
|
||||
ResultValue {
|
||||
|
||||
function translatePrimitiveValue(value: PrimitiveColumnValue, type: PrimitiveTypeKind): ResultValue {
|
||||
switch (type) {
|
||||
case 'i':
|
||||
case 'f':
|
||||
@@ -127,6 +108,7 @@ async function parseResultSets(response: Response): Promise<readonly ResultSet[]
|
||||
|
||||
interface ResultsInfo {
|
||||
resultsPath: string;
|
||||
resultSets: ResultSet[] | undefined;
|
||||
origResultsPaths: ResultsPaths;
|
||||
database: DatabaseInfo;
|
||||
interpretation: Interpretation | undefined;
|
||||
@@ -187,6 +169,7 @@ class App extends React.Component<{}, ResultsViewState> {
|
||||
case 'setState':
|
||||
this.updateStateWithNewResultsInfo({
|
||||
resultsPath: msg.resultsPath,
|
||||
resultSets: msg.resultSets?.map(x => ({ t: 'RawResultSet', ...x })),
|
||||
origResultsPaths: msg.origResultsPaths,
|
||||
sortedResultsMap: new Map(Object.entries(msg.sortedResultsMap)),
|
||||
database: msg.database,
|
||||
@@ -247,8 +230,9 @@ class App extends React.Component<{}, ResultsViewState> {
|
||||
let results: Results | null = null;
|
||||
let statusText = '';
|
||||
try {
|
||||
const resultSets = resultsInfo.resultSets || await this.getResultSets(resultsInfo);
|
||||
results = {
|
||||
resultSets: await this.getResultSets(resultsInfo),
|
||||
resultSets,
|
||||
database: resultsInfo.database,
|
||||
sortStates: this.getSortStates(resultsInfo)
|
||||
};
|
||||
@@ -277,7 +261,7 @@ class App extends React.Component<{}, ResultsViewState> {
|
||||
},
|
||||
nextResultsInfo: null,
|
||||
isExpectingResultsUpdate: false
|
||||
}
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
@@ -341,4 +325,4 @@ Rdom.render(
|
||||
document.getElementById('root')
|
||||
);
|
||||
|
||||
vscode.postMessage({ t: "resultViewLoaded" })
|
||||
vscode.postMessage({ t: "resultViewLoaded" });
|
||||
|
||||
@@ -75,7 +75,7 @@
|
||||
}
|
||||
|
||||
.vscode-codeql__result-table-location-link {
|
||||
font-family: SFMono-Regular, Consolas, "Liberation Mono", Menlo, Courier, monospace;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
select {
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
import { expect } from "chai";
|
||||
import * as path from "path";
|
||||
import { ArchiveFileSystemProvider, decodeSourceArchiveUri, encodeSourceArchiveUri, ZipFileReference } from "../../archive-filesystem-provider";
|
||||
import { expect } from 'chai';
|
||||
import * as path from 'path';
|
||||
|
||||
describe("archive filesystem provider", () => {
|
||||
import { encodeSourceArchiveUri, ArchiveFileSystemProvider, decodeSourceArchiveUri, ZipFileReference } from '../../archive-filesystem-provider';
|
||||
import { FileType, FileSystemError } from 'vscode';
|
||||
|
||||
describe('archive-filesystem-provider', () => {
|
||||
it("reads empty file correctly", async () => {
|
||||
const archiveProvider = new ArchiveFileSystemProvider();
|
||||
const uri = encodeSourceArchiveUri({
|
||||
@@ -12,6 +14,98 @@ describe("archive filesystem provider", () => {
|
||||
const data = await archiveProvider.readFile(uri);
|
||||
expect(data.length).to.equal(0);
|
||||
});
|
||||
|
||||
it("read non-empty file correctly", async () => {
|
||||
const archiveProvider = new ArchiveFileSystemProvider();
|
||||
const uri = encodeSourceArchiveUri({
|
||||
sourceArchiveZipPath: path.resolve(__dirname, "data/archive-filesystem-provider-test/zip_with_folder.zip"),
|
||||
pathWithinSourceArchive: "folder1/textFile.txt"
|
||||
});
|
||||
const data = await archiveProvider.readFile(uri);
|
||||
expect(Buffer.from(data).toString('utf8')).to.be.equal('I am a text\n');
|
||||
});
|
||||
|
||||
it("read a directory", async () => {
|
||||
const archiveProvider = new ArchiveFileSystemProvider();
|
||||
const uri = encodeSourceArchiveUri({
|
||||
sourceArchiveZipPath: path.resolve(__dirname, "data/archive-filesystem-provider-test/zip_with_folder.zip"),
|
||||
pathWithinSourceArchive: "folder1"
|
||||
});
|
||||
const files = await archiveProvider.readDirectory(uri);
|
||||
expect(files).to.be.deep.equal([
|
||||
['folder2', FileType.Directory],
|
||||
['textFile.txt', FileType.File],
|
||||
['textFile2.txt', FileType.File],
|
||||
]);
|
||||
});
|
||||
|
||||
it('should handle a missing directory', async () => {
|
||||
const archiveProvider = new ArchiveFileSystemProvider();
|
||||
const uri = encodeSourceArchiveUri({
|
||||
sourceArchiveZipPath: path.resolve(__dirname, "data/archive-filesystem-provider-test/zip_with_folder.zip"),
|
||||
pathWithinSourceArchive: "folder1/not-here"
|
||||
});
|
||||
try {
|
||||
await archiveProvider.readDirectory(uri);
|
||||
throw new Error('Failed');
|
||||
} catch (e) {
|
||||
expect(e).to.be.instanceOf(FileSystemError);
|
||||
}
|
||||
});
|
||||
|
||||
it('should handle a missing file', async () => {
|
||||
const archiveProvider = new ArchiveFileSystemProvider();
|
||||
const uri = encodeSourceArchiveUri({
|
||||
sourceArchiveZipPath: path.resolve(__dirname, "data/archive-filesystem-provider-test/zip_with_folder.zip"),
|
||||
pathWithinSourceArchive: "folder1/not-here"
|
||||
});
|
||||
try {
|
||||
await archiveProvider.readFile(uri);
|
||||
throw new Error('Failed');
|
||||
} catch (e) {
|
||||
expect(e).to.be.instanceOf(FileSystemError);
|
||||
}
|
||||
});
|
||||
|
||||
it('should handle reading a file as a directory', async () => {
|
||||
const archiveProvider = new ArchiveFileSystemProvider();
|
||||
const uri = encodeSourceArchiveUri({
|
||||
sourceArchiveZipPath: path.resolve(__dirname, "data/archive-filesystem-provider-test/zip_with_folder.zip"),
|
||||
pathWithinSourceArchive: "folder1/textFile.txt"
|
||||
});
|
||||
try {
|
||||
await archiveProvider.readDirectory(uri);
|
||||
throw new Error('Failed');
|
||||
} catch (e) {
|
||||
expect(e).to.be.instanceOf(FileSystemError);
|
||||
}
|
||||
});
|
||||
|
||||
it('should handle reading a directory as a file', async () => {
|
||||
const archiveProvider = new ArchiveFileSystemProvider();
|
||||
const uri = encodeSourceArchiveUri({
|
||||
sourceArchiveZipPath: path.resolve(__dirname, "data/archive-filesystem-provider-test/zip_with_folder.zip"),
|
||||
pathWithinSourceArchive: "folder1/folder2"
|
||||
});
|
||||
try {
|
||||
await archiveProvider.readFile(uri);
|
||||
throw new Error('Failed');
|
||||
} catch (e) {
|
||||
expect(e).to.be.instanceOf(FileSystemError);
|
||||
}
|
||||
});
|
||||
|
||||
it("read a nested directory", async () => {
|
||||
const archiveProvider = new ArchiveFileSystemProvider();
|
||||
const uri = encodeSourceArchiveUri({
|
||||
sourceArchiveZipPath: path.resolve(__dirname, "data/archive-filesystem-provider-test/zip_with_folder.zip"),
|
||||
pathWithinSourceArchive: "folder1/folder2"
|
||||
});
|
||||
const files = await archiveProvider.readDirectory(uri);
|
||||
expect(files).to.be.deep.equal([
|
||||
['textFile3.txt', FileType.File],
|
||||
]);
|
||||
});
|
||||
});
|
||||
|
||||
describe('source archive uri encoding', function() {
|
||||
|
||||
@@ -0,0 +1,140 @@
|
||||
import "vscode-test";
|
||||
import "mocha";
|
||||
import * as chaiAsPromised from "chai-as-promised";
|
||||
import * as sinon from "sinon";
|
||||
// import * as sinonChai from 'sinon-chai';
|
||||
import * as path from "path";
|
||||
import * as fs from "fs-extra";
|
||||
import * as tmp from "tmp";
|
||||
import * as chai from "chai";
|
||||
import { window } from "vscode";
|
||||
|
||||
import {
|
||||
convertToDatabaseUrl,
|
||||
looksLikeLgtmUrl,
|
||||
findDirWithFile,
|
||||
} from "../../databaseFetcher";
|
||||
chai.use(chaiAsPromised);
|
||||
const expect = chai.expect;
|
||||
|
||||
describe("databaseFetcher", () => {
|
||||
describe("convertToDatabaseUrl", () => {
|
||||
let quickPickSpy: sinon.SinonStub;
|
||||
beforeEach(() => {
|
||||
quickPickSpy = sinon.stub(window, "showQuickPick");
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
(window.showQuickPick as sinon.SinonStub).restore();
|
||||
});
|
||||
|
||||
it("should convert a project url to a database url", async () => {
|
||||
quickPickSpy.returns("javascript" as any);
|
||||
const lgtmUrl = "https://lgtm.com/projects/g/github/codeql";
|
||||
const dbUrl = await convertToDatabaseUrl(lgtmUrl);
|
||||
|
||||
expect(dbUrl).to.equal(
|
||||
"https://lgtm.com/api/v1.0/snapshots/1506465042581/javascript"
|
||||
);
|
||||
expect(quickPickSpy.firstCall.args[0]).to.contain("javascript");
|
||||
expect(quickPickSpy.firstCall.args[0]).to.contain("python");
|
||||
});
|
||||
|
||||
it("should convert a project url to a database url with extra path segments", async () => {
|
||||
quickPickSpy.returns("python" as any);
|
||||
const lgtmUrl =
|
||||
"https://lgtm.com/projects/g/github/codeql/subpage/subpage2?query=xxx";
|
||||
const dbUrl = await convertToDatabaseUrl(lgtmUrl);
|
||||
|
||||
expect(dbUrl).to.equal(
|
||||
"https://lgtm.com/api/v1.0/snapshots/1506465042581/python"
|
||||
);
|
||||
});
|
||||
|
||||
it("should fail on a nonexistant prohect", async () => {
|
||||
quickPickSpy.returns("javascript" as any);
|
||||
const lgtmUrl = "https://lgtm.com/projects/g/github/hucairz";
|
||||
expect(convertToDatabaseUrl(lgtmUrl)).to.rejectedWith(/Invalid LGTM URL/);
|
||||
});
|
||||
});
|
||||
|
||||
describe("looksLikeLgtmUrl", () => {
|
||||
it("should handle invalid urls", () => {
|
||||
expect(looksLikeLgtmUrl("")).to.be.false;
|
||||
expect(looksLikeLgtmUrl("http://lgtm.com/projects/g/github/codeql")).to.be
|
||||
.false;
|
||||
expect(looksLikeLgtmUrl("https://ww.lgtm.com/projects/g/github/codeql"))
|
||||
.to.be.false;
|
||||
expect(looksLikeLgtmUrl("https://ww.lgtm.com/projects/g/github")).to.be
|
||||
.false;
|
||||
});
|
||||
|
||||
it("should handle valid urls", () => {
|
||||
expect(looksLikeLgtmUrl("https://lgtm.com/projects/g/github/codeql")).to
|
||||
.be.true;
|
||||
expect(looksLikeLgtmUrl("https://www.lgtm.com/projects/g/github/codeql"))
|
||||
.to.be.true;
|
||||
expect(
|
||||
looksLikeLgtmUrl("https://lgtm.com/projects/g/github/codeql/sub/pages")
|
||||
).to.be.true;
|
||||
expect(
|
||||
looksLikeLgtmUrl(
|
||||
"https://lgtm.com/projects/g/github/codeql/sub/pages?query=string"
|
||||
)
|
||||
).to.be.true;
|
||||
});
|
||||
});
|
||||
|
||||
describe("findDirWithFile", () => {
|
||||
let dir: tmp.DirResult;
|
||||
beforeEach(() => {
|
||||
dir = tmp.dirSync({ unsafeCleanup: true });
|
||||
createFile("a");
|
||||
createFile("b");
|
||||
createFile("c");
|
||||
|
||||
createDir("dir1");
|
||||
createFile("dir1", "d");
|
||||
createFile("dir1", "e");
|
||||
createFile("dir1", "f");
|
||||
|
||||
createDir("dir2");
|
||||
createFile("dir2", "g");
|
||||
createFile("dir2", "h");
|
||||
createFile("dir2", "i");
|
||||
|
||||
createDir("dir2", "dir3");
|
||||
createFile("dir2", "dir3", "j");
|
||||
createFile("dir2", "dir3", "k");
|
||||
createFile("dir2", "dir3", "l");
|
||||
});
|
||||
|
||||
it("should find files", async () => {
|
||||
expect(await findDirWithFile(dir.name, "k")).to.equal(
|
||||
path.join(dir.name, "dir2", "dir3")
|
||||
);
|
||||
expect(await findDirWithFile(dir.name, "h")).to.equal(
|
||||
path.join(dir.name, "dir2")
|
||||
);
|
||||
expect(await findDirWithFile(dir.name, "z", "a")).to.equal(dir.name);
|
||||
// there's some slight indeterminism when more than one name exists
|
||||
// but in general, this will find files in the current directory before
|
||||
// finding files in sub-dirs
|
||||
expect(await findDirWithFile(dir.name, "k", "a")).to.equal(dir.name);
|
||||
});
|
||||
|
||||
|
||||
it("should not find files", async () => {
|
||||
expect(await findDirWithFile(dir.name, "x", "y", "z")).to.be.undefined;
|
||||
});
|
||||
|
||||
|
||||
function createFile(...segments: string[]) {
|
||||
fs.createFileSync(path.join(dir.name, ...segments));
|
||||
}
|
||||
|
||||
function createDir(...segments: string[]) {
|
||||
fs.mkdirSync(path.join(dir.name, ...segments));
|
||||
}
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,47 @@
|
||||
import 'vscode-test';
|
||||
import 'mocha';
|
||||
import * as tmp from 'tmp';
|
||||
import * as path from 'path';
|
||||
import * as fs from 'fs-extra';
|
||||
import { expect } from 'chai';
|
||||
import { Uri } from 'vscode';
|
||||
|
||||
import { DatabaseUI } from '../../databases-ui';
|
||||
|
||||
describe('databases-ui', () => {
|
||||
describe('fixDbUri', () => {
|
||||
const fixDbUri = (DatabaseUI.prototype as any).fixDbUri;
|
||||
it('should choose current directory direcory normally', async () => {
|
||||
const dir = tmp.dirSync().name;
|
||||
const uri = await fixDbUri(Uri.file(dir));
|
||||
expect(uri.toString()).to.eq(Uri.file(dir).toString());
|
||||
});
|
||||
|
||||
it('should choose parent direcory when file is selected', async () => {
|
||||
const file = tmp.fileSync().name;
|
||||
const uri = await fixDbUri(Uri.file(file));
|
||||
expect(uri.toString()).to.eq(Uri.file(path.dirname(file)).toString());
|
||||
});
|
||||
|
||||
it('should choose parent direcory when db-* is selected', async () => {
|
||||
const dir = tmp.dirSync().name;
|
||||
const dbDir = path.join(dir, 'db-hucairz');
|
||||
await fs.mkdirs(dbDir);
|
||||
|
||||
const uri = await fixDbUri(Uri.file(dbDir));
|
||||
expect(uri.toString()).to.eq(Uri.file(dir).toString());
|
||||
});
|
||||
|
||||
it('should choose parent\'s parent direcory when file selected is in db-*', async () => {
|
||||
const dir = tmp.dirSync().name;
|
||||
const dbDir = path.join(dir, 'db-hucairz');
|
||||
const file = path.join(dbDir, 'nested');
|
||||
await fs.mkdirs(dbDir);
|
||||
await fs.createFile(file);
|
||||
|
||||
const uri = await fixDbUri(Uri.file(file));
|
||||
expect(uri.toString()).to.eq(Uri.file(dir).toString());
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
@@ -6,7 +6,7 @@ import { parseSarifPlainTextMessage } from '../../sarif-utils';
|
||||
|
||||
describe('parsing sarif', () => {
|
||||
it('should be able to parse a simple message from the spec', async function() {
|
||||
const message = "Tainted data was used. The data came from [here](3)."
|
||||
const message = "Tainted data was used. The data came from [here](3).";
|
||||
const results = parseSarifPlainTextMessage(message);
|
||||
expect(results).to.deep.equal([
|
||||
"Tainted data was used. The data came from ",
|
||||
@@ -15,7 +15,7 @@ describe('parsing sarif', () => {
|
||||
});
|
||||
|
||||
it('should be able to parse a complex message from the spec', async function() {
|
||||
const message = "Prohibited term used in [para\\[0\\]\\\\spans\\[2\\]](1)."
|
||||
const message = "Prohibited term used in [para\\[0\\]\\\\spans\\[2\\]](1).";
|
||||
const results = parseSarifPlainTextMessage(message);
|
||||
expect(results).to.deep.equal([
|
||||
"Prohibited term used in ",
|
||||
@@ -23,14 +23,14 @@ describe('parsing sarif', () => {
|
||||
]);
|
||||
});
|
||||
it('should be able to parse a broken complex message from the spec', async function() {
|
||||
const message = "Prohibited term used in [para\\[0\\]\\\\spans\\[2\\](1)."
|
||||
const message = "Prohibited term used in [para\\[0\\]\\\\spans\\[2\\](1).";
|
||||
const results = parseSarifPlainTextMessage(message);
|
||||
expect(results).to.deep.equal([
|
||||
"Prohibited term used in [para[0]\\spans[2](1)."
|
||||
]);
|
||||
});
|
||||
it('should be able to parse a message with extra escaping the spec', async function() {
|
||||
const message = "Tainted data was used. The data came from \\[here](3)."
|
||||
const message = "Tainted data was used. The data came from \\[here](3).";
|
||||
const results = parseSarifPlainTextMessage(message);
|
||||
expect(results).to.deep.equal([
|
||||
"Tainted data was used. The data came from [here](3)."
|
||||
|
||||
@@ -32,7 +32,7 @@ describe('webview uri conversion', function() {
|
||||
return {
|
||||
fileUriOnDisk,
|
||||
panel
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
it('should correctly round trip from filesystem to webview and back', function() {
|
||||
|
||||
@@ -11,25 +11,24 @@ type Suite = {
|
||||
};
|
||||
|
||||
/**
|
||||
* Run an integration test suite `suite` at most `tries` times, or
|
||||
* until it succeeds, whichever comes first.
|
||||
*
|
||||
* TODO: Presently there is no way to distinguish a legitimately
|
||||
* failed test run from the test runner being terminated by a signal.
|
||||
* If in the future there arises a way to distinguish these cases
|
||||
* (e.g. https://github.com/microsoft/vscode-test/pull/56) only retry
|
||||
* in the terminated-by-signal case.
|
||||
* Run an integration test suite `suite`, retrying if it segfaults, at
|
||||
* most `tries` times.
|
||||
*/
|
||||
async function runTestsWithRetry(suite: Suite, tries: number): Promise<void> {
|
||||
async function runTestsWithRetryOnSegfault(suite: Suite, tries: number): Promise<void> {
|
||||
for (let t = 0; t < tries; t++) {
|
||||
try {
|
||||
// Download and unzip VS Code if necessary, and run the integration test suite.
|
||||
await runTests(suite);
|
||||
return;
|
||||
} catch (err) {
|
||||
console.error(`Exception raised while running tests: ${err}`);
|
||||
if (t < tries - 1)
|
||||
console.log('Retrying...');
|
||||
if (err === 'SIGSEGV') {
|
||||
console.error('Test runner segfaulted.');
|
||||
if (t < tries - 1)
|
||||
console.error('Retrying...');
|
||||
}
|
||||
else {
|
||||
throw err;
|
||||
}
|
||||
}
|
||||
}
|
||||
console.error(`Tried running suite ${tries} time(s), still failed, giving up.`);
|
||||
@@ -67,7 +66,7 @@ async function main() {
|
||||
];
|
||||
|
||||
for (const integrationTestSuite of integrationTestSuites) {
|
||||
await runTestsWithRetry(integrationTestSuite, 3);
|
||||
await runTestsWithRetryOnSegfault(integrationTestSuite, 3);
|
||||
}
|
||||
} catch (err) {
|
||||
console.error(`Unexpected exception while running tests: ${err}`);
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
predicate foo() {
|
||||
1 == 1
|
||||
}
|
||||
1 = 1
|
||||
}
|
||||
|
||||
101
extensions/ql-vscode/test/pure-tests/command-lint.test.ts
Normal file
@@ -0,0 +1,101 @@
|
||||
import { expect } from 'chai';
|
||||
import * as path from 'path';
|
||||
import * as fs from 'fs-extra';
|
||||
|
||||
type CmdDecl = {
|
||||
command: string;
|
||||
when?: string;
|
||||
title?: string;
|
||||
}
|
||||
|
||||
describe('commands declared in package.json', function() {
|
||||
const manifest = fs.readJsonSync(path.join(__dirname, '../../package.json'));
|
||||
const commands = manifest.contributes.commands;
|
||||
const menus = manifest.contributes.menus;
|
||||
|
||||
const disabledInPalette: Set<string> = new Set<string>();
|
||||
|
||||
// These commands should appear in the command palette, and so
|
||||
// should be prefixed with 'CodeQL: '.
|
||||
const paletteCmds: Set<string> = new Set<string>();
|
||||
|
||||
// These commands arising on context menus in non-CodeQL controlled
|
||||
// panels, (e.g. file browser) and so should be prefixed with 'CodeQL: '.
|
||||
const contribContextMenuCmds: Set<string> = new Set<string>();
|
||||
|
||||
// These are commands used in CodeQL controlled panels, and so don't need any prefixing in their title.
|
||||
const scopedCmds: Set<string> = new Set<string>();
|
||||
const commandTitles: { [cmd: string]: string } = {};
|
||||
|
||||
commands.forEach((commandDecl: CmdDecl) => {
|
||||
const { command, title } = commandDecl;
|
||||
if (command.match(/^codeQL\./)
|
||||
|| command.match(/^codeQLQueryResults\./)
|
||||
|| command.match(/^codeQLTests\./)) {
|
||||
paletteCmds.add(command);
|
||||
expect(title).not.to.be.undefined;
|
||||
commandTitles[command] = title!;
|
||||
}
|
||||
else if (command.match(/^codeQLDatabases\./)
|
||||
|| command.match(/^codeQLQueryHistory\./)) {
|
||||
scopedCmds.add(command);
|
||||
expect(title).not.to.be.undefined;
|
||||
commandTitles[command] = title!;
|
||||
}
|
||||
else {
|
||||
expect.fail(`Unexpected command name ${command}`);
|
||||
}
|
||||
});
|
||||
|
||||
menus['explorer/context'].forEach((commandDecl: CmdDecl) => {
|
||||
const { command } = commandDecl;
|
||||
paletteCmds.delete(command);
|
||||
contribContextMenuCmds.add(command);
|
||||
});
|
||||
|
||||
menus['editor/context'].forEach((commandDecl: CmdDecl) => {
|
||||
const { command } = commandDecl;
|
||||
paletteCmds.delete(command);
|
||||
contribContextMenuCmds.add(command);
|
||||
});
|
||||
|
||||
menus.commandPalette.forEach((commandDecl: CmdDecl) => {
|
||||
if (commandDecl.when === 'false')
|
||||
disabledInPalette.add(commandDecl.command);
|
||||
});
|
||||
|
||||
|
||||
|
||||
it('should have commands appropriately prefixed', function() {
|
||||
paletteCmds.forEach(command => {
|
||||
expect(commandTitles[command], `command ${command} should be prefixed with 'CodeQL: ', since it is accessible from the command palette`).to.match(/^CodeQL: /);
|
||||
});
|
||||
|
||||
contribContextMenuCmds.forEach(command => {
|
||||
expect(commandTitles[command], `command ${command} should be prefixed with 'CodeQL: ', since it is accessible from a context menu in a non-extension-controlled context`).to.match(/^CodeQL: /);
|
||||
});
|
||||
|
||||
scopedCmds.forEach(command => {
|
||||
expect(commandTitles[command], `command ${command} should not be prefixed with 'CodeQL: ', since it is accessible from an extension-controlled context`).not.to.match(/^CodeQL: /);
|
||||
});
|
||||
});
|
||||
|
||||
it('should have the right commands accessible from the command palette', function() {
|
||||
paletteCmds.forEach(command => {
|
||||
expect(disabledInPalette.has(command), `command ${command} should be enabled in the command palette`).to.be.false;
|
||||
});
|
||||
|
||||
// Commands in contribContextMenuCmds may reasonbly be enabled or
|
||||
// disabled in the command palette; for example, codeQL.runQuery
|
||||
// is available there, since we heuristically figure out which
|
||||
// query to run, but codeQL.setCurrentDatabase is not.
|
||||
|
||||
scopedCmds.forEach(command => {
|
||||
expect(disabledInPalette.has(command), `command ${command} should be disabled in the command palette`).to.be.true;
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
});
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { expect } from 'chai';
|
||||
import 'mocha';
|
||||
import { LocationStyle, StringLocation, tryGetWholeFileLocation } from 'semmle-bqrs';
|
||||
import { LocationStyle, StringLocation, tryGetResolvableLocation } from 'semmle-bqrs';
|
||||
|
||||
describe('processing string locations', function () {
|
||||
it('should detect Windows whole-file locations', function () {
|
||||
@@ -8,7 +8,7 @@ describe('processing string locations', function () {
|
||||
t: LocationStyle.String,
|
||||
loc: 'file://C:/path/to/file.ext:0:0:0:0'
|
||||
};
|
||||
const wholeFileLoc = tryGetWholeFileLocation(loc);
|
||||
const wholeFileLoc = tryGetResolvableLocation(loc);
|
||||
expect(wholeFileLoc).to.eql({t: LocationStyle.WholeFile, file: 'C:/path/to/file.ext'});
|
||||
});
|
||||
it('should detect Unix whole-file locations', function () {
|
||||
@@ -16,12 +16,27 @@ describe('processing string locations', function () {
|
||||
t: LocationStyle.String,
|
||||
loc: 'file:///path/to/file.ext:0:0:0:0'
|
||||
};
|
||||
const wholeFileLoc = tryGetWholeFileLocation(loc);
|
||||
const wholeFileLoc = tryGetResolvableLocation(loc);
|
||||
expect(wholeFileLoc).to.eql({t: LocationStyle.WholeFile, file: '/path/to/file.ext'});
|
||||
});
|
||||
it('should detect Unix 5-part locations', function () {
|
||||
const loc: StringLocation = {
|
||||
t: LocationStyle.String,
|
||||
loc: 'file:///path/to/file.ext:1:2:3:4'
|
||||
};
|
||||
const wholeFileLoc = tryGetResolvableLocation(loc);
|
||||
expect(wholeFileLoc).to.eql({
|
||||
t: LocationStyle.FivePart,
|
||||
file: '/path/to/file.ext',
|
||||
lineStart: 1,
|
||||
colStart: 2,
|
||||
lineEnd: 3,
|
||||
colEnd: 4
|
||||
});
|
||||
});
|
||||
it('should ignore other string locations', function () {
|
||||
for (const loc of ['file:///path/to/file.ext', 'I am not a location']) {
|
||||
const wholeFileLoc = tryGetWholeFileLocation({
|
||||
const wholeFileLoc = tryGetResolvableLocation({
|
||||
t: LocationStyle.String,
|
||||
loc: loc
|
||||
});
|
||||
|
||||
@@ -48,18 +48,7 @@ describe('OutputChannelLogger tests', () => {
|
||||
});
|
||||
|
||||
it('should create a side log in the workspace area', async () => {
|
||||
await sideLogTest('storagePath', 'globalStoragePath');
|
||||
});
|
||||
|
||||
it('should create a side log in the global area', async () => {
|
||||
await sideLogTest('globalStoragePath', 'storagePath');
|
||||
});
|
||||
|
||||
async function sideLogTest(expectedArea: string, otherArea: string): Promise<void> {
|
||||
logger.init({
|
||||
[expectedArea]: tempFolders[expectedArea].name,
|
||||
[otherArea]: undefined
|
||||
});
|
||||
logger.init(tempFolders.storagePath.name);
|
||||
|
||||
await logger.log('xxx', { additionalLogLocation: 'first' });
|
||||
await logger.log('yyy', { additionalLogLocation: 'second' });
|
||||
@@ -67,19 +56,16 @@ describe('OutputChannelLogger tests', () => {
|
||||
await logger.log('aaa');
|
||||
|
||||
// expect 2 side logs
|
||||
const testLoggerFolder = path.join(tempFolders[expectedArea].name, 'test-logger');
|
||||
const testLoggerFolder = path.join(tempFolders.storagePath.name, 'test-logger');
|
||||
expect(fs.readdirSync(testLoggerFolder).length).to.equal(2);
|
||||
expect(fs.readdirSync(tempFolders[otherArea].name).length).to.equal(0);
|
||||
|
||||
// contents
|
||||
expect(fs.readFileSync(path.join(testLoggerFolder, 'first'), 'utf8')).to.equal('xxx\nzzz');
|
||||
expect(fs.readFileSync(path.join(testLoggerFolder, 'second'), 'utf8')).to.equal('yyy\n');
|
||||
}
|
||||
});
|
||||
|
||||
it('should delete side logs on dispose', async () => {
|
||||
logger.init({
|
||||
storagePath: tempFolders.storagePath.name
|
||||
});
|
||||
logger.init(tempFolders.storagePath.name);
|
||||
await logger.log('xxx', { additionalLogLocation: 'first' });
|
||||
await logger.log('yyy', { additionalLogLocation: 'second' });
|
||||
|
||||
@@ -94,9 +80,7 @@ describe('OutputChannelLogger tests', () => {
|
||||
});
|
||||
|
||||
it('should remove an additional log location', async () => {
|
||||
logger.init({
|
||||
storagePath: tempFolders.storagePath.name
|
||||
});
|
||||
logger.init(tempFolders.storagePath.name);
|
||||
await logger.log('xxx', { additionalLogLocation: 'first' });
|
||||
await logger.log('yyy', { additionalLogLocation: 'second' });
|
||||
|
||||
@@ -112,9 +96,7 @@ describe('OutputChannelLogger tests', () => {
|
||||
|
||||
it('should delete an existing folder on init', async () => {
|
||||
fs.createFileSync(path.join(tempFolders.storagePath.name, 'test-logger', 'xxx'));
|
||||
logger.init({
|
||||
storagePath: tempFolders.storagePath.name
|
||||
});
|
||||
logger.init(tempFolders.storagePath.name);
|
||||
// should be empty dir
|
||||
|
||||
const testLoggerFolder = path.join(tempFolders.storagePath.name, 'test-logger');
|
||||
|
||||
@@ -33,7 +33,7 @@ class Checkpoint<T> {
|
||||
constructor() {
|
||||
this.res = () => { /**/ };
|
||||
this.rej = () => { /**/ };
|
||||
this.promise = new Promise((res, rej) => { this.res = res; this.rej = rej; })
|
||||
this.promise = new Promise((res, rej) => { this.res = res; this.rej = rej; });
|
||||
}
|
||||
|
||||
async done(): Promise<T> {
|
||||
@@ -114,7 +114,7 @@ describe('using the query server', function() {
|
||||
async getCodeQlPathWithoutVersionCheck(): Promise<string | undefined> {
|
||||
return codeQlPath;
|
||||
},
|
||||
}, logger)
|
||||
}, logger);
|
||||
qs = new qsClient.QueryServerClient(
|
||||
{
|
||||
codeQlPath,
|
||||
@@ -187,7 +187,7 @@ describe('using the query server', function() {
|
||||
const db: messages.Dataset = {
|
||||
dbDir: path.join(__dirname, '../test-db'),
|
||||
workingSet: 'default',
|
||||
}
|
||||
};
|
||||
const params: messages.EvaluateQueriesParams = {
|
||||
db,
|
||||
evaluateId: callbackId,
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { LocationStyle } from './bqrs-schema';
|
||||
import { LocationStyle } from "./bqrs-schema";
|
||||
|
||||
// See https://help.semmle.com/QL/learn-ql/ql/locations.html for how these are used.
|
||||
export interface FivePartLocation {
|
||||
@@ -31,54 +31,69 @@ export type LocationValue = RawLocationValue | WholeFileLocation;
|
||||
/** A location that may be resolved to a source code element. */
|
||||
export type ResolvableLocationValue = FivePartLocation | WholeFileLocation;
|
||||
|
||||
|
||||
/**
|
||||
* The CodeQL filesystem libraries use this pattern in `getURL()` predicates
|
||||
* to describe the location of an entire filesystem resource.
|
||||
* Such locations appear as `StringLocation`s instead of `FivePartLocation`s.
|
||||
*
|
||||
*
|
||||
* Folder resources also get similar URLs, but with the `folder` scheme.
|
||||
* They are deliberately ignored here, since there is no suitable location to show the user.
|
||||
*/
|
||||
const WHOLE_FILE_LOCATION_REGEX = /file:\/\/(.+):0:0:0:0/;
|
||||
|
||||
const FILE_LOCATION_REGEX = /file:\/\/(.+):([0-9]+):([0-9]+):([0-9]+):([0-9]+)/;
|
||||
/**
|
||||
* Gets a resolvable source file location for the specified `LocationValue`, if possible.
|
||||
* @param loc The location to test.
|
||||
*/
|
||||
export function tryGetResolvableLocation(loc: LocationValue | undefined): ResolvableLocationValue | undefined {
|
||||
export function tryGetResolvableLocation(
|
||||
loc: LocationValue | undefined
|
||||
): ResolvableLocationValue | undefined {
|
||||
if (loc === undefined) {
|
||||
return undefined;
|
||||
}
|
||||
else if ((loc.t === LocationStyle.FivePart) && loc.file) {
|
||||
} else if (loc.t === LocationStyle.FivePart && loc.file) {
|
||||
return loc;
|
||||
}
|
||||
else if ((loc.t === LocationStyle.WholeFile) && loc.file) {
|
||||
} else if (loc.t === LocationStyle.WholeFile && loc.file) {
|
||||
return loc;
|
||||
}
|
||||
else if ((loc.t === LocationStyle.String) && loc.loc) {
|
||||
return tryGetWholeFileLocation(loc);
|
||||
}
|
||||
else {
|
||||
} else if (loc.t === LocationStyle.String && loc.loc) {
|
||||
return tryGetLocationFromString(loc);
|
||||
} else {
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
|
||||
export function tryGetWholeFileLocation(loc: StringLocation): WholeFileLocation | undefined {
|
||||
const matches = WHOLE_FILE_LOCATION_REGEX.exec(loc.loc);
|
||||
export function tryGetLocationFromString(
|
||||
loc: StringLocation
|
||||
): ResolvableLocationValue | undefined {
|
||||
const matches = FILE_LOCATION_REGEX.exec(loc.loc);
|
||||
if (matches && matches.length > 1 && matches[1]) {
|
||||
// Whole-file location.
|
||||
// We could represent this as a FivePartLocation with all numeric fields set to zero,
|
||||
// but that would be a deliberate misuse as those fields are intended to be 1-based.
|
||||
return {
|
||||
t: LocationStyle.WholeFile,
|
||||
file: matches[1]
|
||||
};
|
||||
if (isWholeFileMatch(matches)) {
|
||||
return {
|
||||
t: LocationStyle.WholeFile,
|
||||
file: matches[1],
|
||||
};
|
||||
} else {
|
||||
return {
|
||||
t: LocationStyle.FivePart,
|
||||
file: matches[1],
|
||||
lineStart: Number(matches[2]),
|
||||
colStart: Number(matches[3]),
|
||||
lineEnd: Number(matches[4]),
|
||||
colEnd: Number(matches[5]),
|
||||
}
|
||||
}
|
||||
} else {
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
|
||||
function isWholeFileMatch(matches: RegExpExecArray): boolean {
|
||||
return (
|
||||
matches[2] === "0" &&
|
||||
matches[3] === "0" &&
|
||||
matches[4] === "0" &&
|
||||
matches[5] === "0"
|
||||
);
|
||||
}
|
||||
|
||||
export interface ElementBase {
|
||||
id: PrimitiveColumnValue;
|
||||
label?: string;
|
||||
@@ -93,8 +108,7 @@ export interface ElementWithLocation extends ElementBase {
|
||||
location: LocationValue;
|
||||
}
|
||||
|
||||
export interface Element extends Required<ElementBase> {
|
||||
}
|
||||
export interface Element extends Required<ElementBase> {}
|
||||
|
||||
export type PrimitiveColumnValue = string | boolean | number | Date;
|
||||
export type ColumnValue = PrimitiveColumnValue | ElementBase;
|
||||
|
||||
@@ -9,7 +9,8 @@
|
||||
"pnpmOptions": {
|
||||
"strictPeerDependencies": true
|
||||
},
|
||||
"nodeSupportedVersionRange": ">=10.13.0 <13.0.0",
|
||||
"nodeSupportedVersionRange": ">=10.13.0 <15.0.0",
|
||||
"suppressNodeLtsWarning": true,
|
||||
"ensureConsistentVersions": true,
|
||||
"projectFolderMinDepth": 2,
|
||||
"projectFolderMaxDepth": 2,
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
{
|
||||
"newLineCharacter": "\n",
|
||||
"convertTabsToSpaces": true,
|
||||
"indentStyle": 2,
|
||||
"insertSpaceAfterCommaDelimiter": true,
|
||||
"insertSpaceAfterSemicolonInForStatements": true,
|
||||
|
||||