Skip to content

Commit

Permalink
Detect script version 9 (#5154)
Browse files Browse the repository at this point in the history
* detect script v9 as default and detect script v8 as optional for blackduck

* unit test fix

---------

Co-authored-by: Dmitrii Pavlukhin <[email protected]>
  • Loading branch information
akram8008 and dimaste authored Oct 23, 2024
1 parent 3ad2628 commit 7b08d47
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 11 deletions.
7 changes: 4 additions & 3 deletions cmd/detectExecuteScan.go
Original file line number Diff line number Diff line change
Expand Up @@ -427,10 +427,11 @@ func getDetectScript(config detectExecuteScanOptions, utils detectUtils) error {
log.Entry().Infof("Downloading Detect Script")

downloadScript := func() error {
if config.UseDetect9 {
return utils.DownloadFile("https://detect.synopsys.com/detect9.sh", "detect.sh", nil, nil)
if config.UseDetect8 {
return utils.DownloadFile("https://detect.synopsys.com/detect8.sh", "detect.sh", nil, nil)
}
return utils.DownloadFile("https://detect.synopsys.com/detect8.sh", "detect.sh", nil, nil)
return utils.DownloadFile("https://detect.synopsys.com/detect9.sh", "detect.sh", nil, nil)

}

if err := downloadScript(); err != nil {
Expand Down
8 changes: 4 additions & 4 deletions cmd/detectExecuteScan_generated.go

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

2 changes: 1 addition & 1 deletion cmd/detectExecuteScan_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ func TestRunDetect(t *testing.T) {
utilsMock.AddFile("detect.sh", []byte(""))
err := runDetect(ctx, detectExecuteScanOptions{}, utilsMock, &detectExecuteScanInflux{})

assert.Equal(t, utilsMock.downloadedFiles["https://detect.synopsys.com/detect8.sh"], "detect.sh")
assert.Equal(t, utilsMock.downloadedFiles["https://detect.synopsys.com/detect9.sh"], "detect.sh")
assert.True(t, utilsMock.HasRemovedFile("detect.sh"))
assert.NoError(t, err)
assert.Equal(t, ".", utilsMock.Dir, "Wrong execution directory used")
Expand Down
6 changes: 3 additions & 3 deletions resources/metadata/detectExecuteScan.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -653,11 +653,11 @@ spec:
resourceRef:
- name: commonPipelineEnvironment
param: container/repositoryPassword
- name: useDetect9
- name: useDetect8
description:
"This flag enables the use of the supported version 9 of the Detect Script instead of v8"
"This flag enables the use of the supported version 8 of the Detect Script instead of v9"
aliases:
- name: detect/useDetect9
- name: detect/useDetect8
type: bool
scope:
- PARAMETERS
Expand Down

0 comments on commit 7b08d47

Please sign in to comment.