@@ -8,6 +8,7 @@ import * as fs from "fs"
88import * as os from "os" ;
99import CxBFL from "../bfl/CxBFL" ;
1010import path = require( 'path' ) ;
11+ import { getTrimmedMapValue } from "./utils" ;
1112
1213type ParamTypeMap = Map < CxParamType , string > ;
1314
@@ -56,6 +57,7 @@ export class CxWrapper {
5657 }
5758 }
5859
60+
5961 initializeCommands ( formatRequired : boolean ) : string [ ] {
6062 const list : string [ ] = [ ] ;
6163 if ( this . config . clientId ) {
@@ -353,30 +355,38 @@ export class CxWrapper {
353355 return exec . executeCommands ( this . config . pathToExecutable , commands ) ;
354356 }
355357
356- async ideScansEnabled ( ) : Promise < boolean > {
357- const commands : string [ ] = [ CxConstants . CMD_UTILS , CxConstants . SUB_CMD_TENANT ] ;
358- commands . push ( ...this . initializeCommands ( false ) ) ;
359- const exec = new ExecutionService ( ) ;
360- const output = await exec . executeMapTenantOutputCommands ( this . config . pathToExecutable , commands ) ;
361- return output . has ( CxConstants . IDE_SCANS_KEY ) && output . get ( CxConstants . IDE_SCANS_KEY ) . toLowerCase ( ) === " true" ;
362- }
358+ async ideScansEnabled ( ) : Promise < boolean > {
359+ const commands : string [ ] = [ CxConstants . CMD_UTILS , CxConstants . SUB_CMD_TENANT ] ;
360+ commands . push ( ...this . initializeCommands ( false ) ) ;
363361
364- async guidedRemediationEnabled ( ) : Promise < boolean > {
365- const commands : string [ ] = [ CxConstants . CMD_UTILS , CxConstants . SUB_CMD_TENANT ] ;
366- commands . push ( ...this . initializeCommands ( false ) ) ;
367- const exec = new ExecutionService ( ) ;
368- const output = await exec . executeMapTenantOutputCommands ( this . config . pathToExecutable , commands ) ;
369- return output . has ( CxConstants . AI_GUIDED_REMEDIATION_KEY ) && output . get ( CxConstants . AI_GUIDED_REMEDIATION_KEY ) . toLowerCase ( ) === " true" ;
370- }
362+ const exec = new ExecutionService ( ) ;
363+ const output = await exec . executeMapTenantOutputCommands ( this . config . pathToExecutable , commands ) ;
371364
365+ const value = getTrimmedMapValue ( output , CxConstants . IDE_SCANS_KEY ) ;
366+ return value ?. toLowerCase ( ) === "true" ;
367+ }
372368
373- async aiMcpServerEnabled ( ) : Promise < boolean > {
369+ async guidedRemediationEnabled ( ) : Promise < boolean > {
374370 const commands : string [ ] = [ CxConstants . CMD_UTILS , CxConstants . SUB_CMD_TENANT ] ;
375371 commands . push ( ...this . initializeCommands ( false ) ) ;
372+
376373 const exec = new ExecutionService ( ) ;
377374 const output = await exec . executeMapTenantOutputCommands ( this . config . pathToExecutable , commands ) ;
378- return output . has ( CxConstants . AI_MCP_SERVER_KEY ) &&
379- output . get ( CxConstants . AI_MCP_SERVER_KEY ) . toLowerCase ( ) === "true" ;
375+
376+ const value = getTrimmedMapValue ( output , CxConstants . AI_GUIDED_REMEDIATION_KEY ) ;
377+ return value ?. toLowerCase ( ) === "true" ;
378+ }
379+
380+
381+ async aiMcpServerEnabled ( ) : Promise < boolean > {
382+ const commands : string [ ] = [ CxConstants . CMD_UTILS , CxConstants . SUB_CMD_TENANT ] ;
383+ commands . push ( ...this . initializeCommands ( false ) ) ;
384+
385+ const exec = new ExecutionService ( ) ;
386+ const output = await exec . executeMapTenantOutputCommands ( this . config . pathToExecutable , commands ) ;
387+
388+ const value = getTrimmedMapValue ( output , CxConstants . AI_MCP_SERVER_KEY ) ;
389+ return value ?. toLowerCase ( ) === "true" ;
380390}
381391
382392 async kicsChat ( apikey : string , file : string , line : number , severity : string , vulnerability : string , input : string , conversationId ?: string , model ?: string ) : Promise < CxCommandOutput > {
0 commit comments