From a9eaedc2d02d9fdcbbd8062ee0c0b0b3fbdb1717 Mon Sep 17 00:00:00 2001 From: Joe Stevens Date: Fri, 29 Nov 2024 09:41:31 -0500 Subject: [PATCH] [feat][report-converter] Add support for bug path positions (for arrows) sarif files contain all the information required to construct the arrows. This commit extracts that information and uses it in the report. --- .../report/parser/sarif.py | 20 +++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/tools/report-converter/codechecker_report_converter/report/parser/sarif.py b/tools/report-converter/codechecker_report_converter/report/parser/sarif.py index 856bf544cf..f29462fc4b 100644 --- a/tools/report-converter/codechecker_report_converter/report/parser/sarif.py +++ b/tools/report-converter/codechecker_report_converter/report/parser/sarif.py @@ -143,26 +143,30 @@ def _process_code_flows( thread_flow_info = ThreadFlowInfo() - # TODO: Currently, we only collect bug path events. - for code_flow in result.get("codeFlows", []): for thread_flow in code_flow.get("threadFlows", []): for location_data in thread_flow["locations"]: - # There are a lot data stored alongside the location worth + if "location" not in location_data: + continue + + # There is a lot data stored alongside the location worth # parsing, but we only need the actual location now. location = location_data["location"] + file, rng = self._process_location(location) + if not (file and rng): + continue + + thread_flow_info.bug_path_positions.append( + BugPathPosition(file, rng) + ) + if "message" not in location: - # TODO: This might be a bug path position (for arrows). continue message = self._process_message( location["message"], rule_id, rules) - file, rng = self._process_location(location) - if not (file and rng): - continue - thread_flow_info.bug_path_events.append(BugPathEvent( message, file, rng.start_line, rng.start_col, rng))