Improve reentrancy heuristic: Only skip view/pure/variable calls if Solidity 0.5 is used

pull/172/head
Josselin 6 years ago
parent ea599c4efd
commit d22e53fdfe
  1. 13
      slither/detectors/reentrancy/reentrancy.py

@ -34,8 +34,7 @@ class Reentrancy(AbstractDetector):
KEY = 'REENTRANCY' KEY = 'REENTRANCY'
@staticmethod def _can_callback(self, irs):
def _can_callback(irs):
""" """
Detect if the node contains a call that can Detect if the node contains a call that can
be used to re-entrance be used to re-entrance
@ -50,10 +49,12 @@ class Reentrancy(AbstractDetector):
if isinstance(ir, LowLevelCall): if isinstance(ir, LowLevelCall):
return True return True
if isinstance(ir, HighLevelCall) and not isinstance(ir, LibraryCall): if isinstance(ir, HighLevelCall) and not isinstance(ir, LibraryCall):
if isinstance(ir.function, Function) and (ir.function.view or ir.function.pure): # If solidity >0.5, STATICCALL is used
continue if self.slither.solc_version and self.slither.solc_version.startswith('0.5.'):
if isinstance(ir.function, Variable): if isinstance(ir.function, Function) and (ir.function.view or ir.function.pure):
continue continue
if isinstance(ir.function, Variable):
continue
return True return True
return False return False

Loading…
Cancel
Save