Skip to content

Commit eaaf8ad

Browse files
authored
Merge pull request #13256 from Jino-T/bugfix
Added Line Field for SonarQube Scan and SonarQube Scan Detailed Scan Types
2 parents 22e7047 + c7e745f commit eaaf8ad

1 file changed

Lines changed: 12 additions & 6 deletions

File tree

dojo/tools/sonarqube/sonarqube_restapi_json.py

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ def get_json_items(self, json_content, test, mode):
1313
rule = issue.get("rule")
1414
component = issue.get("component")
1515
project = issue.get("project")
16-
line = str(issue.get("line"))
16+
line = issue.get("line")
1717
textRange = issue.get("textRange", {})
1818
flows = issue.get("flows", [])
1919
status = issue.get("status")
@@ -28,7 +28,7 @@ def get_json_items(self, json_content, test, mode):
2828
description += "**rule:** " + rule + "\n"
2929
description += "**component:** " + component + "\n"
3030
description += "**project:** " + project + "\n"
31-
description += "**line:** " + line + "\n"
31+
description += "**line:** " + str(line) + "\n"
3232
if bool(textRange):
3333
res = [item + ": " + str(textRange[item]) for item in textRange]
3434
description += "**textRange:** " + ", ".join(res) + "\n"
@@ -49,6 +49,7 @@ def get_json_items(self, json_content, test, mode):
4949
static_finding=True,
5050
dynamic_finding=False,
5151
tags=["bug"],
52+
line=line,
5253
)
5354
elif issue.get("type") == "VULNERABILITY":
5455
key = issue.get("key")
@@ -58,6 +59,7 @@ def get_json_items(self, json_content, test, mode):
5859
flows = issue.get("flows", [])
5960
status = issue.get("status")
6061
message = issue.get("message")
62+
line = issue.get("line")
6163
cwe = None
6264
if "Category: CWE-" in message:
6365
cwe_pattern = r"Category: CWE-\d{1,5}"
@@ -91,6 +93,7 @@ def get_json_items(self, json_content, test, mode):
9193
description += "**rule:** " + rule + "\n"
9294
description += "**component:** " + component + "\n"
9395
description += "**project:** " + project + "\n"
96+
description += "**line:** " + str(line) + "\n"
9497
if flows != []:
9598
description += "**flows:** " + str(flows) + "\n"
9699
description += "**status:** " + status + "\n"
@@ -115,6 +118,7 @@ def get_json_items(self, json_content, test, mode):
115118
cvssv3_score=cvss,
116119
file_path=component,
117120
tags=["vulnerability"],
121+
line=line,
118122
)
119123
vulnids = []
120124
if "Reference: CVE" in message:
@@ -141,7 +145,7 @@ def get_json_items(self, json_content, test, mode):
141145
rule = issue.get("rule")
142146
component = issue.get("component")
143147
project = issue.get("project")
144-
line = str(issue.get("line"))
148+
line = issue.get("line")
145149
textRange = issue.get("textRange", {})
146150
flows = issue.get("flows", [])
147151
status = issue.get("status")
@@ -154,7 +158,7 @@ def get_json_items(self, json_content, test, mode):
154158
description += "**rule:** " + rule + "\n"
155159
description += "**component:** " + component + "\n"
156160
description += "**project:** " + project + "\n"
157-
description += "**line:** " + line + "\n"
161+
description += "**line:** " + str(line) + "\n"
158162
if bool(textRange):
159163
res = []
160164
for item in textRange:
@@ -180,6 +184,7 @@ def get_json_items(self, json_content, test, mode):
180184
dynamic_finding=False,
181185
file_path=component,
182186
tags=["code_smell"],
187+
line=line,
183188
)
184189
items.append(item)
185190
if json_content.get("hotspots"):
@@ -189,7 +194,7 @@ def get_json_items(self, json_content, test, mode):
189194
project = hotspot.get("project")
190195
securityCategory = hotspot.get("securityCategory")
191196
status = hotspot.get("status")
192-
line = str(hotspot.get("line"))
197+
line = hotspot.get("line")
193198
message = hotspot.get("message")
194199
textRange = hotspot.get("textRange", {})
195200
flows = hotspot.get("flows", [])
@@ -201,7 +206,7 @@ def get_json_items(self, json_content, test, mode):
201206
description += "**project:** " + project + "\n"
202207
description += "**securityCategory:** " + securityCategory + "\n"
203208
description += "**status:** " + status + "\n"
204-
description += "**line:** " + line + "\n"
209+
description += "**line:** " + str(line) + "\n"
205210
description += "**message:** " + message + "\n"
206211
if bool(textRange):
207212
res = []
@@ -223,6 +228,7 @@ def get_json_items(self, json_content, test, mode):
223228
dynamic_finding=False,
224229
file_path=component,
225230
tags=["hotspot"],
231+
line=line,
226232
)
227233
items.append(item)
228234
return items

0 commit comments

Comments
 (0)