-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Fix issue name and finding ID in Sonar metadata * Update fixed findings with metadata from ToolRule * Hardening suggestions for codemodder-python / fix-sonar-metadata (#825) Use Assignment Expression (Walrus) In Conditional Co-authored-by: pixeebot[bot] <104101892+pixeebot[bot]@users.noreply.github.com> --------- Co-authored-by: pixeebot[bot] <104101892+pixeebot[bot]@users.noreply.github.com>
- Loading branch information
1 parent
51344e5
commit b557d7b
Showing
4 changed files
with
44 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
from __future__ import annotations | ||
|
||
import typing | ||
|
||
if typing.TYPE_CHECKING: | ||
from codemodder.codemods.base_codemod import ToolRule | ||
|
||
from codemodder.codetf import ChangeSet | ||
|
||
|
||
def update_finding_metadata( | ||
tool_rules: list[ToolRule], | ||
changesets: list[ChangeSet], | ||
) -> list[ChangeSet]: | ||
if not (tool_rule_map := {rule.id: (rule.name, rule.url) for rule in tool_rules}): | ||
return changesets | ||
|
||
for changeset in changesets: | ||
for change in changeset.changes: | ||
for finding in change.findings or []: | ||
if finding.id in tool_rule_map: | ||
finding.rule.name = tool_rule_map[finding.id][0] | ||
finding.rule.url = tool_rule_map[finding.id][1] | ||
|
||
# TODO: eventually make this functional and return a new list | ||
return changesets |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters