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

Implemented new CLI flag: --show-suppressed #966

Merged
merged 4 commits into from
Nov 1, 2022
Merged

Conversation

vimalpatel19
Copy link
Contributor

@vimalpatel19 vimalpatel19 commented Oct 24, 2022

Implemented new CLI flag (--include-suppressed) that allows for ignored/suppressed matches to be displayed in the table output format when that flag is provided.

Closes: #887

…ed/suppressed matches to be displayed in the table output format when that flag is provided.

Signed-off-by: Vimal Patel <vimalpatel0611@gmail.com>
Copy link
Contributor

@kzantow kzantow left a comment

Choose a reason for hiding this comment

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

I've had a cursory look through this change but I have a question: do these suppressed vulnerabilities need to be included in the JSON or just the table view (they are already included in the JSON)? If it's just the latter, maybe a better approach would be to not modify the data structure, but just print out both normal and suppressed vulns together?

@freedom-isnotanarchy
Copy link

I can't seem to find the Feature Request, for this. I know I cared ... and a search does not find that Feature Request.
Might you happen to have that URL, handy ?

@kzantow
Copy link
Contributor

kzantow commented Oct 24, 2022

@freedom-isnotanarchy it's linked in the description and on the right in the Development section

@vimalpatel19
Copy link
Contributor Author

vimalpatel19 commented Oct 24, 2022

@kzantow the suppressed vulnerabilities should already be displayed in the JSON and template output formats. The question I had was do we want to also display the suppressed vulnerabilities in the just the table format, or do we want to attempt to display them in the rest of the other output formats as well (such as cyclonedx, sarif, etc.)?

If it is just for the table format, I can proceed as you suggested and not modify Match data structure. Otherwise if we need to include suppressed vulnerabilities for each of the remaining formats that don't currently do that, I think it might be better to keep the modified Match data structure as opposed to passing in an additional parameter (containing the list of suppressed vulnerabilities) to the NewPresenter method for each of the output formats here: https://github.com/anchore/grype/blob/main/grype/presenter/presenter.go.

@freedom-isnotanarchy
Copy link

@freedom-isnotanarchy it's linked in the description and on the right in the Development section

pr_linked_to_issue

@kzantow
Copy link
Contributor

kzantow commented Oct 25, 2022

@vimalpatel19 these are already included in JSON output, I'm pretty sure, though in a different spot, so I think we should just add these to the table output when the flag is set. 👍

@vimalpatel19
Copy link
Contributor Author

Yes, the JSON output format does have both the matching and suppressed vulnerabilities in the output. I will proceed with just the table output format with the approach you had discussed previously above.

…st. Instead, procceded with making changes for the new flag for just the table output format.

Signed-off-by: Vimal Patel <vimalpatel0611@gmail.com>
@vimalpatel19
Copy link
Contributor Author

@kzantow can you review again when you get a please chance? Pushed updates based on your suggestions earlier.

Copy link
Contributor

@kzantow kzantow left a comment

Choose a reason for hiding this comment

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

Sorry for the delay here, I left some more specific feedback, but a couple general comments:

  • I feel the parameters dealing with showing suppressed vulnerabilities should be the last parameters in every function call for consistency, especially since it's the most recent featured added
  • after pondering this a bit more, I think --show-suppressed is probably a better name for this parameter, as --include-suppressed does not affect failure codes and such, which seems a bit misleading

Happy to hear thoughts on this!

grype/presenter/config_test.go Outdated Show resolved Hide resolved
grype/presenter/config.go Outdated Show resolved Hide resolved
grype/presenter/table/presenter.go Outdated Show resolved Hide resolved
grype/presenter/table/presenter.go Outdated Show resolved Hide resolved
grype/presenter/table/presenter.go Outdated Show resolved Hide resolved
grype/presenter/table/presenter.go Outdated Show resolved Hide resolved
Signed-off-by: Vimal Patel <vimalpatel0611@gmail.com>
@vimalpatel19
Copy link
Contributor Author

@kzantow thanks for the feedback. I have made updates based on your suggestions, can you please review again when you get a chance?

@kzantow kzantow changed the title Implemented new CLI flag: --include-suppressed Implemented new CLI flag: --show-suppressed Nov 1, 2022
Copy link
Contributor

@kzantow kzantow left a comment

Choose a reason for hiding this comment

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

Thanks for the contribution @vimalpatel19, this looks great!

@kzantow
Copy link
Contributor

kzantow commented Nov 1, 2022

Hi @vimalpatel19 -- it looks like there's just one tiny lint issue: https://github.com/anchore/grype/actions/runs/3370373110/jobs/5592852609#step:8:20

I'd be fine with just adding a //nolint:funlen at the top of the function for this one. To validate it fixes the problem you can run make lint locally.

Signed-off-by: Vimal Patel <vimalpatel0611@gmail.com>
@vimalpatel19
Copy link
Contributor Author

@kzantow addressed the lint issue for function length.

@spiffcs spiffcs merged commit 0c4a372 into anchore:main Nov 1, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Show all vulnerabilities, even suppressed
4 participants