From 82f2994125423ae1708f1a7c1eb2fa710b222c03 Mon Sep 17 00:00:00 2001 From: clavedeluna Date: Wed, 4 Dec 2024 17:35:59 -0300 Subject: [PATCH 1/2] store sarif tool data --- src/codemodder/result.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/codemodder/result.py b/src/codemodder/result.py index 42c0bf5f..08ee811e 100644 --- a/src/codemodder/result.py +++ b/src/codemodder/result.py @@ -177,17 +177,18 @@ def fuzzy_column_match(pos: CodeRange, location: Location) -> bool: class ResultSet(dict[str, dict[Path, list[Result]]]): - results_for_rule: dict[str, list[Result]] - - def __init__(self, *args, **kwargs): - super().__init__(*args, **kwargs) - self.results_for_rule = {} + results_for_rule: dict[str, list[Result]] = {} + # stores SARIF runs.tool data + tools: list[dict[str, dict]] = [] 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]: From 187a0d03168c24751731d64c268611c54ad2a61c Mon Sep 17 00:00:00 2001 From: clavedeluna Date: Wed, 4 Dec 2024 18:01:56 -0300 Subject: [PATCH 2/2] apparently we do need init --- src/codemodder/result.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/codemodder/result.py b/src/codemodder/result.py index 08ee811e..f3487d5c 100644 --- a/src/codemodder/result.py +++ b/src/codemodder/result.py @@ -177,9 +177,14 @@ def fuzzy_column_match(pos: CodeRange, location: Location) -> bool: class ResultSet(dict[str, dict[Path, list[Result]]]): - results_for_rule: dict[str, list[Result]] = {} + results_for_rule: dict[str, list[Result]] # stores SARIF runs.tool data - tools: list[dict[str, dict]] = [] + 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)