@@ -25,6 +25,11 @@ import { CompilationMessage } from './pure/messages';
2525 */
2626const SARIF_FORMAT = 'sarifv2.1.0' ;
2727
28+ /**
29+ * The string used to specify CSV format.
30+ */
31+ const CSV_FORMAT = 'csv' ;
32+
2833/**
2934 * Flags to pass to all cli commands.
3035 */
@@ -582,18 +587,20 @@ export class CodeQLCliServer implements Disposable {
582587 return await this . runJsonCodeQlCliCommand < DecodedBqrsChunk > ( [ 'bqrs' , 'decode' ] , subcommandArgs , 'Reading bqrs data' ) ;
583588 }
584589
585- async interpretBqrs ( metadata : { kind : string ; id : string ; scored ?: string } , resultsPath : string , interpretedResultsPath : string , sourceInfo ?: SourceInfo ) : Promise < sarif . Log > {
590+ async runInterpretCommand ( format : string , metadata : QueryMetadata , resultsPath : string , interpretedResultsPath : string , sourceInfo ?: SourceInfo ) {
586591 const args = [
587592 `-t=kind=${ metadata . kind } ` ,
588593 `-t=id=${ metadata . id } ` ,
589594 '--output' , interpretedResultsPath ,
590- '--format' , SARIF_FORMAT ,
595+ '--format' , format ,
596+ ] ;
597+ if ( format == SARIF_FORMAT ) {
591598 // TODO: This flag means that we don't group interpreted results
592599 // by primary location. We may want to revisit whether we call
593600 // interpretation with and without this flag, or do some
594601 // grouping client-side.
595- '--no-group-results' ,
596- ] ;
602+ args . push ( '--no-group-results' ) ;
603+ }
597604 if ( config . isCanary ( ) && metadata . scored !== undefined ) {
598605 args . push ( `-t=scored=${ metadata . scored } ` ) ;
599606 }
@@ -611,6 +618,10 @@ export class CodeQLCliServer implements Disposable {
611618
612619 args . push ( resultsPath ) ;
613620 await this . runCodeQlCliCommand ( [ 'bqrs' , 'interpret' ] , args , 'Interpreting query results' ) ;
621+ }
622+
623+ async interpretBqrs ( metadata : QueryMetadata , resultsPath : string , interpretedResultsPath : string , sourceInfo ?: SourceInfo ) : Promise < sarif . Log > {
624+ await this . runInterpretCommand ( SARIF_FORMAT , metadata , resultsPath , interpretedResultsPath , sourceInfo ) ;
614625
615626 let output : string ;
616627 try {
@@ -629,6 +640,9 @@ export class CodeQLCliServer implements Disposable {
629640 }
630641 }
631642
643+ async generateResultsCsv ( metadata : QueryMetadata , resultsPath : string , csvPath : string , sourceInfo ?: SourceInfo ) : Promise < void > {
644+ await this . runInterpretCommand ( CSV_FORMAT , metadata , resultsPath , csvPath , sourceInfo ) ;
645+ }
632646
633647 async sortBqrs ( resultsPath : string , sortedResultsPath : string , resultSet : string , sortKeys : number [ ] , sortDirections : SortDirection [ ] ) : Promise < void > {
634648 const sortDirectionStrings = sortDirections . map ( direction => {
0 commit comments