Skip to content

Commit

Permalink
added detect8 support (#4545)
Browse files Browse the repository at this point in the history
  • Loading branch information
dimaste authored and andrew-kireev committed Oct 17, 2023
1 parent 5a4ac6c commit 869ce75
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 1 deletion.
13 changes: 12 additions & 1 deletion cmd/detectExecuteScan.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ func newDetectUtils(client *github.Client) detectUtils {
"FAILURE_BLACKDUCK_FEATURE_ERROR - Detect encountered an error while attempting an operation on Black Duck. Ensure your Black Duck is compatible with this version of detect.",
"FAILURE_GENERAL_ERROR - Detect encountered a known error, details of the error are provided.",
"FAILURE_UNKNOWN_ERROR - Detect encountered an unknown error.",
"FAILURE_MINIMUM_INTERVAL_NOT_MET - Detect did not wait the minimum required scan interval.",
},
},
},
Expand Down Expand Up @@ -276,6 +277,7 @@ func exitCodeMapping(exitCodeKey int) string {
12: "FAILURE_POLARIS_CONNECTIVITY => Detect was unable to connect to Polaris. Check your configuration and connection.",
99: "FAILURE_GENERAL_ERROR => Detect encountered a known error, details of the error are provided.",
100: "FAILURE_UNKNOWN_ERROR => Detect encountered an unknown error.",
13: "FAILURE_MINIMUM_INTERVAL_NOT_MET => Detect did not wait the minimum required scan interval.",
}

if _, isKeyExists := exitCodes[exitCodeKey]; isKeyExists {
Expand All @@ -290,7 +292,12 @@ func getDetectScript(config detectExecuteScanOptions, utils detectUtils) error {
log.Entry().Infof("The scanOnChanges option is deprecated")
}

log.Entry().Infof("Downloading Detect7")
log.Entry().Infof("Downloading Detect Script")

if config.UseDetect8 {
return utils.DownloadFile("https://detect.synopsys.com/detect8.sh", "detect.sh", nil, nil)
}

return utils.DownloadFile("https://detect.synopsys.com/detect7.sh", "detect.sh", nil, nil)
}

Expand Down Expand Up @@ -351,6 +358,10 @@ func addDetectArgs(args []string, config detectExecuteScanOptions, utils detectU
args = append(args, fmt.Sprintf("--detect.policy.check.fail.on.severities=%v", strings.Join(config.FailOn, ",")))
}

if config.SuccessOnSkip {
args = append(args, fmt.Sprintf("\"--detect.force.success.on.skip=%v\"", config.SuccessOnSkip))
}

codelocation := config.CodeLocation
if len(codelocation) == 0 && len(config.ProjectName) > 0 {
codelocation = fmt.Sprintf("%v/%v", config.ProjectName, detectVersionName)
Expand Down
22 changes: 22 additions & 0 deletions cmd/detectExecuteScan_generated.go

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

22 changes: 22 additions & 0 deletions resources/metadata/detectExecuteScan.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,28 @@ spec:
- STAGES
- STEPS
deprecated: true
- name: useDetect8
description:
"This flag allows to use the currently supported 8 version of Detect Script instead of v7"
aliases:
- name: detect/useDetect8
type: bool
scope:
- PARAMETERS
- STAGES
- STEPS
default: false
- name: successOnSkip
description:
"This flag allows forces Black Duck to exit with 0 error code if any step is skipped"
aliases:
- name: detect/successOnSkip
type: bool
scope:
- PARAMETERS
- STAGES
- STEPS
default: false
- name: customEnvironmentVariables
description:
"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
Expand Down

0 comments on commit 869ce75

Please sign in to comment.