Skip to content

Commit 8491719

Browse files
committed
Update Change.findings => fixedFindings to conform to spec
1 parent a91d084 commit 8491719

16 files changed

+46
-44
lines changed

src/codemodder/codemods/imported_call_modifier.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ def leave_Call(self, original_node: cst.Call, updated_node: cst.Call):
8181
Change(
8282
lineNumber=line_number,
8383
description=self.change_description,
84-
findings=self.file_context.get_findings_for_location(
84+
fixedFindings=self.file_context.get_findings_for_location(
8585
line_number
8686
),
8787
)

src/codemodder/codemods/libcst_transformer.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ def report_change_for_line(
126126
Change(
127127
lineNumber=line_number,
128128
description=description or self.change_description,
129-
findings=findings
129+
fixedFindings=findings
130130
or self.file_context.get_findings_for_location(line_number),
131131
)
132132
)

src/codemodder/codemods/regex_transformer.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ def _apply(self, original_lines, file_context, results):
4040
Change(
4141
lineNumber=lineno + 1,
4242
description=self.change_description,
43-
findings=file_context.get_findings_for_location(lineno),
43+
fixedFindings=file_context.get_findings_for_location(lineno),
4444
)
4545
)
4646
return changes, updated_lines
@@ -110,7 +110,7 @@ def _apply(self, original_lines, file_context, results):
110110
Change(
111111
lineNumber=lineno + 1,
112112
description=self.change_description,
113-
findings=file_context.get_findings_for_location(lineno),
113+
fixedFindings=file_context.get_findings_for_location(lineno),
114114
)
115115
)
116116

src/codemodder/codemods/test/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,5 +224,5 @@ def run_and_assert(
224224

225225
def assert_findings(self, changes: list[Change]):
226226
assert all(
227-
x.findings for x in changes
227+
x.fixedFindings for x in changes
228228
), f"Expected all changes to have findings: {changes}"

src/codemodder/codemods/xml_transformer.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ def add_change(self, line):
9696
Change(
9797
lineNumber=line,
9898
description=self.change_description or None,
99-
findings=self.file_context.get_findings_for_location(line),
99+
fixedFindings=self.file_context.get_findings_for_location(line),
100100
)
101101
)
102102

src/codemodder/codetf.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ class Change(BaseModel):
6262
diffSide: DiffSide = DiffSide.RIGHT
6363
properties: Optional[dict] = None
6464
packageActions: Optional[list[PackageAction]] = None
65-
findings: Optional[list[Finding]] = None
65+
fixedFindings: Optional[list[Finding]] = None
6666

6767
@model_validator(mode="after")
6868
def validate_lineNumber(self):
@@ -83,7 +83,7 @@ def with_findings(self, findings: list[Finding] | None) -> Change:
8383
diffSide=self.diffSide,
8484
properties=self.properties,
8585
packageActions=self.packageActions,
86-
findings=findings,
86+
fixedFindings=findings,
8787
)
8888

8989

src/codemodder/utils/update_finding_metadata.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ def update_finding_metadata(
2727
if finding.rule.id in tool_rule_map
2828
else finding
2929
)
30-
for finding in change.findings or []
30+
for finding in change.fixedFindings or []
3131
]
3232
or None
3333
)

src/core_codemods/file_resource_leak.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ def _handle_block(
229229
Change(
230230
lineNumber=line_number,
231231
description=FileResourceLeakTransformer.change_description,
232-
findings=self.file_context.get_findings_for_location(
232+
fixedFindings=self.file_context.get_findings_for_location(
233233
line_number
234234
),
235235
)

tests/codemods/defectdojo/semgrep/test_avoid_insecure_deserialization.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,9 @@ def test_yaml_load(self, tmpdir):
4646
)
4747

4848
assert changes is not None
49-
assert changes[0].changes[0].findings is not None
50-
assert changes[0].changes[0].findings[0].id == "1"
51-
assert changes[0].changes[0].findings[0].rule.id == RULE_ID
49+
assert changes[0].changes[0].fixedFindings is not None
50+
assert changes[0].changes[0].fixedFindings[0].id == "1"
51+
assert changes[0].changes[0].fixedFindings[0].rule.id == RULE_ID
5252

5353
@mock.patch("codemodder.codemods.api.FileContext.add_dependency")
5454
def test_pickle_load(self, adds_dependency, tmpdir):
@@ -80,9 +80,9 @@ def test_pickle_load(self, adds_dependency, tmpdir):
8080
adds_dependency.assert_called_once_with(Fickling)
8181

8282
assert changes is not None
83-
assert changes[0].changes[0].findings is not None
84-
assert changes[0].changes[0].findings[0].id == "2"
85-
assert changes[0].changes[0].findings[0].rule.id == RULE_ID
83+
assert changes[0].changes[0].fixedFindings is not None
84+
assert changes[0].changes[0].fixedFindings[0].id == "2"
85+
assert changes[0].changes[0].fixedFindings[0].rule.id == RULE_ID
8686

8787
@mock.patch("codemodder.codemods.api.FileContext.add_dependency")
8888
def test_pickle_and_yaml(self, adds_dependency, tmpdir):
@@ -128,12 +128,12 @@ def test_pickle_and_yaml(self, adds_dependency, tmpdir):
128128
adds_dependency.assert_called_once_with(Fickling)
129129

130130
assert changes is not None
131-
assert changes[0].changes[0].findings is not None
132-
assert changes[0].changes[0].findings[0].id == "4"
133-
assert changes[0].changes[0].findings[0].rule.id == RULE_ID
134-
assert changes[0].changes[1].findings is not None
135-
assert changes[0].changes[1].findings[0].id == "3"
136-
assert changes[0].changes[1].findings[0].rule.id == RULE_ID
131+
assert changes[0].changes[0].fixedFindings is not None
132+
assert changes[0].changes[0].fixedFindings[0].id == "4"
133+
assert changes[0].changes[0].fixedFindings[0].rule.id == RULE_ID
134+
assert changes[0].changes[1].fixedFindings is not None
135+
assert changes[0].changes[1].fixedFindings[0].id == "3"
136+
assert changes[0].changes[1].fixedFindings[0].rule.id == RULE_ID
137137

138138
@mock.patch("codemodder.codemods.api.FileContext.add_dependency")
139139
def test_pickle_loads(self, adds_dependency, tmpdir):

tests/codemods/defectdojo/semgrep/test_django_secure_set_cookie.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,9 @@ def test_simple(self, tmpdir):
3737
)
3838

3939
assert changes is not None
40-
assert changes[0].changes[0].findings is not None
41-
assert changes[0].changes[0].findings[0].id == "1"
40+
assert changes[0].changes[0].fixedFindings is not None
41+
assert changes[0].changes[0].fixedFindings[0].id == "1"
4242
assert (
43-
changes[0].changes[0].findings[0].rule.id
43+
changes[0].changes[0].fixedFindings[0].rule.id
4444
== "python.django.security.audit.secure-cookies.django-secure-set-cookie"
4545
)

0 commit comments

Comments
 (0)