@@ -88,6 +88,7 @@ const (
8888 configIncremental = "incremental"
8989 configFastScan = "fastScanMode"
9090 configPresetName = "presetName"
91+ configPresetID = "presetId"
9192 configEngineVerbose = "engineVerbose"
9293 configLanguageMode = "languageMode"
9394 ConfigContainersFilesFilterKey = "filesFilter"
@@ -553,7 +554,10 @@ func scanCreateSubCommand(
553554 false ,
554555 "Incremental SAST scan should be performed." ,
555556 )
557+
556558 createScanCmd .PersistentFlags ().String (commonParams .PresetName , "" , "The name of the Checkmarx preset to use." )
559+ createScanCmd .PersistentFlags ().String (commonParams .IacsPresetIDFlag , "" , commonParams .IacsPresetIDUsage )
560+
557561 createScanCmd .PersistentFlags ().String (
558562 commonParams .ScaResolverFlag ,
559563 "" ,
@@ -898,6 +902,7 @@ func addKicsScan(cmd *cobra.Command, resubmitConfig []wrappers.Config) map[strin
898902 kicsMapConfig [resultsMapType ] = commonParams .KicsType
899903 kicsConfig .Filter = deprecatedFlagValue (cmd , commonParams .KicsFilterFlag , commonParams .IacsFilterFlag )
900904 kicsConfig .Platforms = deprecatedFlagValue (cmd , commonParams .KicsPlatformsFlag , commonParams .IacsPlatformsFlag )
905+ kicsConfig .PresetID , _ = cmd .Flags ().GetString (commonParams .IacsPresetIDFlag )
901906 for _ , config := range resubmitConfig {
902907 if config .Type == commonParams .KicsType {
903908 resubmitFilter := config .Value [configFilterKey ]
@@ -908,6 +913,10 @@ func addKicsScan(cmd *cobra.Command, resubmitConfig []wrappers.Config) map[strin
908913 if resubmitPlatforms != nil && kicsConfig .Platforms == "" {
909914 kicsConfig .Platforms = resubmitPlatforms .(string )
910915 }
916+ resubmitPresetID := config .Value [configPresetID ]
917+ if resubmitPresetID != nil && kicsConfig .PresetID == "" {
918+ kicsConfig .PresetID = resubmitPresetID .(string )
919+ }
911920 }
912921 }
913922 kicsMapConfig [resultsMapValue ] = & kicsConfig
@@ -1123,7 +1132,7 @@ func validateScanTypes(cmd *cobra.Command, jwtWrapper wrappers.JWTWrapper, featu
11231132 var scanTypes []string
11241133 var SCSScanTypes []string
11251134
1126- containerEngineCLIEnabled , _ := featureFlagsWrapper . GetSpecificFlag ( wrappers . ContainerEngineCLIEnabled )
1135+ runContainerEngineCLI := isContainersEngineEnabled ( featureFlagsWrapper )
11271136 allowedEngines , err := jwtWrapper .GetAllowedEngines (featureFlagsWrapper )
11281137 if err != nil {
11291138 err = errors .Errorf ("Error validating scan types: %v" , err )
@@ -1140,7 +1149,7 @@ func validateScanTypes(cmd *cobra.Command, jwtWrapper wrappers.JWTWrapper, featu
11401149
11411150 scanTypes = strings .Split (userScanTypes , "," )
11421151 for _ , scanType := range scanTypes {
1143- if ! allowedEngines [scanType ] || (scanType == commonParams .ContainersType && ! (containerEngineCLIEnabled . Status )) {
1152+ if ! allowedEngines [scanType ] || (scanType == commonParams .ContainersType && ! (runContainerEngineCLI )) {
11441153 keys := reflect .ValueOf (allowedEngines ).MapKeys ()
11451154 err = errors .Errorf (engineNotAllowed , scanType , scanType , keys )
11461155 return err
@@ -1156,7 +1165,7 @@ func validateScanTypes(cmd *cobra.Command, jwtWrapper wrappers.JWTWrapper, featu
11561165
11571166 } else {
11581167 for k := range allowedEngines {
1159- if k == commonParams .ContainersType && ! (containerEngineCLIEnabled . Status ) {
1168+ if k == commonParams .ContainersType && ! (runContainerEngineCLI ) {
11601169 continue
11611170 }
11621171 scanTypes = append (scanTypes , k )
@@ -1169,6 +1178,16 @@ func validateScanTypes(cmd *cobra.Command, jwtWrapper wrappers.JWTWrapper, featu
11691178 return nil
11701179}
11711180
1181+ func isContainersEngineEnabled (featureFlagsWrapper wrappers.FeatureFlagsWrapper ) bool {
1182+ containerEngineCLIEnabled , err := featureFlagsWrapper .GetSpecificFlag (wrappers .ContainerEngineCLIEnabled )
1183+ if err != nil {
1184+ logger .PrintfIfVerbose ("Failed to fetch CONTAINER_ENGINE_CLI_ENABLED FF, defaulting to `false`. Error: %s" , err )
1185+ return false
1186+ }
1187+
1188+ return containerEngineCLIEnabled .Status
1189+ }
1190+
11721191func scanTypeEnabled (scanType string ) bool {
11731192 scanTypes := strings .Split (actualScanTypes , "," )
11741193 for _ , a := range scanTypes {
@@ -2791,6 +2810,12 @@ func validateCreateScanFlags(cmd *cobra.Command) error {
27912810 return errors .Errorf ("Invalid value for --project-private-package flag. The value must be true or false." )
27922811 }
27932812
2813+ if kicsPresetID , _ := cmd .Flags ().GetString (commonParams .IacsPresetIDFlag ); kicsPresetID != "" {
2814+ if _ , err := uuid .Parse (kicsPresetID ); err != nil {
2815+ return fmt .Errorf ("Invalid value for --%s flag. Must be a valid UUID." , commonParams .IacsPresetIDFlag )
2816+ }
2817+ }
2818+
27942819 return nil
27952820}
27962821
0 commit comments