From 8539c03e22e2dbbef95a6be14a384139c91d258a Mon Sep 17 00:00:00 2001 From: Josselin Date: Tue, 22 Jun 2021 11:34:28 +0200 Subject: [PATCH 1/2] Improve debug info in case of name reuse --- .../slither_compilation_unit_solc.py | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/slither/solc_parsing/slither_compilation_unit_solc.py b/slither/solc_parsing/slither_compilation_unit_solc.py index e7ff8d099..aafd3fe0d 100644 --- a/slither/solc_parsing/slither_compilation_unit_solc.py +++ b/slither/solc_parsing/slither_compilation_unit_solc.py @@ -311,7 +311,7 @@ Please rename it, this name is reserved for Slither's internals""" father_constructors = [] # try: # Resolve linearized base contracts. - missing_inheritance = False + missing_inheritance = None for i in contract_parser.linearized_base_contracts[1:]: if i in contract_parser.remapping: @@ -321,7 +321,7 @@ Please rename it, this name is reserved for Slither's internals""" elif i in self._contracts_by_id: ancestors.append(self._contracts_by_id[i]) else: - missing_inheritance = True + missing_inheritance = i # Resolve immediate base contracts for i in contract_parser.baseContracts: @@ -332,7 +332,7 @@ Please rename it, this name is reserved for Slither's internals""" elif i in self._contracts_by_id: fathers.append(self._contracts_by_id[i]) else: - missing_inheritance = True + missing_inheritance = i # Resolve immediate base constructor calls for i in contract_parser.baseConstructorContractsCalled: @@ -343,7 +343,7 @@ Please rename it, this name is reserved for Slither's internals""" elif i in self._contracts_by_id: father_constructors.append(self._contracts_by_id[i]) else: - missing_inheritance = True + missing_inheritance = i contract_parser.underlying_contract.set_inheritance( ancestors, fathers, father_constructors @@ -353,7 +353,14 @@ Please rename it, this name is reserved for Slither's internals""" self._compilation_unit.contracts_with_missing_inheritance.add( contract_parser.underlying_contract ) - contract_parser.log_incorrect_parsing(f"Missing inheritance {contract_parser}") + txt = f"Missing inheritance {contract_parser.underlying_contract} ({contract_parser.compilation_unit.crytic_compile_compilation_unit.unique_id})\n" + txt += f"Missing inheritance ID: {missing_inheritance}\n" + if contract_parser.underlying_contract.inheritance: + txt += f"Inheritance found:\n" + for contract_inherited in contract_parser.underlying_contract.inheritance: + txt += f"\t - {contract_inherited} (ID {contract_inherited.id})\n" + contract_parser.log_incorrect_parsing(txt) + contract_parser.set_is_analyzed(True) contract_parser.delete_content() From 2b06b49cb7b6267ee3ef7c049dfa97fa607997d4 Mon Sep 17 00:00:00 2001 From: Josselin Feist Date: Mon, 1 Aug 2022 15:15:54 +0200 Subject: [PATCH 2/2] Minor --- slither/solc_parsing/slither_compilation_unit_solc.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/slither/solc_parsing/slither_compilation_unit_solc.py b/slither/solc_parsing/slither_compilation_unit_solc.py index e057d00e8..3054b4470 100644 --- a/slither/solc_parsing/slither_compilation_unit_solc.py +++ b/slither/solc_parsing/slither_compilation_unit_solc.py @@ -459,7 +459,7 @@ Please rename it, this name is reserved for Slither's internals""" txt = f"Missing inheritance {contract_parser.underlying_contract} ({contract_parser.compilation_unit.crytic_compile_compilation_unit.unique_id})\n" txt += f"Missing inheritance ID: {missing_inheritance}\n" if contract_parser.underlying_contract.inheritance: - txt += f"Inheritance found:\n" + txt += "Inheritance found:\n" for contract_inherited in contract_parser.underlying_contract.inheritance: txt += f"\t - {contract_inherited} (ID {contract_inherited.id})\n" contract_parser.log_incorrect_parsing(txt)