From 95bd4b2b70d4b099ff28e8d99cf098e8aaf946d7 Mon Sep 17 00:00:00 2001 From: Dani Alcala <112832187+clavedeluna@users.noreply.github.com> Date: Wed, 4 Dec 2024 18:54:53 -0300 Subject: [PATCH] store sarif tool data (#943) * store sarif tool data * apparently we do need init --- src/codemodder/result.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/codemodder/result.py b/src/codemodder/result.py index 42c0bf5f..f3487d5c 100644 --- a/src/codemodder/result.py +++ b/src/codemodder/result.py @@ -178,16 +178,22 @@ def fuzzy_column_match(pos: CodeRange, location: Location) -> bool: class ResultSet(dict[str, dict[Path, list[Result]]]): results_for_rule: dict[str, list[Result]] + # stores SARIF runs.tool data + tools: list[dict[str, dict]] def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) self.results_for_rule = {} + self.tools = [] def add_result(self, result: Result): self.results_for_rule.setdefault(result.rule_id, []).append(result) for loc in result.locations: self.setdefault(result.rule_id, {}).setdefault(loc.file, []).append(result) + def store_tool_data(self, tool_data: dict): + self.tools.append(tool_data) + def results_for_rule_and_file( self, context: CodemodExecutionContext, rule_id: str, file: Path ) -> list[Result]: