Skip to content

Commit

Permalink
store sarif tool data (#943)
Browse files Browse the repository at this point in the history
* store sarif tool data

* apparently we do need init
  • Loading branch information
clavedeluna authored Dec 4, 2024
1 parent a91d084 commit 95bd4b2
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/codemodder/result.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]:
Expand Down

0 comments on commit 95bd4b2

Please sign in to comment.