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 severity column to vulnerability list #2262

Merged

Conversation

ZhangChen199102
Copy link
Contributor

@ZhangChen199102 ZhangChen199102 commented Jun 3, 2024

Issue: #2255

image

Copy link
Contributor

@andrewpollock andrewpollock left a comment

Choose a reason for hiding this comment

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

LGTMish (without seeing a preview), with some thoughts on handling multiple CVSS versions.

There's also the UX question of records that do not have any CVSS scores and how they would sort...

Comment on lines 140 to 142
{% for score in (vulnerability.severity_scores) %}
<li>{{ score }}</li>
{% endfor %}
Copy link
Contributor

Choose a reason for hiding this comment

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

I think it would be preferable to only output the highest available CVSS score, I.e. where CVSSv3 and CVSSv4 scores are provided, favour the v4 score.

@ZhangChen199102 ZhangChen199102 force-pushed the add-severity-column-to-vulnerability-list branch 3 times, most recently from 5c89f1c to 1f28fe8 Compare June 5, 2024 00:49
@ZhangChen199102 ZhangChen199102 marked this pull request as ready for review June 5, 2024 01:15
Copy link
Contributor

@andrewpollock andrewpollock left a comment

Choose a reason for hiding this comment

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

LGTM

@oliverchang
Copy link
Collaborator

LGTM

This adds more width to our page :/ Should we evaluate removing some other columns first?

@oliverchang
Copy link
Collaborator

e.g. fix available, and versions probably isn't that useful.

@hogo6002
Copy link
Contributor

Hey @ZhangChen199102 , thanks for implementing this feature! After discussing with the team, we have some thoughts on this change:

  • Instead of adding a new column for the severity score, we can just move it into the "Fix Available" column and making it more of an "Attributes" column. This can reduce the number of columns and allow us to easily add other tags in the future.
  • the current severity tag colour makes the text a bit hard to see. Maybe we can just use a white tag with black text, displaying the information like "Severity - 5.4 (MEDIUM)"?
  • the "Affected versions" listed here aren't adding much information and make the page looks a bit crowded. We can remove this column entirely from https://osv.dev/list (this can be done in a separate PR, and it would also automatically resolve Display the correct affected versions when filtering by ecosystem #2286)

@zahraaalizadeh zahraaalizadeh force-pushed the add-severity-column-to-vulnerability-list branch from 1f28fe8 to 9661b2c Compare June 19, 2024 05:46
Copy link
Contributor

@zahraaalizadeh zahraaalizadeh left a comment

Choose a reason for hiding this comment

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

Resolves: #2255, #2286

Screenshot 2024-06-19 at 3 10 51 PM

@another-rex
Copy link
Contributor

another-rex commented Jun 20, 2024

Looks really good! Can you also try keeping the color, but for the darker colors have the text color switch from black to white to make it easier to read? I'm not sure if we'll go with that, but I think it would be nice to compare. (Or choose different tag colors to maintain the contrast. )

@zahraaalizadeh
Copy link
Contributor

With the current colors, switching the text color to white instead of black actually fails the contrast ratio for accessibility (checked using this tool).

I’ve attached a sample output for reference, showing how the text looks with white colors on these backgrounds. Additionally, I’ve attached a photo demonstrating the appearance with black text on these colors.

As another alternative, I’ve used red-themed colors for high and critical severities to maintain the contrast.

Sample output with white text on colors( fails accessibility checks )
Screenshot 2024-06-20 at 4 34 33 PM

Black and white text on colors ( passes accessibility checks )
Screenshot 2024-06-20 at 4 41 52 PM

Red-themed colors for medium high and critical severities
Screenshot 2024-06-20 at 5 06 07 PM

@another-rex
Copy link
Contributor

I personally prefer the middle option, though can you try switching the orange (High) text color to white instead of black?

@hogo6002
Copy link
Contributor

I personally prefer the middle option, though can you try switching the orange (High) text color to white instead of black?

+1, I also think the middle one looks better. The third one has a pink colour, which is the same as our "no fix available" tag.

@zahraaalizadeh
Copy link
Contributor

zahraaalizadeh commented Jun 25, 2024

I personally prefer the middle option, though can you try switching the orange (High) text color to white instead of black?

@another-rex @hogo6002, unfortunately, using white on orange fails the accessibility contrast checks. the result is in demonstrated on pic1 in my previous comment.

Screenshot 2024-06-25 at 9 39 04 AM

@zahraaalizadeh
Copy link
Contributor

Here is the updated colours:
Screenshot 2024-06-25 at 4 39 25 PM

Copy link
Contributor

@another-rex another-rex left a comment

Choose a reason for hiding this comment

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

Styling LGTM! Just some minor comments.

@@ -22,6 +22,7 @@ requests = "==2.32.2"
grpcio-status = "==1.62.2"
gunicorn = "==22.0.0"
whitenoise = "6.5.0"
cvss = "*"
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you pin this version

@@ -537,6 +544,26 @@ md-icon-button.mdc-data-table__sort-icon-button {
&.fix-unavailable {
background: $osv-red-300;
}

&.severity-low {
background: #53aa33;
Copy link
Contributor

Choose a reason for hiding this comment

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

Set these values as (scss) variables, I think we might want to use them for each vulnerability page as well.

if detailed:
add_links(response)
add_source_info(bug, response)
return response


def add_cvss_score(bug):
"""Add severity score where possible."""
severity_score = {}
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: can this just be 3 variables?

This change refactors the existing functionality
of calculating the severity base score and rating,
to enable reusing it in vulnerability page.
@zahraaalizadeh zahraaalizadeh force-pushed the add-severity-column-to-vulnerability-list branch from 41de3b9 to 307c07d Compare June 26, 2024 01:09
"markers": "platform_python_implementation != 'PyPy'",
"version": "==0.22.0"
"markers": "python_version >= '3.7'",
"version": "==6.5.0"
Copy link
Contributor

Choose a reason for hiding this comment

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

The version of whitenoise specified in the Pipfile is 6.5.0, so it makes sense that pipenv lock downgrades the version from 6.7.0 to 6.5.0, as introduced by this commit.
However I'm unsure why it removed zstandard. I suspect it might be because I'm running it from a mac machine?

Copy link
Contributor

Choose a reason for hiding this comment

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

Hmm I'm guessing whitenoise added zstd support somewhere between 6.7.0 and 6.5.0. Since it looks like we are already using whitenoise 6.7.0, can you update our pipfile for whitenoise to ==6.7.0 (The only reason renovatebot didn't do it is because there's currently a dependency conflict in the Google cloud dependencies. )

Copy link
Contributor

Choose a reason for hiding this comment

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

Re zstandard, looking at pipenv graph it's a dependancy for flask-compress version 1.15 as the version in Pipfile is specified as 1.13 it's been removed.

Copy link
Contributor

Choose a reason for hiding this comment

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

@another-rex Should I upgradeflask-compress from 1.13 to 1.15 too?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, I think that'll be good

Comment on lines +300 to +302
def calculate_severity_details(
severity: dict) -> tuple[float | None, str | None]:
"""Calculate score and rating of severity"""
Copy link
Contributor

Choose a reason for hiding this comment

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

I cherry-picked this commit from my other branch which adds link to cvss calculator.
FYI - Once this PR was merged, I'll resolve the potential conflicts and open a seperate PR for the mentioned issue.

Copy link
Contributor

@hogo6002 hogo6002 left a comment

Choose a reason for hiding this comment

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

Looks really nice! Thanks Zahra!

@another-rex another-rex merged commit 617416b into google:master Jun 27, 2024
11 checks passed
@G-Rath G-Rath deleted the add-severity-column-to-vulnerability-list branch August 20, 2024 19:24
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.

6 participants