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

Add support for multiple policy in on block event #857

Merged
merged 7 commits into from
Jul 11, 2023

Conversation

asafambar
Copy link
Contributor

  • All tests passed. If this feature is not already covered by the tests, I added new tests.
  • All static analysis checks passed.
  • This pull request is on the dev branch.
  • I used gofmt for formatting the code before submitting the pull request.

Copy link
Contributor

@eyalbe4 eyalbe4 left a comment

Choose a reason for hiding this comment

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

Will you be able to add a clear description to this PR, explaining what this feature is all about and what auto-merge means?
I'd be happy ro review this PR again afterwards.

utils/coreutils/tableutils.go Show resolved Hide resolved
utils/coreutils/tableutils.go Outdated Show resolved Hide resolved
xray/commands/curation/audit.go Outdated Show resolved Hide resolved
@asafambar
Copy link
Contributor Author

asafambar commented Jul 9, 2023

Description for PR:
I added the support to present many policies which blocked the package, up until now we supported only one
also added for each policy the explanation and recommendation,.
explanation - why the package was blocked by this policy (e.g: CVE2020 with severity 9.0)
recommendation - what to do in order to fix the issue (e.g: upgrade to 2.0.1 version)

In order to show multi policies in a neat way in the table structure, I added the auto-merge option,
this option is supported by the library we are using today ---> https://github.com/jedib0t/go-pretty
it merges cells which have similar values, so if under the same blocked package I have many policies with recommendations and explanations, it will merge the the lines for the same package under one, and will keep the split lines for the policies.
an output example:
image

utils/coreutils/tableutils.go Outdated Show resolved Hide resolved
xray/commands/curation/audit.go Show resolved Hide resolved
xray/commands/curation/audit.go Outdated Show resolved Hide resolved
xray/commands/curation/audit.go Outdated Show resolved Hide resolved
@yahavi yahavi changed the title Add support for multiple policy in on block event. Add support for multiple policy in on block event Jul 10, 2023
@yahavi yahavi added the improvement Automatically generated release notes label Jul 10, 2023
@eyalbe4 eyalbe4 added ignore for release Automatically generated release notes and removed improvement Automatically generated release notes labels Jul 11, 2023
@yahavi yahavi merged commit 491202d into jfrog:dev Jul 11, 2023
6 of 7 checks passed
@@ -91,6 +92,36 @@ var DefaultMaxColWidth = 25
// ┌─────────────────────────┐
// │ No customers were found │
// └─────────────────────────┘
//
// Example(auto-merge):
Copy link
Contributor

Choose a reason for hiding this comment

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

// Example(auto-merge): --> // Example (auto-merge):

policies = append(policies, Policy{Policy: strings.TrimSpace(pol), Condition: strings.TrimSpace(cond)})
}
}
return policies
}

// Adding a new line after the headline and replace every "|" with a new line.
func makeLegiblePolicyDetails(explanation, recommendation string) (string, string) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's a unit test for this frunction.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have unit test for the function which using it, anyway, I can add dedicated one

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ignore for release Automatically generated release notes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants