11/* eslint-disable @typescript-eslint/camelcase */
22import * as cpp from 'child-process-promise' ;
33import * as child_process from 'child_process' ;
4- import * as fs from 'fs-extra' ;
54import * as path from 'path' ;
6- import * as sarif from 'sarif' ;
75import { SemVer } from 'semver' ;
86import { Readable } from 'stream' ;
97import { StringDecoder } from 'string_decoder' ;
@@ -12,19 +10,13 @@ import { promisify } from 'util';
1210import { CancellationToken , Disposable } from 'vscode' ;
1311
1412import { BQRSInfo , DecodedBqrsChunk } from './pure/bqrs-cli-types' ;
15- import * as config from './config' ;
1613import { CliConfig } from './config' ;
1714import { DistributionProvider , FindDistributionResultKind } from './distribution' ;
1815import { assertNever } from './pure/helpers-pure' ;
1916import { QueryMetadata , SortDirection } from './pure/interface-types' ;
2017import { Logger , ProgressReporter } from './logging' ;
2118import { CompilationMessage } from './pure/messages' ;
2219
23- /**
24- * The version of the SARIF format that we are using.
25- */
26- const SARIF_FORMAT = 'sarifv2.1.0' ;
27-
2820/**
2921 * Flags to pass to all cli commands.
3022 */
@@ -575,21 +567,13 @@ export class CodeQLCliServer implements Disposable {
575567 return await this . runJsonCodeQlCliCommand < DecodedBqrsChunk > ( [ 'bqrs' , 'decode' ] , subcommandArgs , 'Reading bqrs data' ) ;
576568 }
577569
578- async interpretBqrs ( metadata : { kind : string ; id : string ; scored ? : string } , resultsPath : string , interpretedResultsPath : string , sourceInfo ?: SourceInfo ) : Promise < sarif . Log > {
570+ async interpretBqrs ( metadata : { kind : string ; id : string } , format : string , additonalArgs : string [ ] , resultsPath : string , interpretedResultsPath : string , sourceInfo ?: SourceInfo ) : Promise < void > {
579571 const args = [
580572 `-t=kind=${ metadata . kind } ` ,
581573 `-t=id=${ metadata . id } ` ,
582574 '--output' , interpretedResultsPath ,
583- '--format' , SARIF_FORMAT ,
584- // TODO: This flag means that we don't group interpreted results
585- // by primary location. We may want to revisit whether we call
586- // interpretation with and without this flag, or do some
587- // grouping client-side.
588- '--no-group-results' ,
589- ] ;
590- if ( config . isCanary ( ) && metadata . scored !== undefined ) {
591- args . push ( `-t=scored=${ metadata . scored } ` ) ;
592- }
575+ '--format' , format ,
576+ ] . concat ( additonalArgs ) ;
593577 if ( sourceInfo !== undefined ) {
594578 args . push (
595579 '--source-archive' , sourceInfo . sourceArchive ,
@@ -598,18 +582,6 @@ export class CodeQLCliServer implements Disposable {
598582 }
599583 args . push ( resultsPath ) ;
600584 await this . runCodeQlCliCommand ( [ 'bqrs' , 'interpret' ] , args , 'Interpreting query results' ) ;
601-
602- let output : string ;
603- try {
604- output = await fs . readFile ( interpretedResultsPath , 'utf8' ) ;
605- } catch ( err ) {
606- throw new Error ( `Reading output of interpretation failed: ${ err . stderr || err } ` ) ;
607- }
608- try {
609- return JSON . parse ( output ) as sarif . Log ;
610- } catch ( err ) {
611- throw new Error ( `Parsing output of interpretation failed: ${ err . stderr || err } ` ) ;
612- }
613585 }
614586
615587
0 commit comments