From ac0555f96de22cea0b6990eca0c0d5422d3272f1 Mon Sep 17 00:00:00 2001 From: clavedeluna Date: Tue, 5 Mar 2024 08:33:30 -0300 Subject: [PATCH] update based on review --- src/codemodder/codemods/base_visitor.py | 3 ++- src/core_codemods/sonar/sonar_jwt_decode_verify.py | 5 ++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/codemodder/codemods/base_visitor.py b/src/codemodder/codemods/base_visitor.py index 0c82fb452..d9bd9b315 100644 --- a/src/codemodder/codemods/base_visitor.py +++ b/src/codemodder/codemods/base_visitor.py @@ -23,7 +23,8 @@ def __init__( def filter_by_result(self, node): pos_to_match = self.node_position(node) if self.results is None: - # Some codemods must run without results existing. + # Returning True here means codemods without detectors (and results) + # will still run their transformations. return True return any(result.match_location(pos_to_match, node) for result in self.results) diff --git a/src/core_codemods/sonar/sonar_jwt_decode_verify.py b/src/core_codemods/sonar/sonar_jwt_decode_verify.py index 0fae5af5b..70835b79a 100644 --- a/src/core_codemods/sonar/sonar_jwt_decode_verify.py +++ b/src/core_codemods/sonar/sonar_jwt_decode_verify.py @@ -15,13 +15,12 @@ def filter_by_result(self, node) -> bool: results returned have a start/end column for the verify keyword within the `decode` call, not for the entire call like semgrep returns. """ - if self.results is None: - return False match node: case cst.Call(): pos_to_match = self.node_position(node) return any( - self.match_location(pos_to_match, result) for result in self.results + self.match_location(pos_to_match, result) + for result in self.results or [] ) return False