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 the total types of vulnerabilities in Grype output #946

Merged
merged 18 commits into from
Mar 3, 2023

Conversation

zhiburt
Copy link
Contributor

@zhiburt zhiburt commented Oct 4, 2022

Hi there,

Thank you for keeping "Good first issue".

Let me know if I did it correct.
Notice I haven't include any tests.

image

close #877

Take care

Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com>
@willyw0nka
Copy link

Hi 👋, I think that showing vulnerabilities from Critical to Unknown would be more valuable that the correct shown order (Unknown to Critical). Similar to the order proposed in #709. Maybe some contributor can corroborate this feedback

Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com>
@zhiburt
Copy link
Contributor Author

zhiburt commented Oct 5, 2022

image

@freedom-isnotanarchy
Copy link

Would it be possible/desirable, to tack on "Fixed: ##" , at the end.
I believe "Fixed:" , is also in the spirit of this PR.
Thank you for your consideration.

Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com>
@zhiburt
Copy link
Contributor Author

zhiburt commented Oct 5, 2022

@freedom-isnotanarchy

Done (thanks for comment about the format).
I've used ; instead of , as I take these to be a bit different.

image

@freedom-isnotanarchy
Copy link

freedom-isnotanarchy commented Oct 5, 2022

TODAY:

 Vulnerability DB        [updated]
 ✔ Indexed .
 ✔ Cataloged packages      [1229 packages]
 
geronimo-javamail_1.4_spec      1.7.1                     java-archive  CVE-2008-0732        Low
NAME                            INSTALLED       FIXED-IN  TYPE          VULNERABILITY        SEVERITY
gson                            2.8.6           2.8.9     java-archive  GHSA-4jrv-ppp4-jm57  High
spring-core                     5.2.12.RELEASE            java-archive  CVE-2021-22118       High
spring-core                     5.3.22                    java-archive  CVE-2016-1000027     Critical
xmlsec                          2.1.4           2.1.7     java-archive  GHSA-j8wc-gxx9-82hx  High

YOUR PR: [https://github.com//pull/946]

 Vulnerability DB        [updated]
 ✔ Indexed .
 ✔ Cataloged packages      [1229 packages]
 
NAME                            INSTALLED       FIXED-IN  TYPE          VULNERABILITY        SEVERITY
geronimo-javamail_1.4_spec      1.7.1                     java-archive  CVE-2008-0732        Low
gson                            2.8.6           2.8.9     java-archive  GHSA-4jrv-ppp4-jm57  High
spring-core                     5.2.12.RELEASE            java-archive  CVE-2021-22118       High
spring-core                     5.3.22                    java-archive  CVE-2016-1000027     Critical
xmlsec                          2.1.4           2.1.7     java-archive  GHSA-j8wc-gxx9-82hx  High
[Critcal: 1, High: 3, Medium: 0, Low: 0, Unkonwn: 0; Fixed: 2]

[Critcal: 1, High: 3, Medium: 0, Low: 0, Unkonwn: 0; Fixed: 2] <-- Choice 1) The beautiful work, you have done.
[Critcal: 1, High: 3, Medium: 0, Low: 0, Unkonwn: 0, Fixed: 2] <-- Choice 2) Only use all commas. For symmetry.
Summary: [Critcal: 1, High: 3, Medium: 0, Low: 0, Unkonwn: 0, Fixed: 2] <-- Choice 3) Add "Summary:"

@zhiburt
Copy link
Contributor Author

zhiburt commented Oct 5, 2022

So shall I make it Summary: [Critcal: 1, High: 3, Medium: 0, Low: 0, Unkonwn: 0, Fixed: 2] ?

@freedom-isnotanarchy
Copy link

freedom-isnotanarchy commented Oct 5, 2022

(1) Yes, personally, I prefer this format:

NAME                            INSTALLED       FIXED-IN  TYPE          VULNERABILITY        SEVERITY
geronimo-javamail_1.4_spec      1.7.1                     java-archive  CVE-2008-0732        Low
gson                            2.8.6           2.8.9     java-archive  GHSA-4jrv-ppp4-jm57  High
spring-core                     5.2.12.RELEASE            java-archive  CVE-2021-22118       High
spring-core                     5.3.22                    java-archive  CVE-2016-1000027     Critical
xmlsec                          2.1.4           2.1.7     java-archive  GHSA-j8wc-gxx9-82hx  High
Summary: [Critical: 1, High: 3, Medium: 0, Low: 0, Unknown: 0, Fixed: 2]

(2) But on the higher level, any "Summary" is good, to me.
I am just one person.
And thank you, for your effort.

@spiffcs
Copy link
Contributor

spiffcs commented Oct 6, 2022

Thanks @zhiburt for the PR! Also huge shoutout to all the feedback already thanks everyone.

I kicked off the CI jobs so we can get those running. I have a backlog of things I'm getting through but I'll take a look here when time permits to give a good review.

zhiburt and others added 2 commits October 6, 2022 08:35
Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com>
* main:
  Update grype bootstrap tools to latest versions. (anchore#947)
  chore: add more quality gate images (anchore#950)
  Add in-depth quality gate checks (anchore#949)
  Update Syft to v0.58.0 (anchore#941)
@spiffcs
Copy link
Contributor

spiffcs commented Oct 6, 2022

Thanks for keeping this in the status lines. Since it doesn't change the output of the table I think this is a great addition. Let me get the tests passing and lint fixed and I'll tag a second reviewer from the team.

^--^  ^------------^
|     |
|     +-> Summary in present tense.
|
+-------> Type: chore, docs, feat, fix, refactor, style, or test.

[optional body]

[optional footer(s)]

Signed-off-by: Christopher Phillips <christopher.phillips@anchore.com>
@spiffcs
Copy link
Contributor

spiffcs commented Oct 7, 2022

Lint's are fixed - I'll have more time to look at the panic later - if anyone else want's to give it a shot feel free to add a commit here for those tests

willyw0nka and others added 2 commits October 13, 2022 16:21
Signed-off-by: Albert Simon <simon.albert75@gmail.com>
@zhiburt
Copy link
Contributor Author

zhiburt commented Oct 17, 2022

@willyw0nka

CI need an approval

@willyw0nka
Copy link

I'm not a mantainer, so @spiffcs has to approve it and kick the CI

@zhiburt
Copy link
Contributor Author

zhiburt commented Oct 17, 2022

btw: thanks for your commit with the fix.

_, _ = io.WriteString(scanningLine, fmt.Sprintf(statusTitleTemplate+"%s", spin, title, auxInfo))

auxInfo2 := auxInfoFormat.Sprintf(
"[Critical: %d, High: %d, Medium: %d, Low: %d, Unknown: %d, Fixed: %d]",
Copy link
Contributor

Choose a reason for hiding this comment

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

A quick UX note: maybe we don't show the types that have 0 reported vulnerabilities so this line may be shorter?

Choose a reason for hiding this comment

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

In my personal thought: Always show all columns. Show all, even if they have "0 count".
Breaking symmetry, can be troublesome, in my opinion.

Copy link
Contributor

Choose a reason for hiding this comment

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

I didn't have a strong opinion about this, just a suggestion and fine as-is 👍

@willyw0nka
Copy link

It seems that Mac Acceptance tests failed due to a github out of service error (HTTP 503), can anyone trigger the action again?

@wagoodman
Copy link
Contributor

Hey folks -- I love the idea on outputting summarizing vulnerability result information directly in the TUI! I had a few comments.

  • From a visual perspective, a line that starts with a status icon (the checkbox / spinner) and a bolded title is meant to convey that there is a task that is occurring. The icon helps understand the status in a glanceable way and the bold title stands out as the tense-approriate verb (e.g. "parsing" vs "parsed"). The current "summary" title/status doesn't represent a task (some work done).
  • There isn't an indication that the summary line is only for the preceding task.
  • There is a lot of information trying to come across in a single line, which could get rather long (maybe not prohibitively so though).

With these comments in mind, I wanted to put forth an alternative (opinionated) output that addresses these points:

Screen Shot 2022-10-24 at 9 33 00 AM

This trades horizontal real estate with vertical real estate to show more information. The tree-like output is consistent with how we show related information in the log output and helps to indicate "this additional information belongs to the previous row".

What do folks think about this proposal? I tweaked the current branch to output this but didn't push anything yet until I got more feedback.

@kzantow
Copy link
Contributor

kzantow commented Oct 24, 2022

I, personally, like this much better @wagoodman -- attaching the information the previous scan item, and helps avoid as wide a line with this info 👍

Going this route, I might move the unknown to its own line, too?

@freedom-isnotanarchy
Copy link

Placeholder: Let me gather some thoughts, and come back to make a Comment, soon
Picture: A comparison of both proposals, placed on the same picture. For your consideration ...
grype_add_summary_pr_946

@gh-greg
Copy link

gh-greg commented Oct 26, 2022

Is this Feature/PR, related to this ?
Add the total types of vulnerabilities in Grype output
#877

@kzantow
Copy link
Contributor

kzantow commented Oct 26, 2022

@gh-greg yes (you can also see this in the description and the Development section on the right -- we try our best to link PRs to the issue they relate to)

@willyw0nka
Copy link

Hi, @wagoodman reasoning seems ok to me. How would the --only-fixed flag affect the summary?

@gh-greg
Copy link

gh-greg commented Oct 28, 2022

Regarding Printing Summary:
You ask, what is Twistlock / PrismaCloud 's' default CLI behaviour ?
To print this:

Vulnerabilities found for image MY_IMAGE: total - 114, critical - 1, high - 6, medium - 57, low - 50
[PRISMACLOUD] Found 1 relevant files
[PRISMACLOUD] Found 114 vulnerabilities in 1 images

Signed-off-by: Alex Goodman <alex.goodman@anchore.com>
@spiffcs
Copy link
Contributor

spiffcs commented Feb 10, 2023

Updating conflicts and getting this tested now

* main: (99 commits)
  chore(deps): bump actions/cache from 3.2.4 to 3.2.5 (anchore#1129)
  chore(deps): bump github.com/docker/docker (anchore#1128)
  Update Syft to v0.71.0 (anchore#1126)
  chore(deps): bump github/codeql-action from 2.2.1 to 2.2.3 (anchore#1125)
  Update grype bootstrap tools to latest versions. (anchore#1124)
  chore(deps): bump golang.org/x/term from 0.4.0 to 0.5.0 (anchore#1123)
  Update grype bootstrap tools to latest versions. (anchore#1122)
  Update grype bootstrap tools to latest versions. (anchore#1116)
  Update Syft to v0.70.0 (anchore#1117)
  chore(deps): bump github.com/docker/docker (anchore#1114)
  Update grype bootstrap tools to latest versions. (anchore#1112)
  Update Syft to v0.69.1 (anchore#1111)
  chore: prune cosign dependency for grype builds (anchore#1100)
  Update grype bootstrap tools to latest versions. (anchore#1108)
  Update Syft to v0.69.0 (anchore#1109)
  chore(deps): bump actions/cache from 3.2.3 to 3.2.4 (anchore#1107)
  chore: add new images to quality gate (anchore#1106)
  chore: bump yardstick for better quality gate filtering (anchore#1101)
  chore(deps): bump actions/cache from 3.0.11 to 3.2.3 (anchore#1096)
  chore(deps): bump github/codeql-action from 2.1.39 to 2.2.1 (anchore#1097)
  ...

Signed-off-by: Christopher Phillips <christopher.phillips@anchore.com>
Signed-off-by: Christopher Phillips <christopher.phillips@anchore.com>
@spiffcs
Copy link
Contributor

spiffcs commented Feb 10, 2023

Integration tests are failing with a panic - fixing this - then will post a screenshot of the final state - If we're happy with the new visualization we can merge 🥳

Signed-off-by: Christopher Phillips <christopher.phillips@anchore.com>
@spiffcs
Copy link
Contributor

spiffcs commented Feb 10, 2023

New output format (thanks @wagoodman ):
Screenshot 2023-02-10 at 4 35 46 PM

Vs old output:

Screenshot 2023-02-10 at 4 39 12 PM

@spiffcs
Copy link
Contributor

spiffcs commented Feb 10, 2023

There is one todo comment for debug logging - adding that now

Signed-off-by: Christopher Phillips <christopher.phillips@anchore.com>
Copy link
Contributor

@wagoodman wagoodman left a comment

Choose a reason for hiding this comment

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

The code I pushed was meant to be illustrative and was PoC-quality (and needed refactoring), my comments really are touching on that aspect.

  • vulnerabilitiesList and VulnerabilitiesCategories are enumerating the severities manually, however, it feels like it should have more of a collection on it. Something like BySeverity map[vulnerability.Severity]*progress.Manual (with one extra detail, the public facing VulnerabilitiesCategories should expose progress.Monitorable and not *progress.Manual). This way there shouldn't need to be refactors in this area if we add a severity (or remove one).
  • We should lean more heavily into using viulnerability.Severity and surrounding helpers (such as vulnerability.ParseSeveriry)
  • Are we leaving off negligable severity intentionally? if so, that should be a caller concern (in the log summary handler and tui handler) but the monitor code should still include those severity counts.
  • nit: naming for VulnerabilitiesCategories is awkward since both words are plural. Maybe something more like VulnerabilityCategories.

I've got more comments, but I think these could have enough impact to nullify them, I'll wait to hear back about these first.

@spiffcs
Copy link
Contributor

spiffcs commented Feb 13, 2023

The code I pushed was meant to be illustrative and was PoC-quality (and needed refactoring), my comments really are touching on that aspect.

  • vulnerabilitiesList and VulnerabilitiesCategories are enumerating the severities manually, however, it feels like it should have more of a collection on it. Something like BySeverity map[vulnerability.Severity]*progress.Manual (with one extra detail, the public facing VulnerabilitiesCategories should expose progress.Monitorable and not *progress.Manual). This way there shouldn't need to be refactors in this area if we add a severity (or remove one).

I'll get the above cleaned up where we have something like BySeverity map. I'll also expose progress.Monitorable

  • We should lean more heavily into using viulnerability.Severity and surrounding helpers (such as vulnerability.ParseSeveriry)

I'll see if there are are any other helpers we need and expose this further up so we can do something like VulnerabilitiesBySeverity which uses the by severity map we talked about above.

  • Are we leaving off negligable severity intentionally? if so, that should be a caller concern (in the log summary handler and tui handler) but the monitor code should still include those severity counts.

No - I'll add that in with the above comments

  • nit: naming for VulnerabilitiesCategories is awkward since both words are plural. Maybe something more like VulnerabilityCategories.

👍

I've got more comments, but I think these could have enough impact to nullify them, I'll wait to hear back about these first.

Cool! I'll address the above and we can do the small clean up after

wagoodman and others added 3 commits March 3, 2023 13:50
…vulnerabilities

Signed-off-by: Alex Goodman <alex.goodman@anchore.com>
Signed-off-by: Alex Goodman <alex.goodman@anchore.com>
Signed-off-by: Christopher Phillips <christopher.phillips@anchore.com>
Signed-off-by: Christopher Phillips <christopher.phillips@anchore.com>
@spiffcs spiffcs enabled auto-merge (squash) March 3, 2023 20:21
Signed-off-by: Christopher Phillips <christopher.phillips@anchore.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

Add the total types of vulnerabilities in Grype output
7 participants