-
Notifications
You must be signed in to change notification settings - Fork 203
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix cargo test ( add ref type ) Fix merge conflict Add api test for epss Keep the EPSS score separate from the severity score range Add epss tab Add epss to severity scoring Add published_at date to the Vulnerability score model. Add EPSS importer Add EPSS model Add EPSS UI Add EPSS to api Fix api test Signed-off-by: ziadhany <ziadhany2016@gmail.com>
- Loading branch information
Showing
12 changed files
with
905 additions
and
62 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
# | ||
# Copyright (c) nexB Inc. and others. All rights reserved. | ||
# VulnerableCode is a trademark of nexB Inc. | ||
# SPDX-License-Identifier: Apache-2.0 | ||
# See http://www.apache.org/licenses/LICENSE-2.0 for the license text. | ||
# See https://github.com/nexB/vulnerablecode for support or download. | ||
# See https://aboutcode.org for more information about nexB OSS projects. | ||
# | ||
import csv | ||
import gzip | ||
import logging | ||
import urllib.request | ||
from datetime import datetime | ||
from typing import Iterable | ||
|
||
from vulnerabilities import severity_systems | ||
from vulnerabilities.importer import AdvisoryData | ||
from vulnerabilities.importer import Importer | ||
from vulnerabilities.importer import Reference | ||
from vulnerabilities.importer import VulnerabilitySeverity | ||
|
||
logger = logging.getLogger(__name__) | ||
|
||
|
||
class EPSSImporter(Importer): | ||
"""Exploit Prediction Scoring System (EPSS) Importer""" | ||
|
||
advisory_url = "https://epss.cyentia.com/epss_scores-current.csv.gz" | ||
spdx_license_expression = "unknown" | ||
importer_name = "EPSS Importer" | ||
|
||
def advisory_data(self) -> Iterable[AdvisoryData]: | ||
response = urllib.request.urlopen(self.advisory_url) | ||
with gzip.open(response, "rb") as f: | ||
lines = [l.decode("utf-8") for l in f.readlines()] | ||
|
||
epss_reader = csv.reader(lines) | ||
model_version, score_date = next( | ||
epss_reader | ||
) # score_date='score_date:2024-05-19T00:00:00+0000' | ||
published_at = datetime.strptime(score_date[11::], "%Y-%m-%dT%H:%M:%S%z") | ||
|
||
next(epss_reader) # skip the header row | ||
for epss_row in epss_reader: | ||
cve, score, percentile = epss_row | ||
|
||
if not cve or not score or not percentile: | ||
logger.error(f"Invalid epss row: {epss_row}") | ||
continue | ||
|
||
severity = VulnerabilitySeverity( | ||
system=severity_systems.EPSS, | ||
value=score, | ||
scoring_elements=percentile, | ||
published_at=published_at, | ||
) | ||
|
||
references = Reference( | ||
url=f"https://api.first.org/data/v1/epss?cve={cve}", | ||
severities=[severity], | ||
) | ||
|
||
yield AdvisoryData( | ||
aliases=[cve], | ||
references=[references], | ||
url=self.advisory_url, | ||
) |
43 changes: 43 additions & 0 deletions
43
vulnerabilities/migrations/0059_vulnerabilityseverity_published_at_and_more.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
# Generated by Django 4.1.13 on 2024-07-22 15:39 | ||
|
||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
("vulnerabilities", "0058_vulnerabilityreference_reference_type"), | ||
] | ||
|
||
operations = [ | ||
migrations.AddField( | ||
model_name="vulnerabilityseverity", | ||
name="published_at", | ||
field=models.DateTimeField( | ||
blank=True, | ||
help_text="UTC Date of publication of the vulnerability severity", | ||
null=True, | ||
), | ||
), | ||
migrations.AlterField( | ||
model_name="vulnerabilityseverity", | ||
name="scoring_system", | ||
field=models.CharField( | ||
choices=[ | ||
("cvssv2", "CVSSv2 Base Score"), | ||
("cvssv3", "CVSSv3 Base Score"), | ||
("cvssv3.1", "CVSSv3.1 Base Score"), | ||
("rhbs", "RedHat Bugzilla severity"), | ||
("rhas", "RedHat Aggregate severity"), | ||
("archlinux", "Archlinux Vulnerability Group Severity"), | ||
("cvssv3.1_qr", "CVSSv3.1 Qualitative Severity Rating"), | ||
("generic_textual", "Generic textual severity rating"), | ||
("apache_httpd", "Apache Httpd Severity"), | ||
("apache_tomcat", "Apache Tomcat Severity"), | ||
("epss", "Exploit Prediction Scoring System"), | ||
], | ||
help_text="Identifier for the scoring system used. Available choices are: cvssv2: CVSSv2 Base Score,\ncvssv3: CVSSv3 Base Score,\ncvssv3.1: CVSSv3.1 Base Score,\nrhbs: RedHat Bugzilla severity,\nrhas: RedHat Aggregate severity,\narchlinux: Archlinux Vulnerability Group Severity,\ncvssv3.1_qr: CVSSv3.1 Qualitative Severity Rating,\ngeneric_textual: Generic textual severity rating,\napache_httpd: Apache Httpd Severity,\napache_tomcat: Apache Tomcat Severity,\nepss: Exploit Prediction Scoring System ", | ||
max_length=50, | ||
), | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.