11package com .checkmarx .ast .wrapper ;
22
3+ import com .checkmarx .ast .asca .ScanResult ;
34import com .checkmarx .ast .codebashing .CodeBashing ;
45import com .checkmarx .ast .kicsRealtimeResults .KicsRealtimeResults ;
56import com .checkmarx .ast .learnMore .LearnMore ;
1213import com .checkmarx .ast .results .result .Node ;
1314import com .checkmarx .ast .scan .Scan ;
1415import com .checkmarx .ast .tenant .TenantSetting ;
16+ import com .checkmarx .ast .utils .JsonParser ;
1517import com .fasterxml .jackson .databind .ObjectMapper ;
1618import com .fasterxml .jackson .databind .type .CollectionType ;
1719import com .fasterxml .jackson .databind .type .TypeFactory ;
@@ -216,6 +218,33 @@ public List<Project> projectList(String filter) throws IOException, InterruptedE
216218 return Execution .executeCommand (withConfigArguments (arguments ), logger , Project ::listFromLine );
217219 }
218220
221+ public ScanResult ScanAsca (String fileSource , boolean ascaLatestVersion , String agent ) throws IOException , InterruptedException , CxException {
222+ this .logger .info ("Fetching ASCA scanResult" );
223+
224+ List <String > arguments = new ArrayList <>();
225+ arguments .add (CxConstants .CMD_SCAN );
226+ arguments .add (CxConstants .SUB_CMD_ASCA );
227+ arguments .add (CxConstants .FILE_SOURCE );
228+ arguments .add (fileSource );
229+ if (ascaLatestVersion ) {
230+ arguments .add (CxConstants .ASCA_LATEST_VERSION );
231+ }
232+
233+ appendAgentToArguments (agent , arguments );
234+
235+ return Execution .executeCommand (withConfigArguments (arguments ), logger , ScanResult ::fromLine );
236+ }
237+
238+ private static void appendAgentToArguments (String agent , List <String > arguments ) {
239+ arguments .add (CxConstants .AGENT );
240+ if (agent != null && !agent .isEmpty ()){
241+ arguments .add (agent );
242+ }
243+ else {
244+ arguments .add ("CLI-Java-Wrapper" );
245+ }
246+ }
247+
219248 public List <String > projectBranches (@ NonNull UUID projectId , String filter )
220249 throws CxException , IOException , InterruptedException {
221250 this .logger .info ("Fetching the branches for project id {} using the filter: {}" , projectId , filter );
@@ -229,7 +258,7 @@ public List<String> projectBranches(@NonNull UUID projectId, String filter)
229258
230259 return Execution .executeCommand (withConfigArguments (arguments ),
231260 logger ,
232- line -> CxBaseObject .parse (line , BRANCHES_TYPE ));
261+ line -> JsonParser .parse (line , BRANCHES_TYPE ));
233262 }
234263
235264 public List <CodeBashing > codeBashingList (@ NonNull String cweId , @ NonNull String language , @ NonNull String queryName ) throws IOException , InterruptedException , CxException {
@@ -336,7 +365,7 @@ public KicsRealtimeResults kicsRealtimeScan(@NonNull String fileSources, String
336365 List <String > arguments = new ArrayList <>();
337366 arguments .add (CxConstants .CMD_SCAN );
338367 arguments .add (CxConstants .SUB_CMD_KICS_REALTIME );
339- arguments .add (CxConstants .FILE_SOURCES );
368+ arguments .add (CxConstants .FILE );
340369 arguments .add (fileSources );
341370 arguments .add (CxConstants .ADDITONAL_PARAMS );
342371 arguments .add (additionalParams );
0 commit comments