Skip to content

Store severity scores - #290

Merged
sbs2001 merged 22 commits into
aboutcode-org:mainfrom
sbs2001:store_severity
Feb 9, 2021
Merged

Store severity scores #290
sbs2001 merged 22 commits into
aboutcode-org:mainfrom
sbs2001:store_severity

Conversation

@sbs2001

@sbs2001sbs2001 commented Nov 29, 2020

Copy link
Copy Markdown
Collaborator

Implementation of #157 (comment)

Fixes#157

  • Add data structures to store severity scores

@sbs2001sbs2001 changed the title Store severity scores [WIP]Store severity scores Nov 29, 2020

@pombredannepombredanne left a comment

Copy link
Copy Markdown
Member

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.

Comment threadvulnerabilities/data_source.py
Comment threadvulnerabilities/importers/nvd.py
Comment threadvulnerabilities/importers/redhat.py Outdated
Comment threadvulnerabilities/importers/redhat.py
Comment threadvulnerabilities/importers/redhat.py Outdated
Comment threadvulnerabilities/importers/redhat.py Outdated
Comment threadvulnerabilities/models.py
Comment threadvulnerabilities/tests/test_nvd.py Outdated
Comment threadvulnerabilities/tests/test_nvd.py Outdated
Comment threadvulnerabilities/tests/test_nvd.py Outdated
Comment threadvulnerabilities/.vscode/settings.json Outdated
Comment threadvulnerabilities/data_source.py Outdated
Comment threadvulnerabilities/data_source.py

@pombredannepombredanne left a comment

Copy link
Copy Markdown
Member

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.

Comment threadvulnerabilities/models.py Outdated
@pombredanne

Copy link
Copy Markdown
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
sbs2001force-pushed the store_severity branch 3 times, most recently from 0118d9e to b24c934CompareDecember 24, 2020 09:50
@sbs2001sbs2001 changed the title [WIP]Store severity scores Store severity scores Dec 24, 2020
@sbs2001
sbs2001force-pushed the store_severity branch 3 times, most recently from d6b2bee to 9a72e52CompareJanuary 24, 2021 13:03

@pombredannepombredanne left a comment

Copy link
Copy Markdown
Member

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

Comment threadvulnerabilities/importers/redhat.py
Comment threadvulnerabilities/importers/redhat.py Outdated
Comment threadvulnerabilities/importers/redhat.py Outdated
Comment threadvulnerabilities/migrations/0002_vulnerabilityseverityscore.py Outdated
Comment threadvulnerabilities/models.py Outdated
Comment threadvulnerabilities/severity_systems.py Outdated
Comment threadvulnerabilities/severity_systems.py Outdated
Comment threadvulnerabilities/tests/test_nvd.py Outdated
Comment threadvulnerabilities/tests/test_redhat_importer.py Outdated
Comment threadvulnerabilities/tests/test_redhat_importer.py Outdated
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>
Comment threadvulnerabilities/import_runner.py

@pombredannepombredanne left a comment

Copy link
Copy Markdown
Member

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.

Comment threadvulnerabilities/importers/nvd.py
Comment threadvulnerabilities/tests/test_redhat_importer.py Outdated
Comment threadvulnerabilities/severity_systems.py Outdated
Comment threadvulnerabilities/importers/redhat.py Outdated
Comment threadvulnerabilities/models.py Outdated
Comment threadvulnerabilities/tests/test_nvd.py Outdated
Comment threadvulnerabilities/tests/test_redhat_importer.py
 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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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.

@pombredannepombredanne left a comment

Copy link
Copy Markdown
Member

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:mainFeb 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 freeto 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

@sbs2001@pombredanne