Skip to content

Commit f11daaf

Browse files
committed
Refactored interpretBqrs
1 parent 58a2f21 commit f11daaf

1 file changed

Lines changed: 13 additions & 19 deletions

File tree

  • extensions/ql-vscode/src

extensions/ql-vscode/src/cli.ts

Lines changed: 13 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import { assertNever } from './pure/helpers-pure';
2020
import { QueryMetadata, SortDirection } from './pure/interface-types';
2121
import { Logger, ProgressReporter } from './logging';
2222
import { CompilationMessage } from './pure/messages';
23+
import Chain = require('stream-chain');
2324

2425
/**
2526
* The version of the SARIF format that we are using.
@@ -672,29 +673,22 @@ export class CodeQLCliServer implements Disposable {
672673

673674
async interpretBqrs(metadata: QueryMetadata, resultsPath: string, interpretedResultsPath: string, sourceInfo?: SourceInfo): Promise<sarif.Log> {
674675
await this.runInterpretCommand(SARIF_FORMAT, metadata, resultsPath, interpretedResultsPath, sourceInfo);
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));
676+
let pipeline: Chain;
677+
683678
try {
684-
// output = fs.createReadStream('/Users/marcjaramillo/MLH/vscode-codeql-starter/jdk11-tainted-path.sarif').pipe(parsedSarif);
679+
pipeline = chain([
680+
fs.createReadStream(interpretedResultsPath),
681+
new Parser()
682+
]);
685683
} catch (e) {
686-
const rawMessage = e.stderr || e.message;
687-
const errorMessage = rawMessage.startsWith('Cannot create a string')
688-
? `SARIF too large. ${rawMessage}`
689-
: rawMessage;
690-
throw new Error(`Reading output of interpretation failed: ${errorMessage}`);
684+
throw new Error('Reading output of interpretation failed.');
691685
}
686+
692687
try {
693-
// output.on('data', data => {
694-
// console.log(data);
695-
// });
696-
// output.on('end', () => { console.log('done'); });
697-
return {} as unknown as sarif.Log;
688+
const asm = Assembler.connectTo(pipeline);
689+
asm.on('done', (asm) => asm.current);
690+
// need to return asm.current in place of {}
691+
return {} as sarif.Log;
698692
} catch (err) {
699693
throw new Error(`Parsing output of interpretation failed: ${err.stderr || err}`);
700694
}

0 commit comments

Comments
 (0)