|
1 | | -import * as child_process from 'child_process'; |
2 | 1 | import * as cpp from 'child-process-promise'; |
| 2 | +import * as child_process from 'child_process'; |
3 | 3 | import * as fs from 'fs-extra'; |
4 | 4 | import * as path from 'path'; |
5 | 5 | import * as sarif from 'sarif'; |
| 6 | +import { Readable } from 'stream'; |
| 7 | +import { StringDecoder } from 'string_decoder'; |
6 | 8 | import * as tk from 'tree-kill'; |
7 | 9 | import * as util from 'util'; |
8 | | -import { SortDirection, QueryMetadata } from './interface-types'; |
9 | | -import { Logger, ProgressReporter } from './logging'; |
10 | | -import { Disposable, CancellationToken } from 'vscode'; |
| 10 | +import { CancellationToken, Disposable } from 'vscode'; |
| 11 | +import { BQRSInfo, DecodedBqrsChunk } from "./bqrs-cli-types"; |
11 | 12 | import { DistributionProvider } from './distribution'; |
12 | 13 | import { assertNever } from './helpers-pure'; |
13 | | -import { Readable } from 'stream'; |
14 | | -import { StringDecoder } from 'string_decoder'; |
| 14 | +import { QueryMetadata, SortDirection } from './interface-types'; |
| 15 | +import { Logger, ProgressReporter } from './logging'; |
15 | 16 |
|
16 | 17 | /** |
17 | 18 | * The version of the SARIF format that we are using. |
@@ -471,6 +472,36 @@ export class CodeQLCliServer implements Disposable { |
471 | 472 | } |
472 | 473 | return await this.runJsonCodeQlCliCommand<string[]>(['resolve', 'ram'], args, "Resolving RAM settings", progressReporter); |
473 | 474 | } |
| 475 | + /** |
| 476 | + * Gets the headers (and optionally pagination info) of a bqrs. |
| 477 | + * @param config The configuration containing the path to the CLI. |
| 478 | + * @param bqrsPath The path to the vqrs. |
| 479 | + */ |
| 480 | + async bqrsInfo(bqrsPath: string, pageSize?: number): Promise<BQRSInfo> { |
| 481 | + const subcommandArgs = ( |
| 482 | + pageSize ? ["--paginate-rows", pageSize.toString()] : [] |
| 483 | + ).concat( |
| 484 | + bqrsPath |
| 485 | + ); |
| 486 | + return await this.runJsonCodeQlCliCommand<BQRSInfo>(['bqrs', 'info'], subcommandArgs, "Reading bqrs header"); |
| 487 | + } |
| 488 | + |
| 489 | + /** |
| 490 | + * Gets the results from a bqrs. |
| 491 | + * @param config The configuration containing the path to the CLI. |
| 492 | + * @param bqrsPath The path to the bqrs. |
| 493 | + */ |
| 494 | + async bqrsDecode(bqrsPath: string, resultSet: string, pageSize?: number, offset?: number): Promise<DecodedBqrsChunk> { |
| 495 | + const subcommandArgs = [ |
| 496 | + "--entities=url,string", |
| 497 | + "--result-set", resultSet, |
| 498 | + ].concat( |
| 499 | + pageSize ? ["--rows", pageSize.toString()] : [] |
| 500 | + ).concat( |
| 501 | + offset ? ["--start-at", offset.toString()] : [] |
| 502 | + ).concat([bqrsPath]); |
| 503 | + return await this.runJsonCodeQlCliCommand<DecodedBqrsChunk>(['bqrs', 'decode'], subcommandArgs, "Reading bqrs data"); |
| 504 | + } |
474 | 505 |
|
475 | 506 |
|
476 | 507 | async interpretBqrs(metadata: { kind: string, id: string }, resultsPath: string, interpretedResultsPath: string, sourceInfo?: SourceInfo): Promise<sarif.Log> { |
|
0 commit comments