Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sync master <> dev #2183

Merged
merged 3 commits into from
Oct 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# [Slither, the smart contrat static analyzer](https://crytic.github.io/slither/slither.html)
# [Slither, the smart contract static analyzer](https://crytic.github.io/slither/slither.html)

<img src="https://raw.githubusercontent.com/crytic/slither/master/logo.png" alt="Slither Static Analysis Framework Logo" width="500" />

Expand Down
26 changes: 12 additions & 14 deletions slither/core/dominators/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down Expand Up @@ -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
Expand Down
15 changes: 10 additions & 5 deletions slither/printers/guidance/echidna.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,12 +138,17 @@ def _extract_assert(contracts: List[Contract]) -> Dict[str, Dict[str, List[Dict]
"""
ret: Dict[str, Dict[str, List[Dict]]] = {}
for contract in contracts:
functions_using_assert: Dict[str, List[Dict]] = defaultdict(list)
functions_using_assert = [] # Dict[str, List[Dict]] = defaultdict(list)
for f in contract.functions_entry_points:
for node in f.all_nodes():
if SolidityFunction("assert(bool)") in node.solidity_calls and node.source_mapping:
func_name = _get_name(f)
functions_using_assert[func_name].append(node.source_mapping.to_json())
for v in f.all_solidity_calls():
if v == SolidityFunction("assert(bool)"):
functions_using_assert.append(_get_name(f))
break
# Revert https://github.com/crytic/slither/pull/2105 until format is supported by echidna.
# for node in f.all_nodes():
# if SolidityFunction("assert(bool)") in node.solidity_calls and node.source_mapping:
# func_name = _get_name(f)
# functions_using_assert[func_name].append(node.source_mapping.to_json())
if functions_using_assert:
ret[contract.name] = functions_using_assert
return ret
Expand Down
7 changes: 7 additions & 0 deletions slither/vyper_parsing/declarations/function.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down