Handle missing self.slither.solc_version

pull/380/head
Josselin 5 years ago
parent f4413c097e
commit a0b8ffcbd6
  1. 23
      slither/detectors/attributes/const_functions_asm.py
  2. 29
      slither/detectors/attributes/const_functions_state.py

@ -50,19 +50,20 @@ All the calls to `get` revert, breaking Bob's smart contract execution.'''
list: {'vuln', 'filename,'contract','func','#varsWritten'} list: {'vuln', 'filename,'contract','func','#varsWritten'}
""" """
results = [] results = []
if self.slither.solc_version < "0.5.0": if self.slither.solc_version and self.slither.solc_version >= "0.5.0":
for c in self.contracts: return results
for f in c.functions: for c in self.contracts:
if f.contract_declarer != c: for f in c.functions:
continue if f.contract_declarer != c:
if f.view or f.pure: continue
if f.contains_assembly: if f.view or f.pure:
attr = 'view' if f.view else 'pure' if f.contains_assembly:
attr = 'view' if f.view else 'pure'
info = [f, f' is declared {attr} but contains assembly code\n'] info = [f, f' is declared {attr} but contains assembly code\n']
res = self.generate_result(info, {'contains_assembly': True}) res = self.generate_result(info, {'contains_assembly': True})
results.append(res) results.append(res)
return results return results

@ -50,24 +50,25 @@ All the calls to `get` revert, breaking Bob's smart contract execution.'''
list: {'vuln', 'filename,'contract','func','#varsWritten'} list: {'vuln', 'filename,'contract','func','#varsWritten'}
""" """
results = [] results = []
if self.slither.solc_version < "0.5.0": if self.slither.solc_version and self.slither.solc_version >= "0.5.0":
for c in self.contracts: return results
for f in c.functions: for c in self.contracts:
if f.contract_declarer != c: for f in c.functions:
continue if f.contract_declarer != c:
if f.view or f.pure: continue
variables_written = f.all_state_variables_written() if f.view or f.pure:
if variables_written: variables_written = f.all_state_variables_written()
attr = 'view' if f.view else 'pure' 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: for variable_written in variables_written:
info += ['\t- ', variable_written, '\n'] 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 return results

Loading…
Cancel
Save