1- import { CxConfig } from "./CxConfig" ;
2- import { CxParamType } from "./CxParamType" ;
3- import { CxConstants } from "./CxConstants" ;
4- import { ExecutionService } from "./ExecutionService" ;
5- import { CxCommandOutput } from "./CxCommandOutput" ;
1+ import { CxConfig } from "./CxConfig" ;
2+ import { CxParamType } from "./CxParamType" ;
3+ import { CxConstants } from "./CxConstants" ;
4+ import { ExecutionService } from "./ExecutionService" ;
5+ import { CxCommandOutput } from "./CxCommandOutput" ;
66import { getLoggerWithFilePath , logger } from "./loggerConfig" ;
77import * as fs from "fs"
88import * as os from "os" ;
@@ -15,10 +15,10 @@ export class CxWrapper {
1515
1616 constructor ( cxScanConfig : CxConfig , logFilePath ?: string ) {
1717 let path = require ( "path" ) ;
18-
18+
1919 getLoggerWithFilePath ( logFilePath )
20-
21- if ( cxScanConfig . clientId && cxScanConfig . clientSecret ) {
20+
21+ if ( cxScanConfig . clientId && cxScanConfig . clientSecret ) {
2222 logger . info ( "Received clientId and clientSecret" ) ;
2323 this . config . clientId = cxScanConfig . clientId ;
2424 this . config . clientSecret = cxScanConfig . clientSecret ;
@@ -119,7 +119,7 @@ export class CxWrapper {
119119 const exec = new ExecutionService ( ) ;
120120 return await exec . executeCommands ( this . config . pathToExecutable , commands , CxConstants . SCAN_TYPE ) ;
121121 }
122-
122+
123123 async scanCancel ( id : string ) : Promise < CxCommandOutput > {
124124 const commands : string [ ] = [ CxConstants . CMD_SCAN , CxConstants . SUB_CMD_CANCEL , CxConstants . SCAN_ID , id ] ;
125125 commands . push ( ...this . initializeCommands ( false ) ) ;
@@ -134,15 +134,15 @@ export class CxWrapper {
134134 return await exec . executeCommands ( this . config . pathToExecutable , commands , CxConstants . SCAN_TYPE ) ;
135135 }
136136
137- async scanList ( filters :string ) : Promise < CxCommandOutput > {
137+ async scanList ( filters : string ) : Promise < CxCommandOutput > {
138138 const validated_filters = this . filterArguments ( filters ) ;
139139 const commands : string [ ] = [ CxConstants . CMD_SCAN , "list" ] . concat ( validated_filters ) ;
140140 commands . push ( ...this . initializeCommands ( true ) ) ;
141141 const exec = new ExecutionService ( ) ;
142142 return await exec . executeCommands ( this . config . pathToExecutable , commands , CxConstants . SCAN_TYPE ) ;
143143 }
144144
145- async projectList ( filters :string ) : Promise < CxCommandOutput > {
145+ async projectList ( filters : string ) : Promise < CxCommandOutput > {
146146 const validated_filters = this . filterArguments ( filters ) ;
147147 const commands : string [ ] = [ CxConstants . CMD_PROJECT , "list" ] . concat ( validated_filters ) ;
148148 commands . push ( ...this . initializeCommands ( true ) ) ;
@@ -153,32 +153,32 @@ export class CxWrapper {
153153 async projectBranches ( projectId : string , filters : string ) : Promise < CxCommandOutput > {
154154 // Verify and add possible branch filter by name
155155 const validated_filters = this . filterArguments ( CxConstants . BRANCH_NAME + filters )
156- const commands : string [ ] = [ CxConstants . CMD_PROJECT , CxConstants . SUB_CMD_BRANCHES , CxConstants . PROJECT_ID , projectId ] . concat ( validated_filters ) ;
156+ const commands : string [ ] = [ CxConstants . CMD_PROJECT , CxConstants . SUB_CMD_BRANCHES , CxConstants . PROJECT_ID , projectId ] . concat ( validated_filters ) ;
157157 commands . push ( ...this . initializeCommands ( false ) ) ;
158158 const exec = new ExecutionService ( ) ;
159159 return await exec . executeCommands ( this . config . pathToExecutable , commands ) ;
160160 }
161161
162162 async projectShow ( projectId : string ) : Promise < CxCommandOutput > {
163- const commands : string [ ] = [ CxConstants . CMD_PROJECT , CxConstants . SUB_CMD_SHOW , CxConstants . PROJECT_ID , projectId ] ;
163+ const commands : string [ ] = [ CxConstants . CMD_PROJECT , CxConstants . SUB_CMD_SHOW , CxConstants . PROJECT_ID , projectId ] ;
164164 commands . push ( ...this . initializeCommands ( true ) ) ;
165165 const exec = new ExecutionService ( ) ;
166166 return await exec . executeCommands ( this . config . pathToExecutable , commands , CxConstants . PROJECT_TYPE ) ;
167167 }
168168
169- async triageShow ( projectId : string , similarityId : string , scanType : string ) : Promise < CxCommandOutput > {
169+ async triageShow ( projectId : string , similarityId : string , scanType : string ) : Promise < CxCommandOutput > {
170170 const commands : string [ ] = [ CxConstants . CMD_TRIAGE , CxConstants . SUB_CMD_SHOW , CxConstants . PROJECT_ID , projectId , CxConstants . SIMILARITY_ID , similarityId , CxConstants . SCAN_TYPES_SUB_CMD , scanType ] ;
171171 commands . push ( ...this . initializeCommands ( true ) ) ;
172172 const exec = new ExecutionService ( ) ;
173173 return await exec . executeCommands ( this . config . pathToExecutable , commands , CxConstants . PREDICATE_TYPE ) ;
174- }
175-
174+ }
175+
176176 async triageUpdate ( projectId : string , similarityId : string , scanType : string , state : string , comment : string , severity : string ) : Promise < CxCommandOutput > {
177177 const commands : string [ ] = [ CxConstants . CMD_TRIAGE , CxConstants . SUB_CMD_UPDATE , CxConstants . PROJECT_ID , projectId , CxConstants . SIMILARITY_ID , similarityId , CxConstants . SCAN_TYPES_SUB_CMD , scanType , CxConstants . STATE , state , CxConstants . COMMENT , comment , CxConstants . SEVERITY , severity ] ;
178178 commands . push ( ...this . initializeCommands ( false ) ) ;
179179 const exec = new ExecutionService ( ) ;
180180 return await exec . executeCommands ( this . config . pathToExecutable , commands ) ;
181- }
181+ }
182182
183183 async getResultsList ( scanId : string ) {
184184 const exec = new ExecutionService ( ) ;
@@ -187,7 +187,7 @@ export class CxWrapper {
187187 // Executes the command and creates a result file
188188 await exec . executeResultsCommands ( this . config . pathToExecutable , commands )
189189 // Reads the result file and retrieves the results
190- return exec . executeResultsCommandsFile ( scanId , CxConstants . FORMAT_JSON , CxConstants . FORMAT_JSON_FILE , commands , this . config . pathToExecutable , fileName ) ;
190+ return exec . executeResultsCommandsFile ( scanId , CxConstants . FORMAT_JSON , CxConstants . FORMAT_JSON_FILE , commands , this . config . pathToExecutable , fileName ) ;
191191 }
192192
193193 async getResultsSummary ( scanId : string ) : Promise < CxCommandOutput > {
@@ -197,24 +197,24 @@ export class CxWrapper {
197197 // Executes the command and creates a result file
198198 await exec . executeResultsCommands ( this . config . pathToExecutable , commands ) ;
199199 // Reads the result file and retrieves the results
200- return exec . executeResultsCommandsFile ( scanId , CxConstants . FORMAT_HTML , CxConstants . FORMAT_HTML_FILE , commands , this . config . pathToExecutable , fileName ) ;
200+ return exec . executeResultsCommandsFile ( scanId , CxConstants . FORMAT_HTML , CxConstants . FORMAT_HTML_FILE , commands , this . config . pathToExecutable , fileName ) ;
201201 }
202202
203- async getResults ( scanId : string , resultType :string , outputFileName : string , outputFilePath : string ) {
203+ async getResults ( scanId : string , resultType : string , outputFileName : string , outputFilePath : string ) {
204204 const commands = this . resultsShow ( scanId , resultType , outputFileName , outputFilePath )
205205 const exec = new ExecutionService ( ) ;
206206 return await exec . executeCommands ( this . config . pathToExecutable , commands ) ;
207207 }
208208
209- async codeBashingList ( cweId :string , language :string , queryName :string ) : Promise < CxCommandOutput > {
210- const commands : string [ ] = [ CxConstants . CMD_RESULT , CxConstants . CMD_CODE_BASHING , CxConstants . LANGUAGE , language , CxConstants . VULNERABILITY_TYPE , queryName , CxConstants . CWE_ID , cweId ] ;
209+ async codeBashingList ( cweId : string , language : string , queryName : string ) : Promise < CxCommandOutput > {
210+ const commands : string [ ] = [ CxConstants . CMD_RESULT , CxConstants . CMD_CODE_BASHING , CxConstants . LANGUAGE , language , CxConstants . VULNERABILITY_TYPE , queryName , CxConstants . CWE_ID , cweId ] ;
211211 commands . push ( ...this . initializeCommands ( true ) ) ;
212212 const exec = new ExecutionService ( ) ;
213- return await exec . executeCommands ( this . config . pathToExecutable , commands , CxConstants . CODE_BASHING_TYPE ) ;
213+ return await exec . executeCommands ( this . config . pathToExecutable , commands , CxConstants . CODE_BASHING_TYPE ) ;
214214 }
215215
216216 resultsShow ( scanId : string , reportFormat : string , outputFileName : string , outputPath : string ) : string [ ] {
217- const commands : string [ ] = [ CxConstants . CMD_RESULT , CxConstants . SUB_CMD_SHOW , CxConstants . SCAN_ID , scanId , CxConstants . REPORT_FORMAT , reportFormat ] ;
217+ const commands : string [ ] = [ CxConstants . CMD_RESULT , CxConstants . SUB_CMD_SHOW , CxConstants . SCAN_ID , scanId , CxConstants . REPORT_FORMAT , reportFormat ] ;
218218 if ( outputFileName ) {
219219 commands . push ( CxConstants . OUTPUT_NAME ) ;
220220 commands . push ( outputFileName ) ;
@@ -243,8 +243,7 @@ export class CxWrapper {
243243 for ( const bflNode of bflNodes ) {
244244 for ( const resultNode of resultNodes ) {
245245
246- if ( this . compareNodes ( bflNode , resultNode ) )
247- {
246+ if ( this . compareNodes ( bflNode , resultNode ) ) {
248247 return resultNodes . indexOf ( resultNode ) ;
249248 }
250249 }
@@ -254,22 +253,22 @@ export class CxWrapper {
254253
255254 }
256255
257- compareNodes ( bflNode : CxBFL , resultNode : any ) : boolean {
256+ compareNodes ( bflNode : CxBFL , resultNode : any ) : boolean {
258257
259258 return bflNode . line == resultNode . line &&
260- bflNode . column == resultNode . column &&
261- bflNode . length == resultNode . length &&
262- bflNode . name == resultNode . name &&
263- bflNode . method == resultNode . method &&
264- bflNode . domType == resultNode . domType &&
265- bflNode . fileName == resultNode . fileName &&
266- bflNode . fullName == resultNode . fullName &&
267- bflNode . methodLine == resultNode . methodLine ;
259+ bflNode . column == resultNode . column &&
260+ bflNode . length == resultNode . length &&
261+ bflNode . name == resultNode . name &&
262+ bflNode . method == resultNode . method &&
263+ bflNode . domType == resultNode . domType &&
264+ bflNode . fileName == resultNode . fileName &&
265+ bflNode . fullName == resultNode . fullName &&
266+ bflNode . methodLine == resultNode . methodLine ;
268267 }
269268
270- filterArguments ( filters :string ) :string [ ] {
269+ filterArguments ( filters : string ) : string [ ] {
271270 let r = [ ] ;
272- if ( filters . length > 0 ) {
271+ if ( filters . length > 0 ) {
273272 r . push ( CxConstants . FILTER ) ;
274273 r . push ( filters ) ;
275274 }
0 commit comments