From ccad54263de5802c9893bd6eb151aa68d1a2cb95 Mon Sep 17 00:00:00 2001 From: Simone <79767264+smonicas@users.noreply.github.com> Date: Fri, 16 Jun 2023 00:21:59 +0200 Subject: [PATCH] Handle if crytic-compile returns an empty ast (#1961) --- slither/solc_parsing/slither_compilation_unit_solc.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/slither/solc_parsing/slither_compilation_unit_solc.py b/slither/solc_parsing/slither_compilation_unit_solc.py index a739c6f97d..00ac3a5192 100644 --- a/slither/solc_parsing/slither_compilation_unit_solc.py +++ b/slither/solc_parsing/slither_compilation_unit_solc.py @@ -198,6 +198,13 @@ def _parse_enum(self, top_level_data: Dict, filename: str) -> None: # pylint: disable=too-many-branches,too-many-statements,too-many-locals def parse_top_level_from_loaded_json(self, data_loaded: Dict, filename: str) -> None: + if not data_loaded or data_loaded is None: + logger.error( + "crytic-compile returned an empty AST. " + "If you are trying to analyze a contract from etherscan or similar make sure it has source code available." + ) + return + if "nodeType" in data_loaded: self._is_compact_ast = True