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 EPSS score and percentile to generic csv parser #11449

Merged
merged 3 commits into from
Dec 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ These attributes are supported for CSV:
- Date: Date of the finding in mm/dd/yyyy format.
- Title: Title of the finding
- CweId: Cwe identifier, must be an integer value.
- epss_score: The probability of exploitation in the next 30 days, must be a float value between 0 and 1.0.
- epss_percentile: The proportion of all scored vulnerabilities with the same or a lower EPSS score, must be a float value between 0 and 1.0.
- Url: Url associated with the finding.
- Severity: Severity of the finding. Must be one of Info, Low, Medium, High, or Critical.
- Description: Description of the finding. Can be multiple lines if enclosed in double quotes.
Expand Down
6 changes: 6 additions & 0 deletions dojo/tools/generic/csv_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,12 @@ def _get_findings_csv(self, filename):
if "CweId" in row:
finding.cwe = int(row["CweId"])

if "epss_score" in row:
finding.epss_score = float(row["epss_score"])

if "epss_percentile" in row:
finding.epss_percentile = float(row["epss_percentile"])

if "CVSSV3" in row:
cvss_objects = cvss_parser.parse_cvss_from_text(row["CVSSV3"])
if len(cvss_objects) > 0:
Expand Down
2 changes: 2 additions & 0 deletions unittests/scans/generic/generic_csv_with_epss.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Date,Title,CweId,epss_score,epss_percentile, Url,Severity,Description,Mitigation,Impact,References,Active,Verified,FalsePositive,Duplicate
01/30/2018,"Server leaks inodes via ETags, header found with file /, fields: 0xW/109b 0xpqG8TolgxCnpM/7cGOOI0GRS+rc ",0,.00042,.23474,https://192.168.1.1/,Low,"Server leaks inodes via ETags, header found with file /, fields: 0xW/109b 0xpqG8TolgxCnpM/7cGOOI0GRS+rc ",,,,False,False,False,False
9 changes: 9 additions & 0 deletions unittests/tools/test_generic_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -649,3 +649,12 @@ def test_parse_json_invalid_finding(self):
with self.assertRaisesMessage(ValueError,
"Not allowed fields are present: ['invalid_field', 'last_status_update']"):
parser.get_findings(file, Test())

def test_parse_csv_with_epss(self):
with open("unittests/scans/generic/generic_csv_with_epss.csv", encoding="utf-8") as file:
parser = GenericParser()
findings = parser.get_findings(file, self.test)
self.assertEqual(1, len(findings))
finding = findings[0]
self.assertEqual(.00042, finding.epss_score)
self.assertEqual(.23474, finding.epss_percentile)
Loading