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

Colorize severity in table output #225

Closed
sprt opened this issue Dec 17, 2020 · 3 comments · Fixed by #1284
Closed

Colorize severity in table output #225

sprt opened this issue Dec 17, 2020 · 3 comments · Fixed by #1284
Labels
enhancement New feature or request good-first-issue Good for newcomers I/O Describes bug or enhancement around application input or output

Comments

@sprt
Copy link

sprt commented Dec 17, 2020

It would be nice to display each severity label in its own color in the table output. Trivy does that well and it makes visually parsing the output just a little bit faster, with just a quick glance. I'd suggest something like low = blue, medium = yellow, high = red, critical = bold red. Happy to contribute a PR if you think this sounds interesting!

@sprt sprt added the enhancement New feature or request label Dec 17, 2020
@luhring
Copy link
Contributor

luhring commented Jan 25, 2021

Hey @sprt, this sounds cool! This is certainly something we're open to. Our main considerations are that the colors are a) helpful (like you mention) and b) easily readable, even on a variety of terminal configurations (e.g. some folks prefer dark backgrounds, some prefer light backgrounds, etc.).

As for colors themselves, I think we'll have to see how it looks in context, but I'm sure this won't be a hard problem. One idea is to be consistent with our grype VS Code extension, specifically the "vulnerability report" view (whose code is here: https://github.com/anchore/grype-vscode/blob/main/src/ui/react-components/FindingsList.tsx#L148-L162).

If you want to take a stab at this, that'd be very helpful! I'd be more than happy to serve as a resource and walk through how we've designed the output mechanism.

@wagoodman wagoodman added the I/O Describes bug or enhancement around application input or output label Aug 23, 2021
@spiffcs spiffcs added this to OSS Jun 1, 2022
@spiffcs spiffcs moved this to Triage (Comments or Progress Made) in OSS Jun 1, 2022
@spiffcs spiffcs added the good-first-issue Good for newcomers label Jul 21, 2022
@freedom-isnotanarchy
Copy link

Regarding ((display each severity label in its own color in the table output.)) :
(1) Might this also involve, implementing some new --no-color flag ?
(2) I would be in the audience, that fears that this enhancement, might get in the way of some/many use cases, that this "default table" output, be easy to display and manipulate, as the simplest ASCII-7 characters.

shanedell added a commit to shanedell/grype that referenced this issue May 9, 2023
- Create flag "--no-color" to allow disabling the color. By default its enabled.
- When "--no-color" not specified highlight severity in its color:
  - Critical -> Bold Red
  - High -> Red
  - Medium -> Yellow
  - Low -> Green
  - Negligible -> Blue
  - Note: Golang doesn't have all colors available. Also, doesn't seem to be able use hex codes properly.

Closes anchore#225

Signed-off-by: Shane Dell <shanedell100@gmail.com>
shanedell added a commit to shanedell/grype that referenced this issue Jun 12, 2023
- Create flag "--no-color" to allow disabling the color. By default its enabled.
- When "--no-color" not specified highlight severity in its color:
  - Critical -> Bold Red
  - High -> Red
  - Medium -> Yellow
  - Low -> Green
  - Negligible -> Blue
  - Note: Golang doesn't have all colors available. Also, doesn't seem to be able use hex codes properly.

Closes anchore#225

Signed-off-by: Shane Dell <shanedell100@gmail.com>
shanedell added a commit to shanedell/grype that referenced this issue Jun 12, 2023
- Create flag "--no-color" to allow disabling the color. By default its enabled.
- When "--no-color" not specified highlight severity in its color:
  - Critical -> Bold Red
  - High -> Red
  - Medium -> Yellow
  - Low -> Green
  - Negligible -> Blue
  - Note: Golang doesn't have all colors available. Also, doesn't seem to be able use hex codes properly.
- Add termenv to check if the terminal color profile supports colored output. If it doesn't default to noColor

Closes anchore#225

Signed-off-by: Shane Dell <shanedell100@gmail.com>
@tgerla tgerla removed the status in OSS Oct 6, 2023
@tgerla tgerla moved this to In Progress in OSS Oct 26, 2023
@wagoodman
Copy link
Contributor

The PR has been updated to respond to the NO_COLOR and CLICOLOR_FORCE environment variables #1284 (comment)

wagoodman added a commit that referenced this issue Oct 30, 2023
* Colorize severity in table output

- Create flag "--no-color" to allow disabling the color. By default its enabled.
- When "--no-color" not specified highlight severity in its color:
  - Critical -> Bold Red
  - High -> Red
  - Medium -> Yellow
  - Low -> Green
  - Negligible -> Blue
  - Note: Golang doesn't have all colors available. Also, doesn't seem to be able use hex codes properly.
- Add termenv to check if the terminal color profile supports colored output. If it doesn't default to noColor

Closes #225

Signed-off-by: Shane Dell <shanedell100@gmail.com>

* fix: adopt EnvColorProfile to support NO_COLOR

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

* fix linting and update snapshots

Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com>

---------

Signed-off-by: Shane Dell <shanedell100@gmail.com>
Signed-off-by: Christopher Phillips <christopher.phillips@anchore.com>
Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com>
Co-authored-by: Christopher Phillips <christopher.phillips@anchore.com>
Co-authored-by: Alex Goodman <wagoodman@users.noreply.github.com>
@github-project-automation github-project-automation bot moved this from In Progress to Done in OSS Oct 30, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good-first-issue Good for newcomers I/O Describes bug or enhancement around application input or output
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

5 participants