Skip to content

Commit 2b86454

Browse files
committed
Fixed tests and refactoring
1 parent 8b1d826 commit 2b86454

File tree

4 files changed

+9
-4
lines changed

4 files changed

+9
-4
lines changed

src/codemodder/codemods/test/integration_utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,7 @@ def check_sonar_issues(cls):
293293
)
294294

295295
assert any(
296-
map(lambda x: x in sonar_results, cls.codemod.requested_rules)
296+
[x in sonar_results for x in cls.codemod.requested_rules]
297297
), f"Make sure to add a sonar issue/hotspot for {cls.codemod.rule_id} in {cls.sonar_issues_json} or {cls.sonar_hotspots_json}"
298298
results_for_codemod = sonar_results[cls.codemod.requested_rules[-1]]
299299
file_path = pathlib.Path(cls.code_filename)

src/codemodder/scripts/generate_docs.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -328,6 +328,12 @@ class DocMetadata:
328328
need_sarif="Yes (Sonar)",
329329
)
330330
for name in SONAR_CODEMOD_NAMES
331+
} | {
332+
"secure-cookie": DocMetadata(
333+
importance="Medium",
334+
guidance_explained="Our change provides the most secure way to create cookies in Flask. However, it's possible you have configured your Flask application configurations to use secure cookies. In these cases, using the default parameters for `set_cookie` is safe.",
335+
need_sarif="Yes (Sonar)",
336+
),
331337
}
332338

333339
SEMGREP_CODEMOD_NAMES = [

src/core_codemods/sonar/sonar_secure_cookie.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ class SonarSecureCookieTransformer(LibcstResultTransformer, SecureCookieMixin):
2525
change_description = "Flask response `set_cookie` call should be called with `secure=True`, `httponly=True`, and `samesite='Lax'`."
2626

2727
def leave_Call(self, original_node, updated_node):
28-
# Try to match the func
2928
if self.node_is_selected(original_node.func):
3029
self.report_change(original_node)
3130
new_args = self.replace_args(

tests/test_sonar_results.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ def test_parse_issues_json():
4343

4444
def test_parse_hotspots_json():
4545
results = SonarResultSet.from_json(SAMPLE_DIR / "sonar_hotspots.json")
46-
assert len(results) == 2
46+
assert len(results) == 4
4747

4848

4949
def test_combined_json(tmpdir):
@@ -54,7 +54,7 @@ def test_combined_json(tmpdir):
5454
)
5555

5656
results = SonarResultSet.from_json(Path(tmpdir).joinpath("combined.json"))
57-
assert len(results) == 36
57+
assert len(results) == 38
5858

5959

6060
def test_empty_issues(tmpdir, caplog):

0 commit comments

Comments
 (0)