From 02661eb0ffff56f4fff60f3e00fd065ef9d8332e Mon Sep 17 00:00:00 2001 From: Josselin Date: Sat, 9 Feb 2019 06:55:55 -0500 Subject: [PATCH] Improve reentrancy heuristic: ignore call to this. if the destination is reentrancy-safe (close #127) --- slither/detectors/reentrancy/reentrancy.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/slither/detectors/reentrancy/reentrancy.py b/slither/detectors/reentrancy/reentrancy.py index 3ea959535..74dbab7b6 100644 --- a/slither/detectors/reentrancy/reentrancy.py +++ b/slither/detectors/reentrancy/reentrancy.py @@ -6,7 +6,7 @@ """ from slither.core.cfg.node import NodeType -from slither.core.declarations import Function, SolidityFunction +from slither.core.declarations import Function, SolidityFunction, SolidityVariable from slither.core.expressions import UnaryOperation, UnaryOperationType from slither.detectors.abstract_detector import (AbstractDetector, DetectorClassification) @@ -55,6 +55,13 @@ class Reentrancy(AbstractDetector): continue if isinstance(ir.function, Variable): continue + # If there is a call to itself + # We can check that the function called is + # reentrancy-safe + if ir.destination == SolidityVariable('this'): + if not ir.function.all_high_level_calls(): + if not ir.function.all_low_level_calls(): + continue return True return False