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

store sarif tool data #943

Merged
merged 2 commits into from
Dec 4, 2024
Merged
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
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 = {}
Copy link
Contributor Author

@clavedeluna clavedeluna Dec 4, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this init didn't seem necessary given the default values provided below

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
Loading