Skip to content

Commit cdb9506

Browse files
committed
Merge branch 'main' into aeisenberg/graph-viewer
2 parents d1362bf + 94a311a commit cdb9506

82 files changed

Lines changed: 3622 additions & 697 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/main.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ jobs:
135135
strategy:
136136
matrix:
137137
os: [ubuntu-latest, windows-latest]
138-
version: ['v2.3.3', 'v2.4.6', 'v2.5.9', 'v2.6.3', 'v2.7.6', 'v2.8.0', 'nightly']
138+
version: ['v2.3.3', 'v2.4.6', 'v2.5.9', 'v2.6.3', 'v2.7.6', 'v2.8.1', 'nightly']
139139
env:
140140
CLI_VERSION: ${{ matrix.version }}
141141
NIGHTLY_URL: ${{ needs.find-nightly.outputs.url }}

extensions/ql-vscode/CHANGELOG.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,15 @@
22

33
## [UNRELEASED]
44

5+
- Fix a bug where database upgrades could not be resolved if some of the target pack's dependencies are outside of the workspace. [#1138](https://github.com/github/vscode-codeql/pull/1138)
6+
- Open the query server logs for query errors (instead of the extension log). This will make it easier to track down query errors. [#1158](https://github.com/github/vscode-codeql/pull/1158)
7+
- Fix a bug where queries took a long time to run if there are no folders in the workspace. [#1157](https://github.com/github/vscode-codeql/pull/1157)
8+
59
## 1.5.11 - 10 February 2022
610

711
- Fix a bug where invoking _View AST_ from the file explorer would not view the selected file. Instead it would view the active editor. Also, prevent the _View AST_ from appearing if the current selection includes a directory or multiple files. [#1113](https://github.com/github/vscode-codeql/pull/1113)
812
- Add query history items as soon as a query is run, including new icons for each history item. [#1094](https://github.com/github/vscode-codeql/pull/1094)
13+
- Save query history items across restarts. Items will be saved for 30 days and can be overwritten by setting the `codeQL.queryHistory.ttl` configuration setting. [#1130](https://github.com/github/vscode-codeql/pull/1130)
914
- Allow in-progress query items to be cancelled from the query history view. [#1105](https://github.com/github/vscode-codeql/pull/1105)
1015

1116
## 1.5.10 - 25 January 2022
@@ -32,7 +37,7 @@
3237
- Fix a bug with importing large databases. Databases over 4GB can now be imported directly from LGTM or from a zip file. This functionality is only available when using CodeQL CLI version 2.6.0 or later. [#971](https://github.com/github/vscode-codeql/pull/971)
3338
- Replace certain control codes (`U+0000` - `U+001F`) with their corresponding control labels (`U+2400` - `U+241F`) in the results view. [#963](https://github.com/github/vscode-codeql/pull/963)
3439
- Allow case-insensitive project slugs for GitHub repositories when adding a CodeQL database from LGTM. [#978](https://github.com/github/vscode-codeql/pull/961)
35-
- Add a _CodeQL: Preview Query Help_ command to generate Markdown previews of `.qhelp` query help files. This command should only be run in trusted workspaces. See https://codeql.github.com/docs/codeql-cli/testing-query-help-files for more information about query help. [#988](https://github.com/github/vscode-codeql/pull/988)
40+
- Add a _CodeQL: Preview Query Help_ command to generate Markdown previews of `.qhelp` query help files. This command should only be run in trusted workspaces. See [the CodeQL CLI docs](https://codeql.github.com/docs/codeql-cli/testing-query-help-files) for more information about query help. [#988](https://github.com/github/vscode-codeql/pull/988)
3641
- Make "Open Referenced File" command accessible from the active editor menu. [#989](https://github.com/github/vscode-codeql/pull/989)
3742
- Fix a bug where result set names in the result set drop-down were disappearing when viewing a sorted table. [#1007](https://github.com/github/vscode-codeql/pull/1007)
3843
- Allow query result locations with 0 as the end column value. These are treated as the first column in the line. [#1002](https://github.com/github/vscode-codeql/pull/1002)
Lines changed: 16 additions & 0 deletions
Loading

extensions/ql-vscode/package-lock.json

Lines changed: 7 additions & 35 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

extensions/ql-vscode/package.json

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,12 @@
225225
"default": "%q on %d - %s, %r result count [%t]",
226226
"markdownDescription": "Default string for how to label query history items.\n* %t is the time of the query\n* %q is the human-readable query name\n* %f is the query file name\n* %d is the database name\n* %r is the number of results\n* %s is a status string"
227227
},
228+
"codeQL.queryHistory.ttl": {
229+
"type": "number",
230+
"default": 30,
231+
"description": "Number of days to retain queries in the query history before being automatically deleted.",
232+
"scope": "machine"
233+
},
228234
"codeQL.runningTests.additionalTestArguments": {
229235
"scope": "window",
230236
"type": "array",
@@ -673,7 +679,7 @@
673679
{
674680
"command": "codeQLQueryHistory.removeHistoryItem",
675681
"group": "9_qlCommands",
676-
"when": "viewItem == interpretedResultsItem || viewItem == rawResultsItem || viewItem == cancelledResultsItem"
682+
"when": "viewItem == interpretedResultsItem || viewItem == rawResultsItem || viewItem == remoteResultsItem || viewItem == cancelledResultsItem"
677683
},
678684
{
679685
"command": "codeQLQueryHistory.setLabel",
@@ -1080,7 +1086,7 @@
10801086
"@types/jszip": "~3.1.6",
10811087
"@types/mocha": "^9.0.0",
10821088
"@types/nanoid": "^3.0.0",
1083-
"@types/node": "^12.14.1",
1089+
"@types/node": "^16.11.25",
10841090
"@types/node-fetch": "~2.5.2",
10851091
"@types/proxyquire": "~1.3.28",
10861092
"@types/react": "^17.0.2",

extensions/ql-vscode/src/additional-typings.d.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* The jszip and d3 libraries are designed to work in both the browser and
2+
* The d3 library is designed to work in both the browser and
33
* node. Consequently their typings files refer to both node
44
* types like `Buffer` (which don't exist in the browser), and browser
55
* types like `Blob` (which don't exist in node). Instead of sticking
@@ -8,7 +8,6 @@
88
* succeeds.
99
*/
1010

11-
declare type Blob = string;
1211
declare type RequestInit = Record<string, unknown>;
1312
declare type ElementTagNameMap = any;
1413
declare type NodeListOf<T> = Record<string, T>;

extensions/ql-vscode/src/cli.ts

Lines changed: 43 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -404,7 +404,7 @@ export class CodeQLCliServer implements Disposable {
404404
try {
405405
if (cancellationToken !== undefined) {
406406
cancellationRegistration = cancellationToken.onCancellationRequested(_e => {
407-
tk(child.pid);
407+
tk(child.pid || 0);
408408
});
409409
}
410410
if (logger !== undefined) {
@@ -515,8 +515,7 @@ export class CodeQLCliServer implements Disposable {
515515
async resolveLibraryPath(workspaces: string[], queryPath: string): Promise<QuerySetup> {
516516
const subcommandArgs = [
517517
'--query', queryPath,
518-
'--additional-packs',
519-
workspaces.join(path.delimiter)
518+
...this.getAdditionalPacksArg(workspaces)
520519
];
521520
return await this.runJsonCodeQlCliCommand<QuerySetup>(['resolve', 'library-path'], subcommandArgs, 'Resolving library paths');
522521
}
@@ -529,8 +528,7 @@ export class CodeQLCliServer implements Disposable {
529528
const subcommandArgs = [
530529
'--format', 'bylanguage',
531530
queryUri.fsPath,
532-
'--additional-packs',
533-
workspaces.join(path.delimiter)
531+
...this.getAdditionalPacksArg(workspaces)
534532
];
535533
return JSON.parse(await this.runCodeQlCliCommand(['resolve', 'queries'], subcommandArgs, 'Resolving query by language'));
536534
}
@@ -563,6 +561,17 @@ export class CodeQLCliServer implements Disposable {
563561
);
564562
}
565563

564+
/**
565+
* Issues an internal clear-cache command to the cli server. This
566+
* command is used to clear the qlpack cache of the server.
567+
*
568+
* This cache is generally cleared every 1s. This method is used
569+
* to force an early clearing of the cache.
570+
*/
571+
public async clearCache(): Promise<void> {
572+
await this.runCodeQlCliCommand(['clear-cache'], [], 'Clearing qlpack cache');
573+
}
574+
566575
/**
567576
* Runs QL tests.
568577
* @param testPaths Full paths of the tests to run.
@@ -574,7 +583,7 @@ export class CodeQLCliServer implements Disposable {
574583
): AsyncGenerator<TestCompleted, void, unknown> {
575584

576585
const subcommandArgs = this.cliConfig.additionalTestArguments.concat([
577-
'--additional-packs', workspaces.join(path.delimiter),
586+
...this.getAdditionalPacksArg(workspaces),
578587
'--threads',
579588
this.cliConfig.numberTestThreads.toString(),
580589
...testPaths
@@ -596,8 +605,12 @@ export class CodeQLCliServer implements Disposable {
596605

597606
/** Resolves the ML models that should be available when evaluating a query. */
598607
async resolveMlModels(additionalPacks: string[]): Promise<MlModelsInfo> {
599-
return await this.runJsonCodeQlCliCommand<MlModelsInfo>(['resolve', 'ml-models'], ['--additional-packs',
600-
additionalPacks.join(path.delimiter)], 'Resolving ML models', false);
608+
return await this.runJsonCodeQlCliCommand<MlModelsInfo>(
609+
['resolve', 'ml-models'],
610+
this.getAdditionalPacksArg(additionalPacks),
611+
'Resolving ML models',
612+
false
613+
);
601614
}
602615

603616
/**
@@ -725,9 +738,9 @@ export class CodeQLCliServer implements Disposable {
725738

726739
async interpretBqrsGraph(metadata: QueryMetadata, resultsPath: string, interpretedResultsPath: string, sourceInfo?: SourceInfo): Promise<string[]> {
727740
const additionalArgs = sourceInfo ? ['--dot-location-url-format', 'file://' + sourceInfo.sourceLocationPrefix + '{path}:{start:line}:{start:column}:{end:line}:{end:column}'] : [];
728-
741+
729742
await this.runInterpretCommand('dot', additionalArgs, metadata, resultsPath, interpretedResultsPath, sourceInfo);
730-
743+
731744
try {
732745
const dot = await this.readDotFiles(interpretedResultsPath);
733746
return dot;
@@ -783,7 +796,7 @@ export class CodeQLCliServer implements Disposable {
783796
* @returns A list of database upgrade script directories
784797
*/
785798
async resolveUpgrades(dbScheme: string, searchPath: string[], allowDowngradesIfPossible: boolean, targetDbScheme?: string): Promise<UpgradesInfo> {
786-
const args = ['--additional-packs', searchPath.join(path.delimiter), '--dbscheme', dbScheme];
799+
const args = [...this.getAdditionalPacksArg(searchPath), '--dbscheme', dbScheme];
787800
if (targetDbScheme) {
788801
args.push('--target-dbscheme', targetDbScheme);
789802
if (allowDowngradesIfPossible && await this.cliConstraints.supportsDowngrades()) {
@@ -805,7 +818,7 @@ export class CodeQLCliServer implements Disposable {
805818
* @returns A dictionary mapping qlpack name to the directory it comes from
806819
*/
807820
resolveQlpacks(additionalPacks: string[], searchPath?: string[]): Promise<QlpacksInfo> {
808-
const args = ['--additional-packs', additionalPacks.join(path.delimiter)];
821+
const args = this.getAdditionalPacksArg(additionalPacks);
809822
if (searchPath?.length) {
810823
args.push('--search-path', path.join(...searchPath));
811824
}
@@ -851,7 +864,7 @@ export class CodeQLCliServer implements Disposable {
851864
* @returns A list of query files found.
852865
*/
853866
async resolveQueriesInSuite(suite: string, additionalPacks: string[], searchPath?: string[]): Promise<string[]> {
854-
const args = ['--additional-packs', additionalPacks.join(path.delimiter)];
867+
const args = this.getAdditionalPacksArg(additionalPacks);
855868
if (searchPath !== undefined) {
856869
args.push('--search-path', path.join(...searchPath));
857870
}
@@ -884,8 +897,7 @@ export class CodeQLCliServer implements Disposable {
884897
'-o',
885898
outputPath,
886899
dir,
887-
'--additional-packs',
888-
workspaceFolders.join(path.delimiter)
900+
...this.getAdditionalPacksArg(workspaceFolders)
889901
];
890902
if (!precompile && await this.cliConstraints.supportsNoPrecompile()) {
891903
args.push('--no-precompile');
@@ -940,6 +952,12 @@ export class CodeQLCliServer implements Disposable {
940952
throw new Error('No distribution found');
941953
}
942954
}
955+
956+
private getAdditionalPacksArg(paths: string[]): string[] {
957+
return paths.length
958+
? ['--additional-packs', paths.join(path.delimiter)]
959+
: [];
960+
}
943961
}
944962

945963
/**
@@ -1226,6 +1244,12 @@ export class CliVersionConstraint {
12261244
*/
12271245
public static CLI_VERSION_WITH_PACKAGING = new SemVer('2.6.0');
12281246

1247+
/**
1248+
* CLI version where the `--evaluator-log` and related options to the query server were introduced,
1249+
* on a per-query server basis.
1250+
*/
1251+
public static CLI_VERSION_WITH_STRUCTURED_EVAL_LOG = new SemVer('2.8.2');
1252+
12291253
constructor(private readonly cli: CodeQLCliServer) {
12301254
/**/
12311255
}
@@ -1281,4 +1305,8 @@ export class CliVersionConstraint {
12811305
async supportsPackaging() {
12821306
return this.isVersionAtLeast(CliVersionConstraint.CLI_VERSION_WITH_PACKAGING);
12831307
}
1308+
1309+
async supportsStructuredEvalLog() {
1310+
return this.isVersionAtLeast(CliVersionConstraint.CLI_VERSION_WITH_STRUCTURED_EVAL_LOG);
1311+
}
12841312
}

extensions/ql-vscode/src/commandRunner.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,8 @@ export function commandRunner(
160160
export function commandRunnerWithProgress<R>(
161161
commandId: string,
162162
task: ProgressTask<R>,
163-
progressOptions: Partial<ProgressOptions>
163+
progressOptions: Partial<ProgressOptions>,
164+
outputLogger = logger
164165
): Disposable {
165166
return commands.registerCommand(commandId, async (...args: any[]) => {
166167
const startTime = Date.now();
@@ -177,16 +178,17 @@ export function commandRunnerWithProgress<R>(
177178
if (e instanceof UserCancellationException) {
178179
// User has cancelled this action manually
179180
if (e.silent) {
180-
void logger.log(errorMessage);
181+
void outputLogger.log(errorMessage);
181182
} else {
182-
void showAndLogWarningMessage(errorMessage);
183+
void showAndLogWarningMessage(errorMessage, { outputLogger });
183184
}
184185
} else {
185186
// Include the full stack in the error log only.
186187
const fullMessage = e.stack
187188
? `${errorMessage}\n${e.stack}`
188189
: errorMessage;
189190
void showAndLogErrorMessage(errorMessage, {
191+
outputLogger,
190192
fullMessage
191193
});
192194
}

0 commit comments

Comments
 (0)