Skip to content

Commit

Permalink
URL parsing moved out of the loops; the URI field unquoted before use
Browse files Browse the repository at this point in the history
  • Loading branch information
lyubomyrferents committed Nov 20, 2023
1 parent eb1c3da commit 2196d6d
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions universum/modules/code_report_collector.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@ def _report_as_sarif_json(self, report) -> int:
for run in report.get('runs', []):
analyzer_data: Dict[str, str] = run.get('tool').get('driver') # non-optional per definition
who: str = f"{analyzer_data.get('name')} [{analyzer_data.get('version', '?')}]"
root_uri_base_ids: Dict[str, str] = {uri_base_id: root_path['uri'] for uri_base_id, root_path in
run.get('originalUriBaseIds', {}).items()}
root_uri_base_paths: Dict[str, str] = {uri_base_id: urllib.parse.urlparse(root_path['uri']).path for
uri_base_id, root_path in run.get('originalUriBaseIds', {}).items()}
for issue in run.get('results', []):
issue_count += 1
what: str = issue.get('message')
Expand All @@ -81,10 +81,10 @@ def _report_as_sarif_json(self, report) -> int:
if not uri:
raise ValueError("Unexpected lack of uri tag")
uri_base_id = artifact_data.get('uriBaseId', '')
root_base_path: str = urllib.parse.urlparse(root_uri_base_ids.get(uri_base_id)).path
root_base_path = root_uri_base_paths.get(uri_base_id, '')
if uri_base_id and not root_base_path:
raise ValueError(f"Unexpected lack of 'originalUriBaseIds' value for {uri_base_id}")
path = str(Path(root_base_path, uri))
path = str(Path(root_base_path, urllib.parse.unquote(uri)))
else:
path = urllib.parse.unquote(artifact_data.get('uri', ''))
region_data = location_data.get('region')
Expand Down

0 comments on commit 2196d6d

Please sign in to comment.