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

detectExecuteScan : Changes to include user group and handle build fails #1775

Merged
merged 26 commits into from
Jul 28, 2020

Conversation

shenoygi
Copy link
Member

@shenoygi shenoygi commented Jul 8, 2020

Changes

With this change I have included two parameters for the detectExecuteScan step which executes Synopsys Detect scans.
The non-mandatory parameter group, will allow users to specify a user group which can be added to the projects during scan.
The non-mandatory parameter failOn, allows users to specify the category of the policies to check after the scan is completed. Defaults to Blocker. The current implementation adds this parameter in scanProperties, which can be (unintentionally) over ridden when a different flags are set using the scanProperties parameter

  • Tests : Tests are included in the detectExecuteScan_test.go
  • Documentation : documentation updated through the detect.yaml file

Could you please review and let me know if I am missing something from the documentation/code quality perspective? I have already tested my forked version to include these parameters and also without (since they are non mandatory fields) through jenkins runs.

@CLAassistant
Copy link

CLAassistant commented Jul 8, 2020

CLA assistant check
All committers have signed the CLA.

documentation/docs/steps/detectExecuteScan.md Outdated Show resolved Hide resolved
documentation/docs/steps/detectExecuteScan.md Outdated Show resolved Hide resolved
documentation/docs/steps/detectExecuteScan.md Outdated Show resolved Hide resolved
documentation/docs/steps/detectExecuteScan.md Outdated Show resolved Hide resolved
documentation/docs/steps/detectExecuteScan.md Outdated Show resolved Hide resolved
@@ -1,6 +1,11 @@
# ${docGenStepName}
# detectExecuteScan
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The docs are generated when deployed to GH pages, do not commit generated docs.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the heads up. I will remove this from the commit

@CCFenner CCFenner added the REVIEW Pull-Request needs a review label Jul 9, 2020
Copy link
Member

@OliverNocon OliverNocon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks very much for this PR.

I added some comments, please have a look.

description: Mark the current build as fail based the policy categories. A comma seperated list can be provided to fail on multiple categories, for eg. 'BLOCKER,CRITICAL,MAJOR'
aliases:
- name: detect/failOn
type: string
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

to properly reflect the muilti-value character we should go with type []string

type: string
mandatory: false
default:
BLOCKER
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
BLOCKER
- BLOCKER

@@ -46,6 +46,12 @@ func addDetectArgs(args []string, config detectExecuteScanOptions) []string {

args = append(args, fmt.Sprintf("--detect.project.name=%v", config.ProjectName))
args = append(args, fmt.Sprintf("--detect.project.version.name=%v", config.ProjectVersion))
args = append(args, fmt.Sprintf("--detect.policy.check.fail.on.severities=%v", config.FailOn))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

currently it can be empty if failOn is configured incorrectly.
I see two options:

  • make the parameter mandatory
  • only add the flag if failOn is set

What do you think?

In addtion we should do something like strings.Join(config.FailOn, ",") if the type is changed to[]string

description: Users groups to be assigned for the Project
aliases:
- name: detect/groups
type: string
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can only be one group assigned?
If not, we should make this multi-value -> []string

If only one group can be assigned the parameter should rather be group.

Maybe some more explanation would be helpful in the description.

Copy link
Member

@CCFenner CCFenner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The docs are generated when deployed to GH pages, do not commit fully generated docs file.

cmd/detectExecuteScan.go Outdated Show resolved Hide resolved
cmd/detectExecuteScan.go Show resolved Hide resolved
},
expected: []string{
"--testProp1=1",
"--blackduck.url=https://server.url",
"--blackduck.api.token=apiToken",
"--detect.project.name=testName",
"--detect.project.version.name=1.0",
"--detect.policy.check.fail.on.severities=BLOCKER,CRITICAL,MAJOR",
"--detect.project.user.groups=testGroup",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please test also with multiple groups

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have added another test case to check multiple groups. And tested the generated CLI with a scan

- STAGES
- STEPS
- name: failOn
description: Mark the current build as fail based the policy categories. A comma seperated list can be provided to fail on multiple categories, for eg. 'BLOCKER,CRITICAL,MAJOR'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

update description: it is a list and not comma separated anymore

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. I have updated the description to include the details about the policies and acceptable values

Copy link
Member

@OliverNocon OliverNocon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! LGTM

@shenoygi shenoygi requested a review from CCFenner July 27, 2020 13:53
Comment on lines +3 to +6
description: Executes Synopsys Detect scan
longDescription: |
This step executes [Synopsys Detect](https://synopsys.atlassian.net/wiki/spaces/INTDOCS/pages/62423113/Synopsys+Detect) scans.
Synopsys Detect command line utlity can be used to run various scans including BlackDuck and Polaris scans. This step allows users to run BlackDuck scans by default.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As the docs are concatenated I would omit the first sentence.

Suggested change
description: Executes Synopsys Detect scan
longDescription: |
This step executes [Synopsys Detect](https://synopsys.atlassian.net/wiki/spaces/INTDOCS/pages/62423113/Synopsys+Detect) scans.
Synopsys Detect command line utlity can be used to run various scans including BlackDuck and Polaris scans. This step allows users to run BlackDuck scans by default.
description: Executes Synopsys Detect scan
longDescription: |
[Synopsys Detect](https://synopsys.atlassian.net/wiki/spaces/INTDOCS/pages/62423113/Synopsys+Detect) command line utlity can be used to run various scans including BlackDuck and Polaris scans. This step allows users to run BlackDuck scans by default.

@OliverNocon OliverNocon merged commit 0fc131a into SAP:master Jul 28, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
REVIEW Pull-Request needs a review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants