Skip to content

Commit

Permalink
add recursive check for base constructors | strange setter
Browse files Browse the repository at this point in the history
  • Loading branch information
olegggatttor committed Apr 12, 2024
1 parent 53a7f2d commit 28fa225
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
8 changes: 8 additions & 0 deletions slitherin/detectors/strange_setter.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from slither.detectors.abstract_detector import AbstractDetector, DetectorClassification
from slither.core.declarations import Function
import slither.core.expressions.new_array as na
from slither.analyses.data_dependency.data_dependency import is_dependent


class StrangeSetter(AbstractDetector):
Expand Down Expand Up @@ -54,6 +55,13 @@ def _is_strange_setter(self, fun: Function) -> bool:
for arg in [*external.arguments, external._called._expression]:
if str(arg) == str(param):
used_params.add(param)
if fun.name == "constructor":
for base_call in fun.explicit_base_constructor_calls:
if not self._is_strange_constructor(base_call):
for param_cur in fun.parameters:
for param_base in base_call.parameters:
if is_dependent(param_base, param_cur, base_call):
used_params.add(param_cur)
intersection_len = len(set(fun.parameters) & used_params)
return intersection_len != len(fun.parameters)

Expand Down
4 changes: 4 additions & 0 deletions tests/strange_setter_test.sol
Original file line number Diff line number Diff line change
Expand Up @@ -87,3 +87,7 @@ contract OkConstructor {
init = true;
}
}

contract TestInheritance is StrangeSetter{
constructor(uint256 _toSet) StrangeSetter(_toSet) {}
}

0 comments on commit 28fa225

Please sign in to comment.