Skip to content

Commit

Permalink
fix bugs in other mutators
Browse files Browse the repository at this point in the history
  • Loading branch information
bohendo committed Jan 27, 2025
1 parent 8b9590d commit 2295939
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 6 deletions.
6 changes: 4 additions & 2 deletions slither/tools/mutator/mutators/AOR.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,10 @@ def _mutate(self) -> Dict:
old_str = node.source_mapping.content
line_no = node.source_mapping.lines
if not line_no[0] in self.dont_mutate_line:
# Replace the expression with true
new_str = f"{old_str.split(ir.type.value)[0]}{op.value}{old_str.split(ir.type.value)[1]}"
halves = old_str.split(ir.type.value)
if len(halves) != 2:
continue # skip if assembly
new_str = f"{halves[0]}{op.value}{halves[1]}"
create_patch_with_line(
result,
self.in_file,
Expand Down
2 changes: 1 addition & 1 deletion slither/tools/mutator/mutators/FHR.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def _mutate(self) -> Dict:
for function in self.contract.functions_and_modifiers_declared:
start = function.source_mapping.start
stop = start + function.source_mapping.content.find("{")
old_str = node.source_mapping.content
old_str = function.source_mapping.content
line_no = function.source_mapping.lines
if not line_no[0] in self.dont_mutate_line:
for value in function_header_replacements:
Expand Down
4 changes: 2 additions & 2 deletions slither/tools/mutator/mutators/MVIE.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def _mutate(self) -> Dict:
# Get the string
start = variable.source_mapping.start
stop = variable.expression.source_mapping.start
old_str = node.source_mapping.content
old_str = variable.source_mapping.content
new_str = old_str[: old_str.find("=")]
line_no = variable.node_initialization.source_mapping.lines
if not line_no[0] in self.dont_mutate_line:
Expand All @@ -44,7 +44,7 @@ def _mutate(self) -> Dict:
# Get the string
start = variable.source_mapping.start
stop = variable.expression.source_mapping.start
old_str = node.source_mapping.content
old_str = variable.source_mapping.content
new_str = old_str[: old_str.find("=")]
line_no = variable.source_mapping.lines
if not line_no[0] in self.dont_mutate_line:
Expand Down
2 changes: 1 addition & 1 deletion slither/tools/mutator/mutators/ROR.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def _mutate(self) -> Dict:
line_no = node.source_mapping.lines
if not line_no[0] in self.dont_mutate_line:
# Replace the expression with true
new_str = f"{old_str.split(ir.type.value)[0]} {op.value} {old_str.split(ir.type.value)[1]}"
new_str = f"{old_str.split(ir.type.value)[0]}{op.value}{old_str.split(ir.type.value)[1]}"
create_patch_with_line(
result,
self.in_file,
Expand Down

0 comments on commit 2295939

Please sign in to comment.