From a0b8ffcbd655098c74634b8484755f63099368aa Mon Sep 17 00:00:00 2001 From: Josselin Date: Thu, 28 Nov 2019 12:49:30 +0100 Subject: [PATCH] Handle missing self.slither.solc_version --- .../attributes/const_functions_asm.py | 23 ++++++++------- .../attributes/const_functions_state.py | 29 ++++++++++--------- 2 files changed, 27 insertions(+), 25 deletions(-) diff --git a/slither/detectors/attributes/const_functions_asm.py b/slither/detectors/attributes/const_functions_asm.py index 89af4d9ce..2b9486f96 100644 --- a/slither/detectors/attributes/const_functions_asm.py +++ b/slither/detectors/attributes/const_functions_asm.py @@ -50,19 +50,20 @@ All the calls to `get` revert, breaking Bob's smart contract execution.''' list: {'vuln', 'filename,'contract','func','#varsWritten'} """ results = [] - if self.slither.solc_version < "0.5.0": - for c in self.contracts: - for f in c.functions: - if f.contract_declarer != c: - continue - if f.view or f.pure: - if f.contains_assembly: - attr = 'view' if f.view else 'pure' + if self.slither.solc_version and self.slither.solc_version >= "0.5.0": + return results + for c in self.contracts: + for f in c.functions: + if f.contract_declarer != c: + continue + if f.view or f.pure: + if f.contains_assembly: + attr = 'view' if f.view else 'pure' - info = [f, f' is declared {attr} but contains assembly code\n'] - res = self.generate_result(info, {'contains_assembly': True}) + info = [f, f' is declared {attr} but contains assembly code\n'] + res = self.generate_result(info, {'contains_assembly': True}) - results.append(res) + results.append(res) return results diff --git a/slither/detectors/attributes/const_functions_state.py b/slither/detectors/attributes/const_functions_state.py index 6b39be702..fb7f94c7b 100644 --- a/slither/detectors/attributes/const_functions_state.py +++ b/slither/detectors/attributes/const_functions_state.py @@ -50,24 +50,25 @@ All the calls to `get` revert, breaking Bob's smart contract execution.''' list: {'vuln', 'filename,'contract','func','#varsWritten'} """ results = [] - if self.slither.solc_version < "0.5.0": - for c in self.contracts: - for f in c.functions: - if f.contract_declarer != c: - continue - if f.view or f.pure: - variables_written = f.all_state_variables_written() - if variables_written: - attr = 'view' if f.view else 'pure' + if self.slither.solc_version and self.slither.solc_version >= "0.5.0": + return results + for c in self.contracts: + for f in c.functions: + if f.contract_declarer != c: + continue + if f.view or f.pure: + variables_written = f.all_state_variables_written() + if variables_written: + attr = 'view' if f.view else 'pure' - info = [f, f' is declared {attr} but changes state variables:\n'] + info = [f, f' is declared {attr} but changes state variables:\n'] - for variable_written in variables_written: - info += ['\t- ', variable_written, '\n'] + for variable_written in variables_written: + info += ['\t- ', variable_written, '\n'] - res = self.generate_result(info, {'contains_assembly': False}) + res = self.generate_result(info, {'contains_assembly': False}) - results.append(res) + results.append(res) return results