diff --git a/cmd/detectExecuteScan.go b/cmd/detectExecuteScan.go index 90602722ad..070f87e22b 100644 --- a/cmd/detectExecuteScan.go +++ b/cmd/detectExecuteScan.go @@ -389,13 +389,16 @@ func getDetectScript(config detectExecuteScanOptions, utils detectUtils) error { log.Entry().Infof("Downloading Detect Script") - err := utils.DownloadFile("https://detect.synopsys.com/detect8.sh", "detect.sh", nil, nil) - if err != nil { - time.Sleep(time.Second * 5) - err = utils.DownloadFile("https://detect.synopsys.com/detect8.sh", "detect.sh", nil, nil) - if err != nil { - return err + downloadScript := func() error { + if config.UseDetect9 { + return utils.DownloadFile("https://detect.synopsys.com/detect9.sh", "detect.sh", nil, nil) } + return utils.DownloadFile("https://detect.synopsys.com/detect8.sh", "detect.sh", nil, nil) + } + + if err := downloadScript(); err != nil { + time.Sleep(5 * time.Second) + return downloadScript() } return nil diff --git a/cmd/detectExecuteScan_generated.go b/cmd/detectExecuteScan_generated.go index ff70833b53..e08238bb90 100644 --- a/cmd/detectExecuteScan_generated.go +++ b/cmd/detectExecuteScan_generated.go @@ -70,6 +70,7 @@ type detectExecuteScanOptions struct { RegistryURL string `json:"registryUrl,omitempty" validate:"required_if=ScanContainerDistro ubuntu ScanContainerDistro centos ScanContainerDistro alpine"` RepositoryUsername string `json:"repositoryUsername,omitempty" validate:"required_if=ScanContainerDistro ubuntu ScanContainerDistro centos ScanContainerDistro alpine"` RepositoryPassword string `json:"repositoryPassword,omitempty" validate:"required_if=ScanContainerDistro ubuntu ScanContainerDistro centos ScanContainerDistro alpine"` + UseDetect9 bool `json:"useDetect9,omitempty"` } type detectExecuteScanInflux struct { @@ -322,6 +323,7 @@ func addDetectExecuteScanFlags(cmd *cobra.Command, stepConfig *detectExecuteScan cmd.Flags().StringVar(&stepConfig.RegistryURL, "registryUrl", os.Getenv("PIPER_registryUrl"), "Used accessing for the images to be scanned (typically filled by CPE)") cmd.Flags().StringVar(&stepConfig.RepositoryUsername, "repositoryUsername", os.Getenv("PIPER_repositoryUsername"), "Used accessing for the images to be scanned (typically filled by CPE)") cmd.Flags().StringVar(&stepConfig.RepositoryPassword, "repositoryPassword", os.Getenv("PIPER_repositoryPassword"), "Used accessing for the images to be scanned (typically filled by CPE)") + cmd.Flags().BoolVar(&stepConfig.UseDetect9, "useDetect9", false, "This flag enables the use of the supported version 9 of the Detect Script instead of v8") cmd.MarkFlagRequired("token") cmd.MarkFlagRequired("projectName") @@ -859,6 +861,15 @@ func detectExecuteScanMetadata() config.StepData { Aliases: []config.Alias{}, Default: os.Getenv("PIPER_repositoryPassword"), }, + { + Name: "useDetect9", + ResourceRef: []config.ResourceReference{}, + Scope: []string{"PARAMETERS", "STAGES", "STEPS"}, + Type: "bool", + Mandatory: false, + Aliases: []config.Alias{{Name: "detect/useDetect9"}}, + Default: false, + }, }, }, Containers: []config.Container{ diff --git a/resources/metadata/detectExecuteScan.yaml b/resources/metadata/detectExecuteScan.yaml index 7043f21928..8873952f2f 100644 --- a/resources/metadata/detectExecuteScan.yaml +++ b/resources/metadata/detectExecuteScan.yaml @@ -601,6 +601,17 @@ spec: resourceRef: - name: commonPipelineEnvironment param: container/repositoryPassword + - name: useDetect9 + description: + "This flag enables the use of the supported version 9 of the Detect Script instead of v8" + aliases: + - name: detect/useDetect9 + type: bool + scope: + - PARAMETERS + - STAGES + - STEPS + default: false outputs: resources: - name: influx