Skip to content

Commit 150c7d5

Browse files
🎉 add file_path to SonarQube findings (#11078)
* 🎉 add file_path to SonarQube findings * fix unittest
1 parent 77c7d98 commit 150c7d5

2 files changed

Lines changed: 4 additions & 0 deletions

File tree

dojo/tools/sonarqube/sonarqube_restapi_json.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ def get_json_items(self, json_content, test, mode):
115115
component_version=component_version,
116116
cwe=cwe,
117117
cvssv3_score=cvss,
118+
file_path=component,
118119
tags=["vulnerability"],
119120
)
120121
vulnids = []
@@ -183,6 +184,7 @@ def get_json_items(self, json_content, test, mode):
183184
severity=self.severitytranslator(issue.get("severity")),
184185
static_finding=True,
185186
dynamic_finding=False,
187+
file_path=component,
186188
tags=["code_smell"],
187189
)
188190
items.append(item)
@@ -225,6 +227,7 @@ def get_json_items(self, json_content, test, mode):
225227
severity=self.severitytranslator(hotspot.get("vulnerabilityProbability")),
226228
static_finding=True,
227229
dynamic_finding=False,
230+
file_path=component,
228231
tags=["hotspot"],
229232
)
230233
items.append(item)

unittests/tools/test_sonarqube_parser.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -642,6 +642,7 @@ def test_parse_json_file_from_api_with_multiple_findings_zip(self):
642642
item = findings[0]
643643
self.assertEqual(str, type(item.description))
644644
self.assertEqual("OWASP:UsingComponentWithKnownVulnerability_fjioefjwoefijo", item.title)
645+
self.assertEqual("testapplication", item.file_path)
645646
self.assertEqual("Medium", item.severity)
646647
item = findings[3]
647648
self.assertEqual("OWASP:UsingComponentWithKnownVulnerability_fjioefjwo1123efijo", item.title)

0 commit comments

Comments
 (0)