pull/72/head
Josselin 6 years ago
parent 6dc9faf496
commit c08c3b56e7
  1. 2
      slither/detectors/attributes/locked_ether.py
  2. 3
      slither/detectors/examples/backdoor.py
  3. 2
      slither/detectors/functions/arbitrary_send.py
  4. 1
      slither/detectors/functions/complex_function.py
  5. 2
      slither/detectors/functions/suicidal.py
  6. 2
      slither/detectors/naming_convention/naming_convention.py
  7. 2
      slither/detectors/operations/low_level_calls.py
  8. 6
      slither/detectors/variables/possible_const_state_variables.py
  9. 8
      slither/detectors/variables/uninitialized_state_variables.py
  10. 7
      slither/detectors/variables/uninitialized_storage_variables.py
  11. 7
      slither/detectors/variables/unused_state_variables.py
  12. 2
      slither/solc_parsing/declarations/modifier.py

@ -48,7 +48,7 @@ class LockedEther(AbstractDetector):
txt += "\tContract {} has payable functions:\n".format(contract.name)
for function in funcs_payable:
txt += "\t - {} ({})\n".format(function.name, function.source_mapping_str)
txt += "\tBut has not function to withdraw the ether"
txt += "\tBut has not function to withdraw the ether\n"
info = txt.format(self.filename,
contract.name,
[f.name for f in funcs_payable])

@ -19,7 +19,8 @@ class Backdoor(AbstractDetector):
for f in contract.functions:
if 'backdoor' in f.name:
# Info to be printed
info = 'Backdoor function found in {}.{}'.format(contract.name, f.name)
info = 'Backdoor function found in {}.{} ({})\n'
info = info.format(contract.name, f.name, f.source_mapping_str)
# Print the info
self.log(info)
# Add the result in ret

@ -104,7 +104,7 @@ class ArbitrarySend(AbstractDetector):
func.name)
info += '\tDangerous calls:\n'
for node in nodes:
info += '- {} ({})'.format(node.expression, node.source_mapping_str)
info += '\t- {} ({})\n'.format(node.expression, node.source_mapping_str)
self.log(info)

@ -104,6 +104,7 @@ class ComplexFunction(AbstractDetector):
contract.name,
func_name,
func.source_mapping_str)
info = info + "\n"
self.log(info)
results.append({'vuln': 'ComplexFunc',

@ -55,7 +55,7 @@ class Suicidal(AbstractDetector):
functions = self.detect_suicidal(c)
for func in functions:
txt = "{}.{} ({}) allows anyone to destruct the contract"
txt = "{}.{} ({}) allows anyone to destruct the contract\n"
info = txt.format(func.contract.name,
func.name,
func.source_mapping_str)

@ -155,7 +155,7 @@ class NamingConvention(AbstractDetector):
else:
correct_naming = self.is_mixed_case(var.name)
if not correct_naming:
info = "Variable '{}.{}' ({}) is not in mixedCase"
info = "Variable '{}.{}' ({}) is not in mixedCase\n"
info = info.format(var.contract.name, var.name, var.source_mapping_str)
self.log(info)

@ -42,7 +42,7 @@ class LowLevelCalls(AbstractDetector):
for c in self.contracts:
values = self.detect_low_level_calls(c)
for func, nodes in values:
info = "Low level call in {}.{} ({})"
info = "Low level call in {}.{} ({})\n"
info = info.format(func.contract.name, func.name, func.source_mapping_str)
self.log(info)

@ -64,9 +64,9 @@ class ConstCandidateStateVars(AbstractDetector):
for contract, variables in variables_by_contract.items():
variable_names = [v.name for v in variables]
info = "State variables that could be const in %s, Contract: %s, Vars %s" % (self.filename,
contract,
str(variable_names))
info = "{} has state variables that should be constant:\n".format(contract)
for v in variables:
info += "\t- {} ({})\n".format(v.name, v.source_mapping_str)
self.log(info)
sourceMapping = [v.source_mapping for v in const_candidates]

@ -72,10 +72,10 @@ class UninitializedStateVarsDetection(AbstractDetector):
for c in self.slither.contracts_derived:
ret = self.detect_uninitialized(c)
for variable, functions in ret:
info = "Uninitialized state variable in %s, " % self.filename + \
"Contract: %s, Variable: %s, Used in %s" % (c.name,
str(variable),
[str(f) for f in functions])
info = "{}.{} ({}) is never initialized. It is used in:\n"
info = info.format(variable.contract.name, variable.name, variable.source_mapping_str)
for f in functions:
info += "\t- {} ({})\n".format(f.name, f.source_mapping_str)
self.log(info)
source = [variable.source_mapping]

@ -82,10 +82,9 @@ class UninitializedStorageVars(AbstractDetector):
for(function, uninitialized_storage_variable) in self.results:
var_name = uninitialized_storage_variable.name
info = "Uninitialized storage variables in %s, " % self.filename + \
"Contract: %s, Function: %s, Variable %s" % (function.contract.name,
function.name,
var_name)
info = "{} in {}.{} ({}) is a storage variable never initialiazed\n"
info = info.format(var_name, function.contract.name, function.name, uninitialized_storage_variable.source_mapping_str)
self.log(info)
source = [function.source_mapping, uninitialized_storage_variable.source_mapping]

@ -34,9 +34,10 @@ class UnusedStateVars(AbstractDetector):
unusedVars = self.detect_unused(c)
if unusedVars:
unusedVarsName = [v.name for v in unusedVars]
info = "Unused state variables in %s, Contract: %s, Vars %s" % (self.filename,
c.name,
str(unusedVarsName))
info = ''
for var in unusedVars:
info += "{}.{} ({}) is never used\n".format(var.contract.name, var.name, var.source_mapping_str)
self.log(info)
sourceMapping = [v.source_mapping for v in unusedVars]

@ -65,7 +65,7 @@ class ModifierSolc(Modifier, FunctionSolc):
def _parse_statement(self, statement, node):
name = statement[self.get_key()]
if name == 'PlaceholderStatement':
placeholder_node = self._new_node(NodeType.PLACEHOLDER)
placeholder_node = self._new_node(NodeType.PLACEHOLDER, statement['src'])
link_nodes(node, placeholder_node)
return placeholder_node
return super(ModifierSolc, self)._parse_statement(statement, node)

Loading…
Cancel
Save