diff --git a/slither/detectors/attributes/locked_ether.py b/slither/detectors/attributes/locked_ether.py index 9436e4003..dc17ea6b9 100644 --- a/slither/detectors/attributes/locked_ether.py +++ b/slither/detectors/attributes/locked_ether.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]) diff --git a/slither/detectors/examples/backdoor.py b/slither/detectors/examples/backdoor.py index 9e29724f9..76fe19fcc 100644 --- a/slither/detectors/examples/backdoor.py +++ b/slither/detectors/examples/backdoor.py @@ -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 diff --git a/slither/detectors/functions/arbitrary_send.py b/slither/detectors/functions/arbitrary_send.py index c72cc84c0..0561fe61c 100644 --- a/slither/detectors/functions/arbitrary_send.py +++ b/slither/detectors/functions/arbitrary_send.py @@ -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) diff --git a/slither/detectors/functions/complex_function.py b/slither/detectors/functions/complex_function.py index f2521ad57..ab1260e21 100644 --- a/slither/detectors/functions/complex_function.py +++ b/slither/detectors/functions/complex_function.py @@ -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', diff --git a/slither/detectors/functions/suicidal.py b/slither/detectors/functions/suicidal.py index 8cc21cefe..aef4a9721 100644 --- a/slither/detectors/functions/suicidal.py +++ b/slither/detectors/functions/suicidal.py @@ -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) diff --git a/slither/detectors/naming_convention/naming_convention.py b/slither/detectors/naming_convention/naming_convention.py index ebf5e8c0b..7e64a01b2 100644 --- a/slither/detectors/naming_convention/naming_convention.py +++ b/slither/detectors/naming_convention/naming_convention.py @@ -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) diff --git a/slither/detectors/operations/low_level_calls.py b/slither/detectors/operations/low_level_calls.py index a5a7e828a..2bc74099f 100644 --- a/slither/detectors/operations/low_level_calls.py +++ b/slither/detectors/operations/low_level_calls.py @@ -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) diff --git a/slither/detectors/variables/possible_const_state_variables.py b/slither/detectors/variables/possible_const_state_variables.py index e19a389d1..9edcc8703 100644 --- a/slither/detectors/variables/possible_const_state_variables.py +++ b/slither/detectors/variables/possible_const_state_variables.py @@ -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] diff --git a/slither/detectors/variables/uninitialized_state_variables.py b/slither/detectors/variables/uninitialized_state_variables.py index 86f54b048..a1650e6b7 100644 --- a/slither/detectors/variables/uninitialized_state_variables.py +++ b/slither/detectors/variables/uninitialized_state_variables.py @@ -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] diff --git a/slither/detectors/variables/uninitialized_storage_variables.py b/slither/detectors/variables/uninitialized_storage_variables.py index 37201b33c..be861a1ef 100644 --- a/slither/detectors/variables/uninitialized_storage_variables.py +++ b/slither/detectors/variables/uninitialized_storage_variables.py @@ -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] diff --git a/slither/detectors/variables/unused_state_variables.py b/slither/detectors/variables/unused_state_variables.py index 5be36163e..621e4d8fa 100644 --- a/slither/detectors/variables/unused_state_variables.py +++ b/slither/detectors/variables/unused_state_variables.py @@ -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] diff --git a/slither/solc_parsing/declarations/modifier.py b/slither/solc_parsing/declarations/modifier.py index 527c439e8..1341779c3 100644 --- a/slither/solc_parsing/declarations/modifier.py +++ b/slither/solc_parsing/declarations/modifier.py @@ -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)