From 978012be34177b1a6eba14cee1147679f6af0a01 Mon Sep 17 00:00:00 2001 From: alpharush <0xalpharush@protonmail.com> Date: Tue, 17 Oct 2023 08:50:04 -0500 Subject: [PATCH 1/3] update vyper cfg to include reachability --- slither/vyper_parsing/declarations/function.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/slither/vyper_parsing/declarations/function.py b/slither/vyper_parsing/declarations/function.py index 70e04c8e51..f5acf1296b 100644 --- a/slither/vyper_parsing/declarations/function.py +++ b/slither/vyper_parsing/declarations/function.py @@ -184,6 +184,7 @@ def analyze_content(self) -> None: self._function.is_implemented = True self._function.is_empty = False self._parse_cfg(body) + self._update_reachability(self._function.entry_point) else: self._function.is_implemented = False self._function.is_empty = True @@ -243,6 +244,12 @@ def _new_node( # region Parsing function ################################################################################### ################################################################################### + def _update_reachability(self, node: Node) -> None: + if node.is_reachable: + return + node.set_is_reachable(True) + for son in node.sons: + self._update_reachability(son) # pylint: disable=too-many-branches,too-many-statements,protected-access,too-many-locals def _parse_cfg(self, cfg: List[ASTNode]) -> None: From d7bb7348b0b161c2d926e3661eab32948656c2e0 Mon Sep 17 00:00:00 2001 From: alpharush <0xalpharush@protonmail.com> Date: Tue, 17 Oct 2023 08:52:25 -0500 Subject: [PATCH 2/3] revert https://github.com/crytic/slither/pull/2170 --- slither/core/dominators/utils.py | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/slither/core/dominators/utils.py b/slither/core/dominators/utils.py index eb20ef00cb..0fa2a8ea92 100644 --- a/slither/core/dominators/utils.py +++ b/slither/core/dominators/utils.py @@ -10,20 +10,19 @@ def intersection_predecessor(node: "Node") -> Set["Node"]: if not node.fathers: return set() - # Revert PR1984 ret = node.fathers[0].dominators for pred in node.fathers[1:]: ret = ret.intersection(pred.dominators) - # if not any(father.is_reachable for father in node.fathers): - # return set() - # - # ret = set() - # for pred in node.fathers: - # ret = ret.union(pred.dominators) - # - # for pred in node.fathers: - # if pred.is_reachable: - # ret = ret.intersection(pred.dominators) + if not any(father.is_reachable for father in node.fathers): + return set() + + ret = set() + for pred in node.fathers: + ret = ret.union(pred.dominators) + + for pred in node.fathers: + if pred.is_reachable: + ret = ret.intersection(pred.dominators) return ret @@ -96,9 +95,8 @@ def compute_dominance_frontier(nodes: List["Node"]) -> None: for node in nodes: if len(node.fathers) >= 2: for father in node.fathers: - # Revert PR1984 - # if not father.is_reachable: - # continue + if not father.is_reachable: + continue runner = father # Corner case: if there is a if without else # we need to add update the conditional node From 38c7229c4562eabf528864146c151e513600c108 Mon Sep 17 00:00:00 2001 From: alpharush <0xalpharush@protonmail.com> Date: Tue, 17 Oct 2023 08:56:46 -0500 Subject: [PATCH 3/3] fmt --- slither/core/dominators/utils.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/slither/core/dominators/utils.py b/slither/core/dominators/utils.py index 0fa2a8ea92..150c0c50e6 100644 --- a/slither/core/dominators/utils.py +++ b/slither/core/dominators/utils.py @@ -15,11 +15,11 @@ def intersection_predecessor(node: "Node") -> Set["Node"]: ret = ret.intersection(pred.dominators) if not any(father.is_reachable for father in node.fathers): return set() - + ret = set() for pred in node.fathers: ret = ret.union(pred.dominators) - + for pred in node.fathers: if pred.is_reachable: ret = ret.intersection(pred.dominators)