@@ -8,6 +8,7 @@ import * as fs from "fs"
8
8
import * as os from "os" ;
9
9
import CxBFL from "../bfl/CxBFL" ;
10
10
import path = require( 'path' ) ;
11
+ import { getTrimmedMapValue } from "./utils" ;
11
12
12
13
type ParamTypeMap = Map < CxParamType , string > ;
13
14
@@ -56,6 +57,7 @@ export class CxWrapper {
56
57
}
57
58
}
58
59
60
+
59
61
initializeCommands ( formatRequired : boolean ) : string [ ] {
60
62
const list : string [ ] = [ ] ;
61
63
if ( this . config . clientId ) {
@@ -353,30 +355,38 @@ export class CxWrapper {
353
355
return exec . executeCommands ( this . config . pathToExecutable , commands ) ;
354
356
}
355
357
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 ) ) ;
363
361
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 ) ;
371
364
365
+ const value = getTrimmedMapValue ( output , CxConstants . IDE_SCANS_KEY ) ;
366
+ return value ?. toLowerCase ( ) === "true" ;
367
+ }
372
368
373
- async aiMcpServerEnabled ( ) : Promise < boolean > {
369
+ async guidedRemediationEnabled ( ) : Promise < boolean > {
374
370
const commands : string [ ] = [ CxConstants . CMD_UTILS , CxConstants . SUB_CMD_TENANT ] ;
375
371
commands . push ( ...this . initializeCommands ( false ) ) ;
372
+
376
373
const exec = new ExecutionService ( ) ;
377
374
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" ;
380
390
}
381
391
382
392
async kicsChat ( apikey : string , file : string , line : number , severity : string , vulnerability : string , input : string , conversationId ?: string , model ?: string ) : Promise < CxCommandOutput > {
0 commit comments