Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove useDetect7 option #4717

Merged
merged 5 commits into from
Jan 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 23 additions & 40 deletions cmd/detectExecuteScan.go
Original file line number Diff line number Diff line change
Expand Up @@ -305,11 +305,16 @@ 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)
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 nil
}

func addDetectArgs(args []string, config detectExecuteScanOptions, utils detectUtils, sys *blackduckSystem) ([]string, error) {
Expand Down Expand Up @@ -376,49 +381,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))
args = append(args, fmt.Sprintf("\"--detect.project.name=%v\"", config.ProjectName))
args = append(args, fmt.Sprintf("\"--detect.project.version.name=%v\"", detectVersionName))

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))

// 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, ",")))
}
Expand Down
22 changes: 0 additions & 22 deletions cmd/detectExecuteScan_generated.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 0 additions & 24 deletions resources/metadata/detectExecuteScan.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
Loading