-
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.
Account for frozen datatypes when updating finding metadata
- Loading branch information
Showing
3 changed files
with
87 additions
and
7 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,43 @@ | ||
from codemodder.codemods.base_codemod import ToolRule | ||
from codemodder.codetf import Change, ChangeSet, Finding, Rule | ||
from codemodder.utils.update_finding_metadata import update_finding_metadata | ||
|
||
|
||
def test_update_finding_metdata(): | ||
tool_rule = ToolRule(id="rule_id", name="rule_name", url="rule_url") | ||
changeset = ChangeSet( | ||
path="", | ||
diff="", | ||
changes=[ | ||
Change( | ||
lineNumber=1, | ||
description="foo", | ||
findings=[ | ||
Finding(id="rule_id", rule=Rule(id="rule_id", name="other_name")) | ||
], | ||
), | ||
Change( | ||
lineNumber=2, | ||
description="bar", | ||
findings=[ | ||
Finding(id="other_id", rule=Rule(id="other_id", name="other_name")) | ||
], | ||
), | ||
Change( | ||
lineNumber=3, | ||
description="baz", | ||
), | ||
], | ||
) | ||
|
||
new_changesets = update_finding_metadata( | ||
tool_rules=[tool_rule], changesets=[changeset] | ||
) | ||
|
||
assert new_changesets[0].changes[0].findings | ||
assert new_changesets[0].changes[0].findings[0].rule.name == "rule_name" | ||
assert new_changesets[0].changes[0].findings[0].rule.url == "rule_url" | ||
assert new_changesets[0].changes[1].findings | ||
assert new_changesets[0].changes[1].findings[0].rule.name == "other_name" | ||
assert new_changesets[0].changes[1].findings[0].rule.url is None | ||
assert new_changesets[0].changes[2] == changeset.changes[2] |