11package com .checkmarx .ast .wrapper ;
22
33import com .checkmarx .ast .codebashing .CodeBashing ;
4- import com .checkmarx .ast .kicsRealtimeResults .kicsRealtimeResults ;
4+ import com .checkmarx .ast .kicsRealtimeResults .KicsRealtimeResults ;
55import com .checkmarx .ast .predicate .Predicate ;
66import com .checkmarx .ast .project .Project ;
7+ import com .checkmarx .ast .remediation .KicsRemediation ;
78import com .checkmarx .ast .results .ReportFormat ;
89import com .checkmarx .ast .results .Results ;
910import com .checkmarx .ast .results .ResultsSummary ;
@@ -40,7 +41,6 @@ public CxWrapper(CxConfig cxConfig)
4041
4142 public CxWrapper (@ NonNull CxConfig cxConfig , @ NonNull Logger logger ) throws CxConfig .InvalidCLIConfigException ,
4243 IOException {
43- cxConfig .validate ();
4444 this .cxConfig = cxConfig ;
4545 this .logger = logger ;
4646 this .executable = StringUtils .isBlank (this .cxConfig .getPathToExecutable ())
@@ -319,7 +319,7 @@ public int getResultsBfl(@NonNull UUID scanId, @NonNull String queryId, List<Nod
319319
320320 }
321321
322- public kicsRealtimeResults kicsRealtimeScan (@ NonNull String fileSources ,String engine , String additionalParams )
322+ public KicsRealtimeResults kicsRealtimeScan (@ NonNull String fileSources , String engine , String additionalParams )
323323 throws IOException , InterruptedException , CxException {
324324 this .logger .info ("Executing 'scan kics-realtime' command using the CLI." );
325325 this .logger .info ("Fetching the results for fileSources {} and additionalParams {}" , fileSources , additionalParams );
@@ -331,14 +331,40 @@ public kicsRealtimeResults kicsRealtimeScan(@NonNull String fileSources,String e
331331 arguments .add (fileSources );
332332 arguments .add (CxConstants .ADDITONAL_PARAMS );
333333 arguments .add (additionalParams );
334- if (engine .length ()> 0 ) {
334+ if (engine .length () > 0 ) {
335335 arguments .add (CxConstants .ENGINE );
336336 arguments .add (engine );
337337 }
338- kicsRealtimeResults kicsResults = Execution .executeCommand (withConfigArguments (arguments ), logger , kicsRealtimeResults ::fromLine );
338+ KicsRealtimeResults kicsResults = Execution .executeCommand (withConfigArguments (arguments ), logger , KicsRealtimeResults ::fromLine );
339339 return kicsResults ;
340+ }
341+
342+ public KicsRemediation kicsRemediate (@ NonNull String resultsFile , String kicsFile , String engine ,String similarityIds )
343+ throws IOException , InterruptedException , CxException {
344+ this .logger .info ("Executing 'remediation kics' command using the CLI." );
345+ this .logger .info ("Applying remediation for resultsFile {} and resultsFile {}" , resultsFile , kicsFile );
340346
347+ List <String > arguments = new ArrayList <>();
348+ arguments .add (this .executable );
349+ arguments .add ("utils" );
350+ arguments .add ("remediation" );
351+ arguments .add ("kics" );
352+ arguments .add ("--results-file" );
353+ arguments .add (resultsFile );
354+ arguments .add ("--kics-files" );
355+ arguments .add (kicsFile );
356+ if (engine .length () > 0 ) {
357+ arguments .add (CxConstants .ENGINE );
358+ arguments .add (engine );
359+ }
360+ if (similarityIds .length () > 0 ) {
361+ arguments .add ("--similarity-ids" );
362+ arguments .add (similarityIds );
363+ }
364+ KicsRemediation remediation = Execution .executeCommand (arguments , logger , KicsRemediation ::fromLine );
365+ return remediation ;
341366 }
367+
342368 private int getIndexOfBfLNode (List <Node > bflNodes , List <Node > resultNodes ) {
343369
344370 int bflNodeNotFound = -1 ;
0 commit comments