@@ -10,6 +10,7 @@ import (
1010
1111 "github.com/MakeNowJust/heredoc"
1212 "github.com/checkmarx/ast-cli/internal/commands/util/printer"
13+ "github.com/checkmarx/ast-cli/internal/logger"
1314 "github.com/checkmarx/ast-cli/internal/params"
1415 "github.com/checkmarx/ast-cli/internal/wrappers"
1516 "github.com/pkg/errors"
@@ -211,7 +212,7 @@ func runTriageUpdate(resultsPredicatesWrapper wrappers.ResultsPredicatesWrapper,
211212 }
212213 var err error
213214 state , customStateID , err = determineSystemOrCustomState (customStatesWrapper , featureFlagsWrapper , state , customStateID )
214- predicate , err := handlePredicate (vulnerabilityDetails , similarityID , projectID , severity , state , customStateID , comment , scanType )
215+ predicate , err := preparePredicateRequest (vulnerabilityDetails , similarityID , projectID , severity , state , customStateID , comment , scanType )
215216 if err != nil {
216217 return errors .Wrapf (err , "%s" , "Failed updating the predicate" )
217218 }
@@ -223,12 +224,12 @@ func runTriageUpdate(resultsPredicatesWrapper wrappers.ResultsPredicatesWrapper,
223224 }
224225}
225226
226- func handlePredicate (vulnerabilityDetails []string , similarityID string , projectID string , severity string , state string , customStateID int , comment string , scanType string ) (interface {}, error ) {
227+ func preparePredicateRequest (vulnerabilityDetails []string , similarityID string , projectID string , severity string , state string , customStateID int , comment string , scanType string ) (interface {}, error ) {
227228 scanType = strings .ToLower (scanType )
228229 scanType = strings .TrimSpace (scanType )
229230 if strings .EqualFold (scanType , Sca ) {
230231 state = transformState (state )
231- payload , err := handleScaTriage (vulnerabilityDetails , comment , state , projectID )
232+ payload , err := prepareScaTriagePayload (vulnerabilityDetails , comment , state , projectID )
232233 if err != nil {
233234 return nil , err
234235 }
@@ -266,7 +267,7 @@ func transformState(state string) string {
266267 return ""
267268}
268269
269- func handleScaTriage (vulnerabilityDetails []string , comment string , state string , projectId string ) (interface {}, error ) {
270+ func prepareScaTriagePayload (vulnerabilityDetails []string , comment string , state string , projectId string ) (interface {}, error ) {
270271 scaTriageInfo := make (map [string ]interface {})
271272 for _ , vulnerability := range vulnerabilityDetails {
272273 vulnerabilityKeyVal := strings .SplitN (vulnerability , "=" , 2 )
@@ -296,13 +297,14 @@ func handleScaTriage(vulnerabilityDetails []string, comment string, state string
296297 scaTriageInfo ["actions" ] = []map [string ]interface {}{actionInfo }
297298 b , err := json .Marshal (scaTriageInfo )
298299 if err != nil {
299- return nil , errors .Errorf ("Failed to serialize vulnerabilities %s" , scaTriageInfo )
300+ logger .PrintIfVerbose (fmt .Sprintf ("Failed to serialize vulnerabilities %s" , scaTriageInfo ))
301+ return nil , errors .Errorf ("Failed to prepare SCA triage request" )
300302 }
301- payload := & wrappers.ScaPredicateRequest {}
302- fmt .Println ("Payload: " , string (b ))
303+ payload := wrappers.ScaPredicateRequest {}
303304 err = json .Unmarshal (b , payload )
304305 if err != nil {
305- return nil , errors .Errorf ("Failed to deserialize vulnerabilities %s" , b )
306+ logger .PrintIfVerbose (fmt .Sprintf ("Failed to deserialize vulnerabilities %s" , string (b )))
307+ return nil , errors .Errorf ("Failed to prepare SCA triage request" )
306308 }
307309 return payload , nil
308310}
0 commit comments