Split constable-states and erc20-indexed findings into separate results

pull/226/head
David Pokora 6 years ago
parent be7b0de41d
commit 899b46b75d
No known key found for this signature in database
GPG Key ID: 3CED48D1BB21BDD7
  1. 17
      slither/detectors/erc20/unindexed_event_parameters.py
  2. 10
      slither/detectors/variables/possible_const_state_variables.py

@ -72,14 +72,15 @@ In this case, Transfer and Approval events should have the 'indexed' keyword on
for c in self.contracts:
unindexed_params = self.detect_erc20_unindexed_event_params(c)
if unindexed_params:
info = "{} ({}) does not mark important ERC20 parameters as 'indexed':\n"
info = info.format(c.name, c.source_mapping_str)
# Add each problematic event definition to our result list
for (event, parameter) in unindexed_params:
info += "\t-{} ({}) does not index parameter '{}'\n".format(event.name, event.source_mapping_str, parameter.name)
# Add the events to the JSON (note: we do not add the params/vars as they have no source mapping).
json = self.generate_json_result(info)
self.add_functions_to_json([event for event, _ in unindexed_params], json)
results.append(json)
info = "ERC20 event {}.{} ({}) does not index parameter '{}'\n".format(c.name, event.name, event.source_mapping_str, parameter.name)
# Add the events to the JSON (note: we do not add the params/vars as they have no source mapping).
json = self.generate_json_result(info)
self.add_function_to_json(event, json, {
"parameter_name": parameter.name
})
results.append(json)
return results

@ -67,7 +67,6 @@ class ConstCandidateStateVars(AbstractDetector):
""" Detect state variables that could be const
"""
results = []
all_info = ''
all_variables = [c.state_variables for c in self.slither.contracts]
all_variables = set([item for sublist in all_variables for item in sublist])
@ -84,13 +83,14 @@ class ConstCandidateStateVars(AbstractDetector):
if (not v in all_variables_written) and self._constant_initial_expression(v)]
# Order for deterministic results
constable_variables = sorted(constable_variables, key=lambda x: x.canonical_name)
# Create a result for each finding
for v in constable_variables:
info = "{}.{} should be constant ({})\n".format(v.contract.name,
v.name,
v.source_mapping_str)
all_info += info
if all_info != '':
json = self.generate_json_result(all_info)
self.add_variables_to_json(constable_variables, json)
json = self.generate_json_result(info)
self.add_variable_to_json(v, json)
results.append(json)
return results

Loading…
Cancel
Save