diff --git a/slitherin/detectors/strange_setter.py b/slitherin/detectors/strange_setter.py index 323dc9b..2782caa 100644 --- a/slitherin/detectors/strange_setter.py +++ b/slitherin/detectors/strange_setter.py @@ -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): @@ -54,11 +55,18 @@ 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) def _is_strange_constructor(self, fun: Function) -> bool: - """Checks if constructor sets nothing""" + """Checks if constructor setqs nothing""" return self._is_strange_setter(fun) def _detect(self) -> List[Output]: diff --git a/tests/strange_setter_test.sol b/tests/strange_setter_test.sol index d2475c3..2c52806 100644 --- a/tests/strange_setter_test.sol +++ b/tests/strange_setter_test.sol @@ -87,3 +87,7 @@ contract OkConstructor { init = true; } } + +contract TestInheritance is StrangeSetter{ + constructor(uint256 _toSet) StrangeSetter(_toSet) {} +} \ No newline at end of file