apply black

pull/1046/head
Jaime 3 years ago
parent f4df89bf80
commit 32d265eb69
  1. 11
      slither/detectors/statements/unprotected_upgradeable.py

@ -20,6 +20,7 @@ def _can_be_destroyed(contract) -> List[Function]:
break break
return targets return targets
def _has_initializer_modifier(functions: List[Function]) -> bool: def _has_initializer_modifier(functions: List[Function]) -> bool:
for f in functions: for f in functions:
for m in f.modifiers: for m in f.modifiers:
@ -27,6 +28,7 @@ def _has_initializer_modifier(functions: List[Function]) -> bool:
return True return True
return False return False
def _has_protected_initialize(functions: List[Function]) -> bool: def _has_protected_initialize(functions: List[Function]) -> bool:
for f in functions: for f in functions:
if f.name == "initialize": if f.name == "initialize":
@ -35,6 +37,7 @@ def _has_protected_initialize(functions: List[Function]) -> bool:
return True return True
return False return False
class UnprotectedUpgradeable(AbstractDetector): class UnprotectedUpgradeable(AbstractDetector):
ARGUMENT = "unprotected-upgrade" ARGUMENT = "unprotected-upgrade"
@ -75,10 +78,14 @@ class UnprotectedUpgradeable(AbstractDetector):
for contract in self.compilation_unit.contracts_derived: for contract in self.compilation_unit.contracts_derived:
if contract.is_upgradeable: if contract.is_upgradeable:
if not _has_initializer_modifier(contract.constructors) or not _has_protected_initialize(contract.functions): if not _has_initializer_modifier(
contract.constructors
) or not _has_protected_initialize(contract.functions):
functions_that_can_destroy = _can_be_destroyed(contract) functions_that_can_destroy = _can_be_destroyed(contract)
if functions_that_can_destroy: if functions_that_can_destroy:
initiliaze_functions = [f for f in contract.functions if f.name == "initialize"] initiliaze_functions = [
f for f in contract.functions if f.name == "initialize"
]
vars_init_ = [ vars_init_ = [
init.all_state_variables_written() for init in initiliaze_functions init.all_state_variables_written() for init in initiliaze_functions

Loading…
Cancel
Save