Skip to content

Commit 58a2f21

Browse files
Continue work on streaming for SARIF files
1 parent 0ac223a commit 58a2f21

3 files changed

Lines changed: 20 additions & 25 deletions

File tree

extensions/ql-vscode/package-lock.json

Lines changed: 2 additions & 21 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: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -958,6 +958,7 @@
958958
},
959959
"dependencies": {
960960
"@octokit/rest": "^18.5.6",
961+
"@types/stream-chain": "^2.0.1",
961962
"@types/stream-json": "^1.7.1",
962963
"child-process-promise": "^2.2.1",
963964
"classnames": "~2.2.6",
@@ -970,6 +971,7 @@
970971
"react": "^16.8.6",
971972
"react-dom": "^16.8.6",
972973
"semver": "~7.3.2",
974+
"stream-chain": "^2.2.4",
973975
"stream-json": "^1.7.3",
974976
"tmp": "^0.1.0",
975977
"tmp-promise": "~3.0.2",

extensions/ql-vscode/src/cli.ts

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@ import * as cpp from 'child-process-promise';
22
import * as child_process from 'child_process';
33
import * as fs from 'fs-extra';
44
import * as path from 'path';
5+
import { chain } from 'stream-chain';
56
import { Parser } from 'stream-json';
7+
import Assembler = require('stream-json/Assembler');
68
import * as sarif from 'sarif';
79
import { SemVer } from 'semver';
810
import { Readable } from 'stream';
@@ -670,10 +672,16 @@ export class CodeQLCliServer implements Disposable {
670672

671673
async interpretBqrs(metadata: QueryMetadata, resultsPath: string, interpretedResultsPath: string, sourceInfo?: SourceInfo): Promise<sarif.Log> {
672674
await this.runInterpretCommand(SARIF_FORMAT, metadata, resultsPath, interpretedResultsPath, sourceInfo);
673-
const parsedSarif = new Parser();
674-
let output: Parser;
675+
676+
const pipeline = chain([
677+
fs.createReadStream(interpretedResultsPath),
678+
new Parser()
679+
]);
680+
681+
const asm = Assembler.connectTo(pipeline);
682+
asm.on('done', asm => console.log(asm.current));
675683
try {
676-
output = fs.createReadStream(interpretedResultsPath).pipe(parsedSarif);
684+
// output = fs.createReadStream('/Users/marcjaramillo/MLH/vscode-codeql-starter/jdk11-tainted-path.sarif').pipe(parsedSarif);
677685
} catch (e) {
678686
const rawMessage = e.stderr || e.message;
679687
const errorMessage = rawMessage.startsWith('Cannot create a string')
@@ -682,7 +690,11 @@ export class CodeQLCliServer implements Disposable {
682690
throw new Error(`Reading output of interpretation failed: ${errorMessage}`);
683691
}
684692
try {
685-
return output as unknown as sarif.Log;
693+
// output.on('data', data => {
694+
// console.log(data);
695+
// });
696+
// output.on('end', () => { console.log('done'); });
697+
return {} as unknown as sarif.Log;
686698
} catch (err) {
687699
throw new Error(`Parsing output of interpretation failed: ${err.stderr || err}`);
688700
}

0 commit comments

Comments
 (0)