@@ -6,6 +6,7 @@ import {CxCommandOutput} from "./CxCommandOutput";
66import { logger } from "./loggerConfig" ;
77import * as fs from "fs"
88import * as os from "os" ;
9+ import CxBFL from "../bfl/CxBFL" ;
910
1011type ParamTypeMap = Map < CxParamType , string > ;
1112
@@ -216,6 +217,46 @@ export class CxWrapper {
216217 return commands ;
217218 }
218219
220+ async getResultsBfl ( scanId : string , queryId : string , resultNodes : any [ ] ) {
221+ const commands : string [ ] = [ CxConstants . CMD_RESULT , CxConstants . SUB_CMD_BFL , CxConstants . SCAN_ID , scanId , CxConstants . QUERY_ID , queryId ] ;
222+ commands . push ( ...this . initializeCommands ( true ) ) ;
223+ const exec = new ExecutionService ( ) ;
224+ const response = await exec . executeCommands ( this . config . pathToExecutable , commands , CxConstants . BFL_TYPE ) ;
225+ const bflNodeIndex = this . getIndexOfBflNode ( response . payload , resultNodes )
226+ response . payload [ 0 ] = bflNodeIndex ;
227+ return response ;
228+ }
229+
230+ getIndexOfBflNode ( bflNodes : CxBFL [ ] , resultNodes : any [ ] ) : number {
231+
232+ let bflNodeNotFound = - 1 ;
233+ for ( const bflNode of bflNodes ) {
234+ for ( const resultNode of resultNodes ) {
235+
236+ if ( this . compareNodes ( bflNode , resultNode ) )
237+ {
238+ return resultNodes . indexOf ( resultNode ) ;
239+ }
240+ }
241+
242+ }
243+ return bflNodeNotFound ;
244+
245+ }
246+
247+ compareNodes ( bflNode : CxBFL , resultNode : any ) : boolean {
248+
249+ return bflNode . line == resultNode . line &&
250+ bflNode . column == resultNode . column &&
251+ bflNode . length == resultNode . length &&
252+ bflNode . name == resultNode . name &&
253+ bflNode . method == resultNode . method &&
254+ bflNode . domType == resultNode . domType &&
255+ bflNode . fileName == resultNode . fileName &&
256+ bflNode . fullName == resultNode . fullName &&
257+ bflNode . methodLine == resultNode . methodLine ;
258+ }
259+
219260 filterArguments ( filters :string ) :string [ ] {
220261 let r = [ ] ;
221262 if ( filters . length > 0 ) {
0 commit comments