Skip to content

Conversation

@sbs2001
Copy link
Collaborator

@sbs2001 sbs2001 commented Nov 29, 2020

Implementation of #157 (comment)

Fixes #157

  • Add data structures to store severity scores

@sbs2001 sbs2001 requested a review from pombredanne November 29, 2020 10:42
@sbs2001 sbs2001 changed the title Store severity scores [WIP]Store severity scores Nov 29, 2020
Copy link
Member

@pombredanne pombredanne left a comment

Choose a reason for hiding this comment

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

Thanks!
See my comments in line for your consideration.

Copy link
Member

@pombredanne pombredanne left a comment

Choose a reason for hiding this comment

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

See my suggested changes for the models.

@pombredanne
Copy link
Member

@sbs2001 you wrote:

I thought about #290 (comment) , and I think storing the ScoringSystems in the db would be a better approach

It can but then how scoring systems will we have? At most a couple per data sources, and in reality only a handful. And this is purely static data, and not really usable as data for some query except for the identifier so I am not sure this needs the added ceremony and complexity when stored in the DB. (e.g. you then need fixtures to bootstrap etc.). I see this instead as an enhanced but still very small list of value choices for a single field.

@sbs2001 sbs2001 force-pushed the store_severity branch 3 times, most recently from 0118d9e to b24c934 Compare December 24, 2020 09:50
@sbs2001 sbs2001 changed the title [WIP]Store severity scores Store severity scores Dec 24, 2020
@sbs2001 sbs2001 force-pushed the store_severity branch 3 times, most recently from d6b2bee to 9a72e52 Compare January 24, 2021 13:03
@sbs2001 sbs2001 requested a review from pombredanne January 26, 2021 04:20
Copy link
Member

@pombredanne pombredanne left a comment

Choose a reason for hiding this comment

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

Thanks!
See my comments inline

sbs2001 added a commit to sbs2001/vulnerablecode that referenced this pull request Jan 31, 2021
* Correct typo in severity_systems.py
* Use typo for scoring fields instead of list
  in models.py

Signed-off-by: Shivam Sandbhor <shivam.sandbhor@gmail.com>
sbs2001 added a commit to sbs2001/vulnerablecode that referenced this pull request Jan 31, 2021
* Correct typo in severity_systems.py

* Use typo for scoring fields instead of list
  in models.py

* Handle absence of bugzilla and RHSA  better in redhat.py

Signed-off-by: Shivam Sandbhor <shivam.sandbhor@gmail.com>
Copy link
Member

@pombredanne pombredanne left a comment

Choose a reason for hiding this comment

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

Almost there ! see my comments inline for your consideration.

 A VulnerabilitySeverity models is added in models.py to
 store severity of vulnerability.

Signed-off-by: Shivam Sandbhor <shivam.sandbhor@gmail.com>
 A dataclass `VulnerabilitySeverity` is added to enable to
 transport of severity scores.

 The logic in importer_runner.py is modified to store, update
 severity scores and link it to reference and vulnerability

Signed-off-by: Shivam Sandbhor <shivam.sandbhor@gmail.com>
Signed-off-by: Shivam Sandbhor <shivam.sandbhor@gmail.com>
Signed-off-by: Shivam Sandbhor <shivam.sandbhor@gmail.com>
Signed-off-by: Shivam Sandbhor <shivam.sandbhor@gmail.com>
Signed-off-by: Shivam Sandbhor <shivam.sandbhor@gmail.com>
Signed-off-by: Shivam Sandbhor <shivam.sandbhor@gmail.com>
Signed-off-by: Shivam Sandbhor <shivam.sandbhor@gmail.com>
Signed-off-by: Shivam Sandbhor <shivam.sandbhor@gmail.com>
Signed-off-by: Shivam Sandbhor <shivam.sandbhor@gmail.com>
Signed-off-by: Shivam Sandbhor <shivam.sandbhor@gmail.com>
Signed-off-by: Shivam Sandbhor <shivam.sandbhor@gmail.com>
Signed-off-by: Shivam Sandbhor <shivam.sandbhor@gmail.com>
Signed-off-by: Shivam Sandbhor <shivam.sandbhor@gmail.com>
Signed-off-by: Shivam Sandbhor <shivam.sandbhor@gmail.com>
Signed-off-by: Shivam Sandbhor <shivam.sandbhor@gmail.com>
Signed-off-by: Shivam Sandbhor <shivam.sandbhor@gmail.com>
scoring_system_identifier is changed to scoring_system

Signed-off-by: Shivam Sandbhor <shivam.sandbhor@gmail.com>
* Correct typo in severity_systems.py

* Use typo for scoring fields instead of list
  in models.py

* Handle absence of bugzilla and RHSA  better in redhat.py

Signed-off-by: Shivam Sandbhor <shivam.sandbhor@gmail.com>
Signed-off-by: Shivam Sandbhor <shivam.sandbhor@gmail.com>
Signed-off-by: Shivam Sandbhor <shivam.sandbhor@gmail.com>
bugzilla = advisory_data.get("bugzilla")
if bugzilla:
url = "https://bugzilla.redhat.com/show_bug.cgi?id={}".format(bugzilla)
bugzilla_data = requests.get(f"https://bugzilla.redhat.com/rest/bug/{bugzilla}").json()
Copy link
Member

Choose a reason for hiding this comment

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

Just as a side note, this is the kind of JSON we would likely need to store forever as back auditable evidence when we will do this later ... which likely calls for a central place where we fetch things from

max_length=50,
choices=scoring_system_choices,
help_text="Identifier for the scoring system used. Available choices are: {} ".format(
", ".join(
Copy link
Member

Choose a reason for hiding this comment

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

For readability, an intermediate variable would be better for this

namespace="redhat",
name="bash",
version="4.1.2-48.el6",
qualifiers=OrderedDict(),
Copy link
Member

Choose a reason for hiding this comment

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

Feel free to remove OrderedDict from the whole codebase BTW since the dicts are always ordered now.

Copy link
Member

@pombredanne pombredanne left a comment

Choose a reason for hiding this comment

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

LGTM! let's merge.

@sbs2001 sbs2001 merged commit 1d7b64e into aboutcode-org:main Feb 9, 2021
sbs2001 added a commit to sbs2001/vulnerablecode that referenced this pull request Feb 12, 2021
* Correct typo in severity_systems.py

* Use typo for scoring fields instead of list
  in models.py

* Handle absence of bugzilla and RHSA  better in redhat.py

Signed-off-by: Shivam Sandbhor <shivam.sandbhor@gmail.com>
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.

Change database schema to accommodate different types of severity indicators

2 participants