From 83fc366ea30ed70a964c927ccb63c781cbb21527 Mon Sep 17 00:00:00 2001 From: C5345921 Date: Thu, 7 Dec 2023 12:37:22 +0300 Subject: [PATCH 1/3] removed-detect7-option --- cmd/detectExecuteScan.go | 12 +++++++++--- cmd/detectExecuteScan_generated.go | 22 --------------------- resources/metadata/detectExecuteScan.yaml | 24 ----------------------- 3 files changed, 9 insertions(+), 49 deletions(-) diff --git a/cmd/detectExecuteScan.go b/cmd/detectExecuteScan.go index 7c77192df3..047a598e66 100644 --- a/cmd/detectExecuteScan.go +++ b/cmd/detectExecuteScan.go @@ -305,11 +305,17 @@ func getDetectScript(config detectExecuteScanOptions, utils detectUtils) error { log.Entry().Infof("Downloading Detect Script") - if config.UseDetect7 { - return utils.DownloadFile("https://detect.synopsys.com/detect7.sh", "detect.sh", nil, nil) + // ALBATROSS-199 - detect.sh might not be available on the first try + 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 + } } - return utils.DownloadFile("https://detect.synopsys.com/detect8.sh", "detect.sh", nil, nil) + return err } func addDetectArgs(args []string, config detectExecuteScanOptions, utils detectUtils, sys *blackduckSystem) ([]string, error) { diff --git a/cmd/detectExecuteScan_generated.go b/cmd/detectExecuteScan_generated.go index 3f70196b7d..1aaa2b6412 100644 --- a/cmd/detectExecuteScan_generated.go +++ b/cmd/detectExecuteScan_generated.go @@ -45,8 +45,6 @@ type detectExecuteScanOptions struct { MavenExcludedScopes []string `json:"mavenExcludedScopes,omitempty"` DetectTools []string `json:"detectTools,omitempty"` ScanOnChanges bool `json:"scanOnChanges,omitempty"` - UseDetect7 bool `json:"useDetect7,omitempty"` - UseDetect8 bool `json:"useDetect8,omitempty"` SuccessOnSkip bool `json:"successOnSkip,omitempty"` CustomEnvironmentVariables []string `json:"customEnvironmentVariables,omitempty"` MinScanInterval int `json:"minScanInterval,omitempty"` @@ -291,8 +289,6 @@ func addDetectExecuteScanFlags(cmd *cobra.Command, stepConfig *detectExecuteScan cmd.Flags().StringSliceVar(&stepConfig.MavenExcludedScopes, "mavenExcludedScopes", []string{}, "The maven scopes that need to be excluded from the scan. For example, setting the value 'test' will exclude all components which are defined with a test scope in maven") cmd.Flags().StringSliceVar(&stepConfig.DetectTools, "detectTools", []string{}, "The type of BlackDuck scanners to include while running the BlackDuck scan. By default All scanners are included. For the complete list of possible values, Please refer [Synopsys detect documentation](https://community.synopsys.com/s/document-item?bundleId=integrations-detect&topicId=properties%2Fconfiguration%2Fpaths.html&_LANG=enus&anchor=detect-tools-included)") cmd.Flags().BoolVar(&stepConfig.ScanOnChanges, "scanOnChanges", false, "This flag determines if the scan is submitted to the server. If set to true, then the scan request is submitted to the server only when changes are detected in the Open Source Bill of Materials If the flag is set to false, then the scan request is submitted to server regardless of any changes. For more details please refer to the [documentation](https://github.com/blackducksoftware/detect_rescan/blob/master/README.md)") - cmd.Flags().BoolVar(&stepConfig.UseDetect7, "useDetect7", false, "This flag allows to use the currently supported 8 version of Detect Script instead of v7") - cmd.Flags().BoolVar(&stepConfig.UseDetect8, "useDetect8", true, "This flag allows to use the currently supported 8 version of Detect Script instead of v7") cmd.Flags().BoolVar(&stepConfig.SuccessOnSkip, "successOnSkip", true, "This flag allows forces Black Duck to exit with 0 error code if any step is skipped") cmd.Flags().StringSliceVar(&stepConfig.CustomEnvironmentVariables, "customEnvironmentVariables", []string{}, "A list of environment variables which can be set to prepare the environment to run a BlackDuck scan. This includes a list of environment variables defined by Synopsys. The full list can be found [here](https://community.synopsys.com/s/document-item?bundleId=integrations-detect&topicId=configuring%2Fenvvars.html&_LANG=enus) This list affects the detect script downloaded while running the scan. Right now only detect7.sh is available for downloading") cmd.Flags().IntVar(&stepConfig.MinScanInterval, "minScanInterval", 0, "This parameter controls the frequency (in number of hours) at which the signature scan is re-submitted for scan. When set to a value greater than 0, the signature scans are skipped until the specified number of hours has elapsed since the last signature scan.") @@ -559,24 +555,6 @@ func detectExecuteScanMetadata() config.StepData { Aliases: []config.Alias{}, Default: false, }, - { - Name: "useDetect7", - ResourceRef: []config.ResourceReference{}, - Scope: []string{"PARAMETERS", "STAGES", "STEPS"}, - Type: "bool", - Mandatory: false, - Aliases: []config.Alias{{Name: "detect/useDetect7"}}, - Default: false, - }, - { - Name: "useDetect8", - ResourceRef: []config.ResourceReference{}, - Scope: []string{"PARAMETERS", "STAGES", "STEPS"}, - Type: "bool", - Mandatory: false, - Aliases: []config.Alias{{Name: "detect/useDetect8", Deprecated: true}}, - Default: true, - }, { Name: "successOnSkip", ResourceRef: []config.ResourceReference{}, diff --git a/resources/metadata/detectExecuteScan.yaml b/resources/metadata/detectExecuteScan.yaml index dc0663c6bd..e840c07bc7 100644 --- a/resources/metadata/detectExecuteScan.yaml +++ b/resources/metadata/detectExecuteScan.yaml @@ -301,30 +301,6 @@ spec: - STAGES - STEPS deprecated: true - - name: useDetect7 - description: - "This flag allows to use the currently supported 8 version of Detect Script instead of v7" - aliases: - - name: detect/useDetect7 - type: bool - scope: - - PARAMETERS - - STAGES - - STEPS - default: false - - name: useDetect8 - description: - "This flag allows to use the currently supported 8 version of Detect Script instead of v7" - aliases: - - name: detect/useDetect8 - deprecated: true - type: bool - scope: - - PARAMETERS - - STAGES - - STEPS - default: true - deprecated: true - name: successOnSkip description: "This flag allows forces Black Duck to exit with 0 error code if any step is skipped" From b0a964af853e9336957f157d062ce9c504d8e14d Mon Sep 17 00:00:00 2001 From: C5345921 Date: Thu, 7 Dec 2023 12:48:40 +0300 Subject: [PATCH 2/3] linting-fix --- cmd/detectExecuteScan.go | 52 ++++++++++++---------------------------- 1 file changed, 15 insertions(+), 37 deletions(-) diff --git a/cmd/detectExecuteScan.go b/cmd/detectExecuteScan.go index 047a598e66..446953fbf9 100644 --- a/cmd/detectExecuteScan.go +++ b/cmd/detectExecuteScan.go @@ -382,49 +382,27 @@ func addDetectArgs(args []string, config detectExecuteScanOptions, utils detectU codelocation = fmt.Sprintf("%v/%v", config.ProjectName, detectVersionName) } - // Since detect8 adds quotes by default, to avoid double quotation they should be removed for several arguments - if config.UseDetect7 { - args = append(args, fmt.Sprintf("\"--detect.project.name='%v'\"", config.ProjectName)) - args = append(args, fmt.Sprintf("\"--detect.project.version.name='%v'\"", detectVersionName)) - - // Groups parameter is added only when there is atleast one non-empty groupname provided - if len(config.Groups) > 0 && len(config.Groups[0]) > 0 { - args = append(args, fmt.Sprintf("\"--detect.project.user.groups='%v'\"", strings.Join(config.Groups, ","))) - } - - // Atleast 1, non-empty category to fail on must be provided - if len(config.FailOn) > 0 && len(config.FailOn[0]) > 0 { - args = append(args, fmt.Sprintf("--detect.policy.check.fail.on.severities=%v", strings.Join(config.FailOn, ","))) - } - - args = append(args, fmt.Sprintf("\"--detect.code.location.name='%v'\"", codelocation)) - - if len(mavenArgs) > 0 && !checkIfArgumentIsInScanProperties(config, "detect.maven.build.command") { - args = append(args, fmt.Sprintf("\"--detect.maven.build.command='%v'\"", strings.Join(mavenArgs, " "))) - } - } else { - args = append(args, fmt.Sprintf("\"--detect.project.name=%v\"", config.ProjectName)) - args = append(args, fmt.Sprintf("\"--detect.project.version.name=%v\"", detectVersionName)) + args = append(args, fmt.Sprintf("\"--detect.project.name=%v\"", config.ProjectName)) + args = append(args, fmt.Sprintf("\"--detect.project.version.name=%v\"", detectVersionName)) - // Groups parameter is added only when there is atleast one non-empty groupname provided - if len(config.Groups) > 0 && len(config.Groups[0]) > 0 { - args = append(args, fmt.Sprintf("\"--detect.project.user.groups=%v\"", strings.Join(config.Groups, ","))) - } - - // Atleast 1, non-empty category to fail on must be provided - if len(config.FailOn) > 0 && len(config.FailOn[0]) > 0 { - args = append(args, fmt.Sprintf("--detect.policy.check.fail.on.severities=%v", strings.Join(config.FailOn, ","))) - } + // Groups parameter is added only when there is atleast one non-empty groupname provided + if len(config.Groups) > 0 && len(config.Groups[0]) > 0 { + args = append(args, fmt.Sprintf("\"--detect.project.user.groups=%v\"", strings.Join(config.Groups, ","))) + } - args = append(args, fmt.Sprintf("\"--detect.code.location.name=%v\"", codelocation)) + // Atleast 1, non-empty category to fail on must be provided + if len(config.FailOn) > 0 && len(config.FailOn[0]) > 0 { + args = append(args, fmt.Sprintf("--detect.policy.check.fail.on.severities=%v", strings.Join(config.FailOn, ","))) + } - if len(mavenArgs) > 0 && !checkIfArgumentIsInScanProperties(config, "detect.maven.build.command") { - args = append(args, fmt.Sprintf("\"--detect.maven.build.command=%v\"", strings.Join(mavenArgs, " "))) - } + args = append(args, fmt.Sprintf("\"--detect.code.location.name=%v\"", codelocation)) - args = append(args, fmt.Sprintf("\"--detect.force.success.on.skip=true\"")) + if len(mavenArgs) > 0 && !checkIfArgumentIsInScanProperties(config, "detect.maven.build.command") { + args = append(args, fmt.Sprintf("\"--detect.maven.build.command=%v\"", strings.Join(mavenArgs, " "))) } + args = append(args, fmt.Sprintf("\"--detect.force.success.on.skip=true\"")) + if len(config.ScanPaths) > 0 && len(config.ScanPaths[0]) > 0 { args = append(args, fmt.Sprintf("--detect.blackduck.signature.scanner.paths=%v", strings.Join(config.ScanPaths, ","))) } From c452fbe9c0d3d9141e69f92f7c2765be93d820dc Mon Sep 17 00:00:00 2001 From: C5345921 Date: Thu, 14 Dec 2023 16:09:38 +0300 Subject: [PATCH 3/3] removed-comment --- cmd/detectExecuteScan.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/cmd/detectExecuteScan.go b/cmd/detectExecuteScan.go index 446953fbf9..8ee82bf3be 100644 --- a/cmd/detectExecuteScan.go +++ b/cmd/detectExecuteScan.go @@ -305,7 +305,6 @@ func getDetectScript(config detectExecuteScanOptions, utils detectUtils) error { log.Entry().Infof("Downloading Detect Script") - // ALBATROSS-199 - detect.sh might not be available on the first try err := utils.DownloadFile("https://detect.synopsys.com/detect8.sh", "detect.sh", nil, nil) if err != nil { time.Sleep(time.Second * 5) @@ -315,7 +314,7 @@ func getDetectScript(config detectExecuteScanOptions, utils detectUtils) error { } } - return err + return nil } func addDetectArgs(args []string, config detectExecuteScanOptions, utils detectUtils, sys *blackduckSystem) ([]string, error) {