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

fix(report): adjust for relative uri path #852

Merged
merged 2 commits into from
Dec 12, 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
2 changes: 1 addition & 1 deletion tests/test_code_report.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ def finalize(self) -> str:
],
"originalUriBaseIds": {
"ROOTPATH": {
"uri": "my_path"
"uri": "file:///my_path"
}
}
}
Expand Down
9 changes: 5 additions & 4 deletions universum/modules/code_report_collector.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,14 +68,15 @@ def _process_one_sarif_issue(self, issue, root_uri_base_paths, who) -> None:
uri = artifact_data.get('uri')
if not uri:
raise ValueError("Unexpected lack of uri tag")
path = urllib.parse.unquote(urllib.parse.urlparse(uri).path)
if artifact_data.get('uriBaseId'):
# means path is relative, need to make absolute
uri_base_id = artifact_data.get('uriBaseId', '')
root_base_path = root_uri_base_paths.get(uri_base_id, '')
if uri_base_id and not root_base_path:
base_uri = root_uri_base_paths.get(uri_base_id, '')
if uri_base_id and not base_uri:
raise ValueError(f"Unexpected lack of 'originalUriBaseIds' value for {uri_base_id}")
path = str(Path(root_base_path) / path)
else:
base_uri = ''
path = str(Path(urllib.parse.urlparse(urllib.parse.urljoin(base_uri, uri)).path))
region_data = location_data.get('region')
if not region_data:
continue # TODO: cover this case as comment to the file as a whole
Expand Down
Loading