Skip to content

Commit

Permalink
[bugfix] Whispers 2.2 report importing support (#8891)
Browse files Browse the repository at this point in the history
* Whispers 2.2 support

* Run tests
  • Loading branch information
adeptex authored Oct 30, 2023
1 parent 4ba6859 commit 577dad0
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 0 deletions.
7 changes: 7 additions & 0 deletions dojo/tools/whispers/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,18 @@ class WhispersParser(object):
"""

SEVERITY_MAP = {
# Whispers 2.1
"BLOCKER": "Critical",
"CRITICAL": "High",
"MAJOR": "Medium",
"MINOR": "Low",
"INFO": "Info",
# Whispers 2.2
"Critical": "Critical",
"High": "High",
"Medium": "Medium",
"Low": "Low",
"Info": "Info",
}

@staticmethod
Expand Down
1 change: 1 addition & 0 deletions unittests/scans/whispers/whispers_one_vul_v2.2.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[{"key": "pip password", "value": "hardcoded", "file": "src/pip.conf", "line": 2, "rule_id": "pip", "message": "pip.conf Password", "severity": "High"}]
14 changes: 14 additions & 0 deletions unittests/tools/test_whispers_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,20 @@

class TestWhispersParser(TestCase):

def test_whispers_parser_severity_map(self):
fixtures = [
"unittests/scans/whispers/whispers_one_vul.json", # v2.1 format
"unittests/scans/whispers/whispers_one_vul_v2.2.json", # v2.2 format
]
expected_severity = "High"

for fixture in fixtures:
testfile = open(fixture)
parser = WhispersParser()
findings = parser.get_findings(testfile, Test())
testfile.close()
self.assertEqual(expected_severity, findings[0].severity)

def test_whispers_parser_with_no_vuln_has_no_findings(self):
testfile = open("unittests/scans/whispers/whispers_zero_vul.json")
parser = WhispersParser()
Expand Down

0 comments on commit 577dad0

Please sign in to comment.