44import com .checkmarx .ast .codebashing .CodeBashing ;
55import com .checkmarx .ast .kicsRealtimeResults .KicsRealtimeResults ;
66import com .checkmarx .ast .learnMore .LearnMore ;
7+ import com .checkmarx .ast .predicate .CustomState ;
78import com .checkmarx .ast .predicate .Predicate ;
89import com .checkmarx .ast .project .Project ;
910import com .checkmarx .ast .remediation .KicsRemediation ;
2324import org .slf4j .LoggerFactory ;
2425
2526import java .io .IOException ;
27+ import java .lang .reflect .Field ;
2628import java .nio .file .Files ;
2729import java .util .ArrayList ;
2830import java .util .List ;
@@ -161,12 +163,32 @@ public List<Predicate> triageShow(@NonNull UUID projectId, String similarityId,
161163
162164 arguments .addAll (jsonArguments ());
163165
164- return Execution .executeCommand (withConfigArguments (arguments ), logger , Predicate ::listFromLine );
166+ return Execution .executeCommand (withConfigArguments (arguments ), logger , Predicate ::listFromLine , Predicate ::validator );
167+ }
168+
169+ public List <Predicate > triageGetStates (boolean all ) throws IOException , InterruptedException , CxException {
170+ this .logger .info ("Executing 'triage get-states' command using the CLI." );
171+
172+ List <String > arguments = new ArrayList <>();
173+ arguments .add (CxConstants .CMD_TRIAGE );
174+ arguments .add (CxConstants .SUB_CMD_GET_STATES );
175+ if (all ) {
176+ arguments .add (CxConstants .ALL_STATES_FLAG );
177+ }
178+
179+ return Execution .executeCommand (withConfigArguments (arguments ), logger , CustomState ::listFromLine );
165180 }
166181
167182 public void triageUpdate (@ NonNull UUID projectId , String similarityId , String scanType , String state , String comment , String severity ) throws IOException , InterruptedException , CxException {
183+ triageUpdate (projectId , similarityId , scanType , state , comment , severity , null );
184+ }
185+
186+ public void triageUpdate (@ NonNull UUID projectId , String similarityId , String scanType , String state , String comment , String severity , String customStateId ) throws IOException , InterruptedException , CxException {
168187 this .logger .info ("Executing 'triage update' command using the CLI." );
169- this .logger .info ("Updating the similarityId {} with state {} and severity {}." , similarityId , state , severity );
188+ this .logger .info ("Updating the similarityId {} with state {} with customStateId {} and severity {}." , similarityId , state , customStateId , severity );
189+
190+ boolean emptyState = state == null || state .isEmpty ();
191+ boolean emptyCustomStateId = customStateId == null || customStateId .isEmpty ();
170192
171193 List <String > arguments = new ArrayList <>();
172194 arguments .add (CxConstants .CMD_TRIAGE );
@@ -179,6 +201,10 @@ public void triageUpdate(@NonNull UUID projectId, String similarityId, String sc
179201 arguments .add (scanType );
180202 arguments .add (CxConstants .STATE );
181203 arguments .add (state );
204+ if (!emptyCustomStateId ) {
205+ arguments .add (CxConstants .CUSTOM_STATE_ID );
206+ arguments .add (customStateId );
207+ }
182208 if (!StringUtils .isBlank (comment )) {
183209 arguments .add (CxConstants .COMMENT );
184210 arguments .add (comment );
@@ -232,7 +258,9 @@ public ScanResult ScanAsca(String fileSource, boolean ascaLatestVersion, String
232258
233259 appendAgentToArguments (agent , arguments );
234260
235- return Execution .executeCommand (withConfigArguments (arguments ), logger , ScanResult ::fromLine );
261+ return Execution .executeCommand (withConfigArguments (arguments ), logger , ScanResult ::fromLine ,
262+ (args , ignored ) ->
263+ (args .size () >= 3 && args .get (1 ).equals (CxConstants .CMD_SCAN ) && args .get (2 ).equals (CxConstants .SUB_CMD_ASCA )));
236264 }
237265
238266 private static void appendAgentToArguments (String agent , List <String > arguments ) {
0 commit comments