Merge pull request #84 from trailofbits/dev-refactor-json

Refactor json output
pull/86/head
Feist Josselin 6 years ago committed by GitHub
commit 6322e201f6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 3
      scripts/tests_generate_expected_json.sh
  2. 6
      scripts/travis_test.sh
  3. 34
      slither/detectors/abstract_detector.py
  4. 28
      slither/detectors/attributes/const_functions.py
  5. 10
      slither/detectors/attributes/constant_pragma.py
  6. 9
      slither/detectors/attributes/locked_ether.py
  7. 9
      slither/detectors/attributes/old_solc.py
  8. 12
      slither/detectors/examples/backdoor.py
  9. 12
      slither/detectors/functions/arbitrary_send.py
  10. 20
      slither/detectors/functions/complex_function.py
  11. 9
      slither/detectors/functions/external_function.py
  12. 8
      slither/detectors/functions/suicidal.py
  13. 111
      slither/detectors/naming_convention/naming_convention.py
  14. 15
      slither/detectors/operations/low_level_calls.py
  15. 10
      slither/detectors/operations/unused_return_values.py
  16. 35
      slither/detectors/reentrancy/reentrancy.py
  17. 16
      slither/detectors/statements/assembly.py
  18. 16
      slither/detectors/statements/controlled_delegatecall.py
  19. 11
      slither/detectors/statements/tx_origin.py
  20. 14
      slither/detectors/variables/possible_const_state_variables.py
  21. 17
      slither/detectors/variables/uninitialized_local_variables.py
  22. 14
      slither/detectors/variables/uninitialized_state_variables.py
  23. 14
      slither/detectors/variables/uninitialized_storage_variables.py
  24. 11
      slither/detectors/variables/unused_state_variables.py
  25. 52
      tests/expected_json/arbitrary_send.arbitrary-send.json
  26. 10
      tests/expected_json/backdoor.backdoor.json
  27. 12
      tests/expected_json/backdoor.suicidal.json
  28. 68
      tests/expected_json/const_state_variables.constable-states.json
  29. 80
      tests/expected_json/constant.constant-function.json
  30. 36
      tests/expected_json/controlled_delegatecall.controlled-delegatecall.json
  31. 68
      tests/expected_json/external_function.external-function.json
  32. 34
      tests/expected_json/inline_assembly_contract.assembly.json
  33. 68
      tests/expected_json/inline_assembly_library.assembly.json
  34. 13
      tests/expected_json/locked_ether.locked-ether.json
  35. 23
      tests/expected_json/low_level_calls.low-level-calls.json
  36. 221
      tests/expected_json/naming_convention.naming-convention.json
  37. 12
      tests/expected_json/old_solc.sol.json.solc-version.json
  38. 16
      tests/expected_json/pragma.0.4.24.pragma.json
  39. 60
      tests/expected_json/reentrancy.reentrancy.json
  40. 48
      tests/expected_json/tx_origin.tx-origin.json
  41. 126
      tests/expected_json/uninitialized.uninitialized-state.json
  42. 30
      tests/expected_json/uninitialized_local_variable.uninitialized-local.json
  43. 30
      tests/expected_json/uninitialized_storage_pointer.uninitialized-storage.json
  44. 47
      tests/expected_json/unused_return.unused-return.json
  45. 14
      tests/expected_json/unused_state.unused-state.json

@ -38,5 +38,6 @@ generate_expected_json(){
#generate_expected_json tests/naming_convention.sol "naming-convention"
#generate_expected_json tests/uninitialized_local_variable.sol "uninitialized-local"
#generate_expected_json tests/controlled_delegatecall.sol "controlled-delegatecall"
generate_expected_json tests/constant.sol "constant-function"
#generate_expected_json tests/constant.sol "constant-function"
#generate_expected_json tests/unused_return.sol "unused-return"

@ -12,6 +12,11 @@ test_slither(){
# run slither detector on input file and save output as json
slither "$1" --disable-solc-warnings --detect "$2" --json "$DIR/tmp-test.json"
if [ $? -eq 255 ]
then
echo "Slither crashed"
exit -1
fi
# convert json file to pretty print and write to destination folder
python "$DIR/pretty_print_and_sort_json.py" "$DIR/tmp-test.json" "$actual"
@ -87,7 +92,6 @@ test_slither tests/naming_convention.sol "naming-convention"
#test_slither tests/complex_func.sol "complex-function"
test_slither tests/controlled_delegatecall.sol "controlled-delegatecall"
test_slither tests/constant.sol "constant-function"
# TODO: update to the new testing framework
test_slither tests/unused_return.sol "unused-return"

@ -79,3 +79,37 @@ class AbstractDetector(metaclass=abc.ABCMeta):
@property
def color(self):
return classification_colors[self.IMPACT]
def generate_json_result(self):
return {'check': self.ARGUMENT}
@staticmethod
def add_variable_to_json(variable, d):
assert 'variable' not in d
d['variable'] = {'name': variable.name, 'source_mapping': variable.source_mapping}
@staticmethod
def add_variables_to_json(variables, d):
assert 'variables' not in d
d['variables'] = [{'name': variable.name,
'source_mapping': variable.source_mapping}
for variable in variables]
@staticmethod
def add_function_to_json(function, d):
assert 'function' not in d
d['function'] = {'name': function.name, 'source_mapping': function.source_mapping}
@staticmethod
def add_functions_to_json(functions, d):
assert 'functions' not in d
d['functions'] = [{'name': function.name,
'source_mapping': function.source_mapping}
for function in functions]
@staticmethod
def add_nodes_to_json(nodes, d):
assert 'expressions' not in d
d['expressions'] = [{'expression': str(node.expression),
'source_mapping': node.source_mapping}
for node in nodes]

@ -35,14 +35,11 @@ class ConstantFunctions(AbstractDetector):
info = '{}.{} ({}) is declared {} but contains assembly code\n'
info = info.format(f.contract.name, f.name, f.source_mapping_str, attr)
self.log(info)
sourceMapping = [f.source_mapping]
results.append({'vuln': 'ConstFunction',
'sourceMapping': sourceMapping,
'filename': self.filename,
'contract': c.name,
'function_name': f.name,
'contains_assembly': True,
'varsWritten': []})
json = self.generate_json_result()
self.add_function_to_json(f, json)
json['variables'] = []
json['contains_assembly'] = True
results.append(json)
variables_written = f.all_state_variables_written()
if variables_written:
@ -53,11 +50,12 @@ class ConstantFunctions(AbstractDetector):
info += '\t- {}.{}\n'.format(variable_written.contract.name,
variable_written.name)
self.log(info)
results.append({'vuln': 'ConstFunction',
'sourceMapping': f.source_mapping,
'filename': self.filename,
'contract': c.name,
'function_name': f.name,
'contains_assembly': False,
'varsWritten': [str(x) for x in variables_written]})
json = self.generate_json_result()
self.add_function_to_json(f, json)
self.add_variables_to_json(variables_written, json)
json['contains_assembly'] = False
results.append(json)
return results

@ -30,10 +30,10 @@ class ConstantPragma(AbstractDetector):
info += "\t- {} declares {}\n".format(p.source_mapping_str, str(p))
self.log(info)
source = [p.source_mapping for p in pragma]
results.append({'vuln': 'ConstantPragma',
'versions': versions,
'sourceMapping': source})
json = self.generate_json_result()
# follow the same format than add_nodes_to_json
json['expressions'] = [{'expression': p.version,
'source_mapping': p.source_mapping} for p in pragma]
results.append(json)
return results

@ -56,11 +56,8 @@ class LockedEther(AbstractDetector):
[f.name for f in funcs_payable])
self.log(info)
source = [f.source_mapping for f in funcs_payable]
results.append({'vuln': 'LockedEther',
'functions_payable' : [f.name for f in funcs_payable],
'contract': contract.name,
'sourceMapping': source})
json = self.generate_json_result()
self.add_functions_to_json(funcs_payable, json)
results.append(json)
return results

@ -33,9 +33,10 @@ class OldSolc(AbstractDetector):
info += "\t- {} declares {}\n".format(p.source_mapping_str, str(p))
self.log(info)
source = [p.source_mapping for p in pragma]
results.append({'vuln': 'OldPragma',
'pragma': [p.version for p in old_pragma],
'sourceMapping': source})
json = self.generate_json_result()
# follow the same format than add_nodes_to_json
json['expressions'] = [{'expression': p.version,
'source_mapping': p.source_mapping} for p in old_pragma]
results.append(json)
return results

@ -12,7 +12,7 @@ class Backdoor(AbstractDetector):
CONFIDENCE = DetectorClassification.HIGH
def detect(self):
ret = []
results = []
for contract in self.slither.contracts_derived:
# Check if a function has 'backdoor' in its name
@ -23,8 +23,10 @@ class Backdoor(AbstractDetector):
info = info.format(contract.name, f.name, f.source_mapping_str)
# Print the info
self.log(info)
# Add the result in ret
source = f.source_mapping
ret.append({'vuln': 'backdoor', 'contract': contract.name, 'sourceMapping' : source})
# Add the result in result
json = self.generate_json_result()
self.add_function_to_json(f, json)
results.append(json)
return ret
return results

@ -100,7 +100,6 @@ class ArbitrarySend(AbstractDetector):
for c in self.contracts:
arbitrary_send = self.detect_arbitrary_send(c)
for (func, nodes) in arbitrary_send:
calls_str = [str(node.expression) for node in nodes]
info = "{}.{} ({}) sends eth to arbirary user\n"
info = info.format(func.contract.name,
@ -112,13 +111,10 @@ class ArbitrarySend(AbstractDetector):
self.log(info)
source_mapping = [node.source_mapping for node in nodes]
results.append({'vuln': 'ArbitrarySend',
'sourceMapping': source_mapping,
'filename': self.filename,
'contract': func.contract.name,
'function': func.name,
'calls': calls_str})
json = self.generate_json_result()
self.add_function_to_json(func, json)
self.add_nodes_to_json(nodes, json)
results.append(json)
return results

@ -89,9 +89,8 @@ class ComplexFunction(AbstractDetector):
for issue in issues:
func, cause = issue.values()
func_name = func.name
txt = "Complex function in {}\n\t- {}.{} ({})\n"
txt = "{}.{} ({}) is a complex function:\n"
if cause == self.CAUSE_EXTERNAL_CALL:
txt += "\t- Reason: High number of external calls"
@ -100,17 +99,18 @@ class ComplexFunction(AbstractDetector):
if cause == self.CAUSE_STATE_VARS:
txt += "\t- Reason: High number of modified state variables"
info = txt.format(self.filename,
contract.name,
func_name,
info = txt.format(func.contract.name,
func.name,
func.source_mapping_str)
info = info + "\n"
self.log(info)
results.append({'vuln': 'ComplexFunc',
'sourceMapping': func.source_mapping,
'filename': self.filename,
'contract': contract.name,
'function': func_name})
json = self.generate_json_result()
self.add_function_to_json(func, json)
json['high_number_of_external_calls'] = cause == self.CAUSE_EXTERNAL_CALL
json['high_number_of_branches'] = cause == self.CAUSE_CYCLOMATIC
json['high_number_of_state_variables'] = cause == self.CAUSE_STATE_VARS
results.append(json)
return results

@ -64,11 +64,10 @@ class ExternalFunction(AbstractDetector):
func.name,
func.source_mapping_str)
all_info += info
results.append({'vuln': 'ExternalFunc',
'sourceMapping': func.source_mapping,
'filename': self.filename,
'contract': func.contract.name,
'function': func.name})
json = self.generate_json_result()
self.add_function_to_json(func, json)
results.append(json)
if all_info != '':
self.log(all_info)
return results

@ -64,10 +64,8 @@ class Suicidal(AbstractDetector):
self.log(info)
results.append({'vuln': 'SuicidalFunc',
'sourceMapping': func.source_mapping,
'filename': self.filename,
'contract': c.name,
'function': func.name})
json = self.generate_json_result()
self.add_function_to_json(func, json)
results.append(json)
return results

@ -48,13 +48,15 @@ class NamingConvention(AbstractDetector):
for contract in self.contracts:
if not self.is_cap_words(contract.name):
info = "Contract '{}' ({}) is not in CapWords\n".format(contract.name, contract.source_mapping_str)
info = "Contract '{}' ({}) is not in CapWords\n".format(contract.name,
contract.source_mapping_str)
all_info += info
results.append({'vuln': 'NamingConvention',
'filename': self.filename,
'contract': contract.name,
'sourceMapping': contract.source_mapping})
results.append({'check': self.ARGUMENT,
'type': 'contract',
'convention':'CapWords',
'name':{'name': contract.name,
'source_mapping': contract.source_mapping}})
for struct in contract.structures:
if struct.contract != contract:
@ -65,11 +67,12 @@ class NamingConvention(AbstractDetector):
info = info.format(struct.contract.name, struct.name, struct.source_mapping_str)
all_info += info
results.append({'vuln': 'NamingConvention',
'filename': self.filename,
'contract': contract.name,
'struct': struct.name,
'sourceMapping': struct.source_mapping})
results.append({'check': self.ARGUMENT,
'type': 'structure',
'convention':'CapWords',
'name':{'name': struct.name,
'source_mapping': struct.source_mapping}})
for event in contract.events:
if event.contract != contract:
@ -80,11 +83,12 @@ class NamingConvention(AbstractDetector):
info = info.format(event.contract.name, event.name, event.source_mapping_str)
all_info += info
results.append({'vuln': 'NamingConvention',
'filename': self.filename,
'contract': contract.name,
'event': event.name,
'sourceMapping': event.source_mapping})
results.append({'check': self.ARGUMENT,
'type': 'event',
'convention':'CapWords',
'name':{'name': event.name,
'source_mapping': event.source_mapping}})
for func in contract.functions:
if func.contract != contract:
@ -95,11 +99,11 @@ class NamingConvention(AbstractDetector):
info = info.format(func.contract.name, func.name, func.source_mapping_str)
all_info += info
results.append({'vuln': 'NamingConvention',
'filename': self.filename,
'contract': contract.name,
'function': func.name,
'sourceMapping': func.source_mapping})
results.append({'check': self.ARGUMENT,
'type': 'function',
'convention':'mixedCase',
'name':{'name': func.name,
'source_mapping': func.source_mapping}})
for argument in func.parameters:
if argument in func.variables_read_or_written:
@ -114,13 +118,11 @@ class NamingConvention(AbstractDetector):
argument.source_mapping_str)
all_info += info
results.append({'vuln': 'NamingConvention',
'filename': self.filename,
'contract': contract.name,
'function': func.name,
'argument': argument.name,
'sourceMapping': argument.source_mapping})
results.append({'check': self.ARGUMENT,
'type': 'parameter',
'convention':'mixedCase',
'name':{'name': argument.name,
'source_mapping': argument.source_mapping}})
for var in contract.state_variables:
if var.contract != contract:
@ -132,11 +134,11 @@ class NamingConvention(AbstractDetector):
info = info.format(var.contract.name, var.name, var.source_mapping_str)
all_info += info
results.append({'vuln': 'NamingConvention',
'filename': self.filename,
'contract': contract.name,
'constant': var.name,
'sourceMapping': var.source_mapping})
results.append({'check': self.ARGUMENT,
'type': 'variable',
'convention':'l_O_I_should_not_be_used',
'name':{'name': var.name,
'source_mapping': var.source_mapping}})
if var.is_constant is True:
# For ERC20 compatibility
@ -148,11 +150,11 @@ class NamingConvention(AbstractDetector):
info = info.format(var.contract.name, var.name, var.source_mapping_str)
all_info += info
results.append({'vuln': 'NamingConvention',
'filename': self.filename,
'contract': contract.name,
'constant': var.name,
'sourceMapping': var.source_mapping})
results.append({'check': self.ARGUMENT,
'type': 'variable_constant',
'convention':'UPPER_CASE_WITH_UNDERSCORES',
'name':{'name': var.name,
'source_mapping': var.source_mapping}})
else:
if var.visibility == 'private':
correct_naming = self.is_mixed_case_with_underscore(var.name)
@ -163,12 +165,11 @@ class NamingConvention(AbstractDetector):
info = info.format(var.contract.name, var.name, var.source_mapping_str)
all_info += info
results.append({'vuln': 'NamingConvention',
'filename': self.filename,
'contract': contract.name,
'variable': var.name,
'sourceMapping': var.source_mapping})
results.append({'check': self.ARGUMENT,
'type': 'variable',
'convention':'mixedCase',
'name':{'name': var.name,
'source_mapping': var.source_mapping}})
for enum in contract.enums:
if enum.contract != contract:
@ -179,11 +180,11 @@ class NamingConvention(AbstractDetector):
info = info.format(enum.contract.name, enum.name, enum.source_mapping_str)
all_info += info
results.append({'vuln': 'NamingConvention',
'filename': self.filename,
'contract': contract.name,
'enum': enum.name,
'sourceMapping': enum.source_mapping})
results.append({'check': self.ARGUMENT,
'type': 'enum',
'convention':'CapWords',
'name':{'name': enum.name,
'source_mapping': enum.source_mapping}})
for modifier in contract.modifiers:
if modifier.contract != contract:
@ -191,14 +192,16 @@ class NamingConvention(AbstractDetector):
if not self.is_mixed_case(modifier.name):
info = "Modifier '{}.{}' ({}) is not in mixedCase\n"
info = info.format(modifier.contract.name, modifier.name, modifier.source_mapping_str)
info = info.format(modifier.contract.name,
modifier.name,
modifier.source_mapping_str)
all_info += info
results.append({'vuln': 'NamingConvention',
'filename': self.filename,
'contract': contract.name,
'modifier': modifier.name,
'sourceMapping': modifier.source_mapping})
results.append({'check': self.ARGUMENT,
'type': 'modifier',
'convention':'mixedCase',
'name':{'name': modifier.name,
'source_mapping': modifier.source_mapping}})
if all_info != '':
self.log(all_info)

@ -45,17 +45,18 @@ 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 {}.{} ({})\n"
info = "Low level call in {}.{} ({}):\n"
info = info.format(func.contract.name, func.name, func.source_mapping_str)
for node in nodes:
info += "\t-{} {}\n".format(str(node.expression), node.source_mapping_str)
all_info += info
sourceMapping = [n.source_mapping for n in nodes]
json = self.generate_json_result()
self.add_function_to_json(func, json)
self.add_nodes_to_json(nodes, json)
results.append(json)
results.append({'vuln': 'Low level call',
'sourceMapping': sourceMapping,
'filename': self.filename,
'contract': func.contract.name,
'function': func.name})
if all_info != '':
self.log(all_info)

@ -60,11 +60,9 @@ class UnusedReturnValues(AbstractDetector):
info += "\t-{} ({})\n".format(node.expression, node.source_mapping_str)
self.log(info)
sourceMapping = [v.source_mapping for v in unused_return]
json = self.generate_json_result()
self.add_function_to_json(f, json)
self.add_nodes_to_json(unused_return, json)
results.append(json)
results.append({'vuln': 'UnusedReturn',
'sourceMapping': sourceMapping,
'filename': self.filename,
'contract': c.name,
'expressions':[str(n.expression) for n in unused_return]})
return results

@ -128,7 +128,7 @@ class Reentrancy(AbstractDetector):
if isinstance(internal_call, Function):
state_vars_written += internal_call.all_state_variables_written()
read_then_written = [(v, node.source_mapping_str) for v in state_vars_written if v in node.context[self.key]['read']]
read_then_written = [(v, node) for v in state_vars_written if v in node.context[self.key]['read']]
node.context[self.key]['read'] = list(set(node.context[self.key]['read'] + node.state_variables_read))
# If a state variables was read and is then written, there is a dangerous call and
@ -194,21 +194,26 @@ class Reentrancy(AbstractDetector):
for call_info in send_eth:
info += '\t- {} ({})\n'.format(call_info.expression, call_info.source_mapping_str)
info += '\tState variables written after the call(s):\n'
for (v, mapping) in varsWritten:
info += '\t- {} ({})\n'.format(v, mapping)
for (v, node) in varsWritten:
info += '\t- {} ({})\n'.format(v, node.source_mapping_str)
self.log(info)
source = [v.source_mapping for (v,_) in varsWritten]
source += [node.source_mapping for node in calls]
source += [node.source_mapping for node in send_eth]
results.append({'vuln': 'Reentrancy',
'sourceMapping': source,
'filename': self.filename,
'contract': func.contract.name,
'function': func.name,
'calls': [str(x.expression) for x in calls],
'send_eth': [str(x.expression) for x in send_eth],
'varsWritten': [str(x) for (x,_) in varsWritten]})
sending_eth_json = []
if calls != send_eth:
sending_eth_json = [{'expression': str(call_info.expression),
'source_mapping': call_info.source_mapping}
for call_info in calls]
json = self.generate_json_result()
self.add_function_to_json(func, json)
json['external_calls'] = [{'expression': str(call_info.expression),
'source_mapping': call_info.source_mapping}
for call_info in calls]
json['external_calls_sending_eth'] = sending_eth_json
json['variables_written'] = [{'name': v.name,
'expression': str(node.expression),
'source_mapping': node.source_mapping}
for (v, node) in varsWritten]
results.append(json)
return results

@ -49,15 +49,17 @@ class Assembly(AbstractDetector):
for func, nodes in values:
info = "{}.{} uses assembly ({})\n"
info = info.format(func.contract.name, func.name, func.source_mapping_str)
all_info += info
sourceMapping = [n.source_mapping for n in nodes]
for node in nodes:
info += "\t- {}\n".format(node.source_mapping_str)
all_info += info
results.append({'vuln': 'Assembly',
'sourceMapping': sourceMapping,
'filename': self.filename,
'contract': func.contract.name,
'function': func.name})
json = self.generate_json_result()
self.add_function_to_json(func, json)
json['assembly'] = [{'source_mapping': node.source_mapping}
for node in nodes]
results.append(json)
if all_info != '':
self.log(all_info)

@ -23,7 +23,7 @@ class ControlledDelegateCall(AbstractDetector):
return ret
def detect(self):
ret = []
results = []
for contract in self.slither.contracts:
for f in contract.functions:
@ -34,12 +34,12 @@ class ControlledDelegateCall(AbstractDetector):
info = '{}.{} ({}) uses delegatecall to a input-controlled function id\n'
info = info.format(contract.name, f.name, f.source_mapping_str)
for node in nodes:
info += '\t{} ({})'.format(node.expression, node.source_mapping_str)
info += '\t{} ({})\n'.format(node.expression, node.source_mapping_str)
self.log(info)
source = [f.source_mapping] + [node.source_mapping for node in nodes]
ret.append({'vuln': 'controlled_delegatecall',
'contract': contract.name,
'function':f.name,
'sourceMapping' : source})
return ret
json = self.generate_json_result()
self.add_function_to_json(f, json)
self.add_nodes_to_json(nodes, json)
results.append(json)
return results

@ -58,12 +58,9 @@ class TxOrigin(AbstractDetector):
self.log(info)
sourceMapping = [n.source_mapping for n in nodes]
results.append({'vuln': 'TxOrigin',
'sourceMapping': sourceMapping,
'filename': self.filename,
'contract': func.contract.name,
'function': func.name})
json = self.generate_json_result()
self.add_function_to_json(func, json)
self.add_nodes_to_json(nodes, json)
results.append(json)
return results

@ -66,17 +66,15 @@ class ConstCandidateStateVars(AbstractDetector):
variables_by_contract[state_var.contract.name].append(state_var)
for contract, variables in variables_by_contract.items():
variable_names = [v.name for v in variables]
for v in variables:
all_info += "{}.{} should be constant ({})\n".format(contract, v.name, v.source_mapping_str)
all_info += "{}.{} should be constant ({})\n".format(contract,
v.name,
v.source_mapping_str)
sourceMapping = [v.source_mapping for v in const_candidates]
json = self.generate_json_result()
self.add_variables_to_json(variables, json)
results.append(json)
results.append({'vuln': 'ConstStateVariableCandidates',
'sourceMapping': sourceMapping,
'filename': self.filename,
'contract': c.name,
'unusedVars': variable_names})
if all_info != '':
self.log(all_info)
return results

@ -86,17 +86,16 @@ class UninitializedLocalVars(AbstractDetector):
var_name = uninitialized_local_variable.name
info = "{} in {}.{} ({}) is a local variable never initialiazed\n"
info = info.format(var_name, function.contract.name, function.name, uninitialized_local_variable.source_mapping_str)
info = info.format(var_name,
function.contract.name,
function.name,
uninitialized_local_variable.source_mapping_str)
self.log(info)
source = [function.source_mapping, uninitialized_local_variable.source_mapping]
results.append({'vuln': 'UninitializedLocalVars',
'sourceMapping': source,
'filename': self.filename,
'contract': function.contract.name,
'function': function.name,
'variable': var_name})
json = self.generate_json_result()
self.add_variable_to_json(uninitialized_local_variable, json)
self.add_function_to_json(function, json)
results.append(json)
return results

@ -75,7 +75,9 @@ class UninitializedStateVarsDetection(AbstractDetector):
ret = self.detect_uninitialized(c)
for variable, functions in ret:
info = "{}.{} ({}) is never initialized. It is used in:\n"
info = info.format(variable.contract.name, variable.name, variable.source_mapping_str)
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)
@ -83,11 +85,9 @@ class UninitializedStateVarsDetection(AbstractDetector):
source = [variable.source_mapping]
source += [f.source_mapping for f in functions]
results.append({'vuln': 'UninitializedStateVars',
'sourceMapping': source,
'filename': self.filename,
'contract': c.name,
'functions': [str(f) for f in functions],
'variable': str(variable)})
json = self.generate_json_result()
self.add_variable_to_json(variable, json)
self.add_functions_to_json(functions, json)
results.append(json)
return results

@ -88,13 +88,11 @@ class UninitializedStorageVars(AbstractDetector):
self.log(info)
source = [function.source_mapping, uninitialized_storage_variable.source_mapping]
results.append({'vuln': 'UninitializedStorageVars',
'sourceMapping': source,
'filename': self.filename,
'contract': function.contract.name,
'function': function.name,
'variable': var_name})
json = self.generate_json_result()
self.add_variable_to_json(uninitialized_storage_variable, json)
self.add_function_to_json(function, json)
results.append(json)
return results

@ -36,7 +36,6 @@ class UnusedStateVars(AbstractDetector):
for c in self.slither.contracts_derived:
unusedVars = self.detect_unused(c)
if unusedVars:
unusedVarsName = [v.name for v in unusedVars]
info = ''
for var in unusedVars:
info += "{}.{} ({}) is never used in {}\n".format(var.contract.name,
@ -45,13 +44,11 @@ class UnusedStateVars(AbstractDetector):
c.name)
all_info += info
sourceMapping = [v.source_mapping for v in unusedVars]
results.append({'vuln': 'unusedStateVars',
'sourceMapping': sourceMapping,
'filename': self.filename,
'contract': c.name,
'unusedVars': unusedVarsName})
json = self.generate_json_result()
self.add_variables_to_json(unusedVars, json)
results.append(json)
if all_info != '':
self.log(all_info)
return results

@ -1,13 +1,10 @@
[
{
"calls": [
"msg.sender.send(this.balance)"
],
"contract": "Test",
"filename": "tests/arbitrary_send.sol",
"function": "direct",
"sourceMapping": [
"check": "arbitrary-send",
"expressions": [
{
"expression": "msg.sender.send(this.balance)",
"source_mapping": {
"filename": "tests/arbitrary_send.sol",
"length": 29,
"lines": [
@ -15,18 +12,28 @@
],
"start": 174
}
}
],
"function": {
"name": "direct",
"source_mapping": {
"filename": "tests/arbitrary_send.sol",
"length": 63,
"lines": [
11,
12,
13
],
"vuln": "ArbitrarySend"
"start": 147
}
}
},
{
"calls": [
"destination.send(this.balance)"
],
"contract": "Test",
"filename": "tests/arbitrary_send.sol",
"function": "indirect",
"sourceMapping": [
"check": "arbitrary-send",
"expressions": [
{
"expression": "destination.send(this.balance)",
"source_mapping": {
"filename": "tests/arbitrary_send.sol",
"length": 30,
"lines": [
@ -34,7 +41,20 @@
],
"start": 307
}
}
],
"function": {
"name": "indirect",
"source_mapping": {
"filename": "tests/arbitrary_send.sol",
"length": 66,
"lines": [
19,
20,
21
],
"vuln": "ArbitrarySend"
"start": 278
}
}
}
]

@ -1,7 +1,9 @@
[
{
"contract": "C",
"sourceMapping": {
"check": "backdoor",
"function": {
"name": "i_am_a_backdoor",
"source_mapping": {
"filename": "tests/backdoor.sol",
"length": 74,
"lines": [
@ -10,7 +12,7 @@
7
],
"start": 43
},
"vuln": "backdoor"
}
}
}
]

@ -1,9 +1,9 @@
[
{
"contract": "C",
"filename": "tests/backdoor.sol",
"function": "i_am_a_backdoor",
"sourceMapping": {
"check": "suicidal",
"function": {
"name": "i_am_a_backdoor",
"source_mapping": {
"filename": "tests/backdoor.sol",
"length": 74,
"lines": [
@ -12,7 +12,7 @@
7
],
"start": 43
},
"vuln": "SuicidalFunc"
}
}
}
]

@ -1,77 +1,48 @@
[
{
"contract": "B",
"filename": "tests/const_state_variables.sol",
"sourceMapping": [
{
"filename": "tests/const_state_variables.sol",
"length": 20,
"lines": [
10
],
"start": 235
},
{
"filename": "tests/const_state_variables.sol",
"length": 20,
"lines": [
14
],
"start": 331
},
"check": "constable-states",
"variables": [
{
"name": "myFriendsAddress",
"source_mapping": {
"filename": "tests/const_state_variables.sol",
"length": 76,
"lines": [
7
],
"start": 130
},
{
"filename": "tests/const_state_variables.sol",
"length": 76,
"lines": [
26
],
"start": 494
}
],
"unusedVars": [
"myFriendsAddress",
"test",
"text2"
],
"vuln": "ConstStateVariableCandidates"
},
{
"contract": "B",
"filename": "tests/const_state_variables.sol",
"sourceMapping": [
{
"name": "test",
"source_mapping": {
"filename": "tests/const_state_variables.sol",
"length": 20,
"lines": [
10
],
"start": 235
}
},
{
"name": "text2",
"source_mapping": {
"filename": "tests/const_state_variables.sol",
"length": 20,
"lines": [
14
],
"start": 331
}
}
]
},
{
"filename": "tests/const_state_variables.sol",
"length": 76,
"lines": [
7
],
"start": 130
},
"check": "constable-states",
"variables": [
{
"name": "mySistersAddress",
"source_mapping": {
"filename": "tests/const_state_variables.sol",
"length": 76,
"lines": [
@ -79,10 +50,7 @@
],
"start": 494
}
],
"unusedVars": [
"mySistersAddress"
],
"vuln": "ConstStateVariableCandidates"
}
]
}
]

@ -1,10 +1,40 @@
[
{
"check": "constant-function",
"contains_assembly": false,
"contract": "Constant",
"function": {
"name": "test_view_bug",
"source_mapping": {
"filename": "tests/constant.sol",
"function_name": "test_constant_bug",
"sourceMapping": {
"length": 58,
"lines": [
5,
6,
7
],
"start": 45
}
},
"variables": [
{
"name": "a",
"source_mapping": {
"filename": "tests/constant.sol",
"length": 6,
"lines": [
3
],
"start": 28
}
}
]
},
{
"check": "constant-function",
"contains_assembly": false,
"function": {
"name": "test_constant_bug",
"source_mapping": {
"filename": "tests/constant.sol",
"length": 66,
"lines": [
@ -13,39 +43,28 @@
11
],
"start": 113
}
},
"varsWritten": [
"a"
],
"vuln": "ConstFunction"
},
"variables": [
{
"contains_assembly": false,
"contract": "Constant",
"filename": "tests/constant.sol",
"function_name": "test_view_bug",
"sourceMapping": {
"name": "a",
"source_mapping": {
"filename": "tests/constant.sol",
"length": 58,
"length": 6,
"lines": [
5,
6,
7
3
],
"start": 45
},
"varsWritten": [
"a"
],
"vuln": "ConstFunction"
"start": 28
}
}
]
},
{
"check": "constant-function",
"contains_assembly": true,
"contract": "Constant",
"filename": "tests/constant.sol",
"function_name": "test_assembly_bug",
"sourceMapping": [
{
"function": {
"name": "test_assembly_bug",
"source_mapping": {
"filename": "tests/constant.sol",
"length": 66,
"lines": [
@ -55,8 +74,7 @@
],
"start": 324
}
],
"varsWritten": [],
"vuln": "ConstFunction"
},
"variables": []
}
]

@ -1,17 +1,22 @@
[
{
"contract": "C",
"function": "bad_delegate_call",
"sourceMapping": [
"check": "controlled-delegatecall",
"expressions": [
{
"expression": "addr_bad.delegatecall(data)",
"source_mapping": {
"filename": "tests/controlled_delegatecall.sol",
"length": 27,
"lines": [
10
],
"start": 178
},
{
}
}
],
"function": {
"name": "bad_delegate_call",
"source_mapping": {
"filename": "tests/controlled_delegatecall.sol",
"length": 120,
"lines": [
@ -22,22 +27,26 @@
],
"start": 92
}
],
"vuln": "controlled_delegatecall"
}
},
{
"contract": "C",
"function": "bad_delegate_call2",
"sourceMapping": [
"check": "controlled-delegatecall",
"expressions": [
{
"expression": "addr_bad.delegatecall(func_id,data)",
"source_mapping": {
"filename": "tests/controlled_delegatecall.sol",
"length": 36,
"lines": [
19
],
"start": 356
},
{
}
}
],
"function": {
"name": "bad_delegate_call2",
"source_mapping": {
"filename": "tests/controlled_delegatecall.sol",
"length": 92,
"lines": [
@ -47,7 +56,6 @@
],
"start": 307
}
],
"vuln": "controlled_delegatecall"
}
}
]

@ -1,25 +1,25 @@
[
{
"contract": "ContractWithFunctionNotCalled",
"check": "external-function",
"function": {
"name": "funcNotCalled3",
"source_mapping": {
"filename": "tests/external_function.sol",
"function": "funcNotCalled",
"sourceMapping": {
"filename": "tests/external_function.sol",
"length": 40,
"length": 41,
"lines": [
21,
22,
23
13,
14,
15
],
"start": 351
},
"vuln": "ExternalFunc"
"start": 257
}
}
},
{
"contract": "ContractWithFunctionNotCalled",
"filename": "tests/external_function.sol",
"function": "funcNotCalled2",
"sourceMapping": {
"check": "external-function",
"function": {
"name": "funcNotCalled2",
"source_mapping": {
"filename": "tests/external_function.sol",
"length": 41,
"lines": [
@ -28,30 +28,30 @@
19
],
"start": 304
},
"vuln": "ExternalFunc"
}
}
},
{
"contract": "ContractWithFunctionNotCalled",
"check": "external-function",
"function": {
"name": "funcNotCalled",
"source_mapping": {
"filename": "tests/external_function.sol",
"function": "funcNotCalled3",
"sourceMapping": {
"filename": "tests/external_function.sol",
"length": 41,
"length": 40,
"lines": [
13,
14,
15
21,
22,
23
],
"start": 257
},
"vuln": "ExternalFunc"
"start": 351
}
}
},
{
"contract": "ContractWithFunctionNotCalled2",
"filename": "tests/external_function.sol",
"function": "funcNotCalled",
"sourceMapping": {
"check": "external-function",
"function": {
"name": "funcNotCalled",
"source_mapping": {
"filename": "tests/external_function.sol",
"length": 304,
"lines": [
@ -65,7 +65,7 @@
39
],
"start": 552
},
"vuln": "ExternalFunc"
}
}
}
]

@ -1,10 +1,8 @@
[
{
"contract": "GetCode",
"filename": "tests/inline_assembly_contract.sol",
"function": "at",
"sourceMapping": [
"assembly": [
{
"source_mapping": {
"filename": "tests/inline_assembly_contract.sol",
"length": 628,
"lines": [
@ -25,7 +23,33 @@
],
"start": 191
}
}
],
"vuln": "Assembly"
"check": "assembly",
"function": {
"name": "at",
"source_mapping": {
"filename": "tests/inline_assembly_contract.sol",
"length": 700,
"lines": [
6,
7,
8,
9,
10,
11,
12,
13,
14,
15,
16,
17,
18,
19,
20
],
"start": 119
}
}
}
]

@ -1,10 +1,8 @@
[
{
"contract": "VectorSum",
"filename": "tests/inline_assembly_library.sol",
"function": "sumAsm",
"sourceMapping": [
"assembly": [
{
"source_mapping": {
"filename": "tests/inline_assembly_library.sol",
"length": 114,
"lines": [
@ -15,15 +13,31 @@
],
"start": 720
}
}
],
"check": "assembly",
"function": {
"name": "sumAsm",
"source_mapping": {
"filename": "tests/inline_assembly_library.sol",
"length": 247,
"lines": [
16,
17,
18,
19,
20,
21,
22
],
"vuln": "Assembly"
"start": 593
}
}
},
{
"contract": "VectorSum",
"filename": "tests/inline_assembly_library.sol",
"function": "sumPureAsm",
"sourceMapping": [
"assembly": [
{
"source_mapping": {
"filename": "tests/inline_assembly_library.sol",
"length": 677,
"lines": [
@ -52,7 +66,41 @@
],
"start": 1000
}
}
],
"vuln": "Assembly"
"check": "assembly",
"function": {
"name": "sumPureAsm",
"source_mapping": {
"filename": "tests/inline_assembly_library.sol",
"length": 754,
"lines": [
25,
26,
27,
28,
29,
30,
31,
32,
33,
34,
35,
36,
37,
38,
39,
40,
41,
42,
43,
44,
45,
46,
47
],
"start": 923
}
}
}
]

@ -1,11 +1,10 @@
[
{
"contract": "OnlyLocked",
"functions_payable": [
"receive"
],
"sourceMapping": [
"check": "locked-ether",
"functions": [
{
"name": "receive",
"source_mapping": {
"filename": "tests/locked_ether.sol",
"length": 72,
"lines": [
@ -15,7 +14,7 @@
],
"start": 47
}
],
"vuln": "LockedEther"
}
]
}
]

@ -1,10 +1,10 @@
[
{
"contract": "Sender",
"filename": "tests/low_level_calls.sol",
"function": "send",
"sourceMapping": [
"check": "low-level-calls",
"expressions": [
{
"expression": "_receiver.call.value(msg.value).gas(7777)()",
"source_mapping": {
"filename": "tests/low_level_calls.sol",
"length": 43,
"lines": [
@ -12,7 +12,20 @@
],
"start": 100
}
}
],
"vuln": "Low level call"
"function": {
"name": "send",
"source_mapping": {
"filename": "tests/low_level_calls.sol",
"length": 101,
"lines": [
5,
6,
7
],
"start": 49
}
}
}
]

@ -1,22 +1,10 @@
[
{
"contract": "T",
"filename": "tests/naming_convention.sol",
"sourceMapping": {
"filename": "tests/naming_convention.sol",
"length": 17,
"lines": [
56
],
"start": 695
},
"variable": "_myPublicVar",
"vuln": "NamingConvention"
},
{
"contract": "naming",
"filename": "tests/naming_convention.sol",
"sourceMapping": {
"check": "naming-convention",
"convention": "CapWords",
"name": {
"name": "naming",
"source_mapping": {
"filename": "tests/naming_convention.sol",
"length": 598,
"lines": [
@ -68,27 +56,48 @@
48
],
"start": 26
}
},
"vuln": "NamingConvention"
"type": "contract"
},
{
"contract": "naming",
"filename": "tests/naming_convention.sol",
"sourceMapping": {
"check": "naming-convention",
"convention": "CapWords",
"name": {
"name": "numbers",
"source_mapping": {
"filename": "tests/naming_convention.sol",
"length": 16,
"length": 23,
"lines": [
11
6
],
"start": 183
"start": 77
}
},
"variable": "Var_One",
"vuln": "NamingConvention"
"type": "enum"
},
{
"contract": "naming",
"check": "naming-convention",
"convention": "CapWords",
"name": {
"name": "event_",
"source_mapping": {
"filename": "tests/naming_convention.sol",
"sourceMapping": {
"length": 19,
"lines": [
23
],
"start": 303
}
},
"type": "event"
},
{
"check": "naming-convention",
"convention": "CapWords",
"name": {
"name": "test",
"source_mapping": {
"filename": "tests/naming_convention.sol",
"length": 20,
"lines": [
@ -97,31 +106,48 @@
16
],
"start": 227
}
},
"struct": "test",
"vuln": "NamingConvention"
"type": "structure"
},
{
"contract": "naming",
"filename": "tests/naming_convention.sol",
"modifier": "CantDo",
"sourceMapping": {
"check": "naming-convention",
"convention": "UPPER_CASE_WITH_UNDERSCORES",
"name": {
"name": "MY_other_CONSTANT",
"source_mapping": {
"filename": "tests/naming_convention.sol",
"length": 36,
"length": 35,
"lines": [
41,
42,
43
9
],
"start": 545
"start": 141
}
},
"vuln": "NamingConvention"
"type": "variable_constant"
},
{
"contract": "naming",
"check": "naming-convention",
"convention": "l_O_I_should_not_be_used",
"name": {
"name": "l",
"source_mapping": {
"filename": "tests/naming_convention.sol",
"function": "GetOne",
"sourceMapping": {
"length": 10,
"lines": [
67
],
"start": 847
}
},
"type": "variable"
},
{
"check": "naming-convention",
"convention": "mixedCase",
"name": {
"name": "GetOne",
"source_mapping": {
"filename": "tests/naming_convention.sol",
"length": 71,
"lines": [
@ -131,93 +157,90 @@
33
],
"start": 405
}
},
"vuln": "NamingConvention"
},
{
"contract": "naming",
"event": "event_",
"filename": "tests/naming_convention.sol",
"sourceMapping": {
"filename": "tests/naming_convention.sol",
"length": 19,
"lines": [
23
],
"start": 303
},
"vuln": "NamingConvention"
"type": "function"
},
{
"contract": "naming",
"enum": "numbers",
"check": "naming-convention",
"convention": "mixedCase",
"name": {
"name": "CantDo",
"source_mapping": {
"filename": "tests/naming_convention.sol",
"sourceMapping": {
"filename": "tests/naming_convention.sol",
"length": 23,
"length": 36,
"lines": [
6
41,
42,
43
],
"start": 77
"start": 545
}
},
"vuln": "NamingConvention"
"type": "modifier"
},
{
"constant": "MY_other_CONSTANT",
"contract": "naming",
"filename": "tests/naming_convention.sol",
"sourceMapping": {
"check": "naming-convention",
"convention": "mixedCase",
"name": {
"name": "Number2",
"source_mapping": {
"filename": "tests/naming_convention.sol",
"length": 35,
"length": 12,
"lines": [
9
35
],
"start": 141
"start": 512
}
},
"vuln": "NamingConvention"
"type": "parameter"
},
{
"constant": "l",
"contract": "T",
"filename": "tests/naming_convention.sol",
"sourceMapping": {
"check": "naming-convention",
"convention": "mixedCase",
"name": {
"name": "_used",
"source_mapping": {
"filename": "tests/naming_convention.sol",
"length": 10,
"lines": [
67
59
],
"start": 847
"start": 748
}
},
"vuln": "NamingConvention"
"type": "parameter"
},
{
"argument": "Number2",
"contract": "naming",
"filename": "tests/naming_convention.sol",
"function": "setInt",
"sourceMapping": {
"check": "naming-convention",
"convention": "mixedCase",
"name": {
"name": "Var_One",
"source_mapping": {
"filename": "tests/naming_convention.sol",
"length": 12,
"length": 16,
"lines": [
35
11
],
"start": 512
"start": 183
}
},
"vuln": "NamingConvention"
"type": "variable"
},
{
"argument": "_used",
"contract": "T",
"filename": "tests/naming_convention.sol",
"function": "test",
"sourceMapping": {
"check": "naming-convention",
"convention": "mixedCase",
"name": {
"name": "_myPublicVar",
"source_mapping": {
"filename": "tests/naming_convention.sol",
"length": 10,
"length": 17,
"lines": [
59
56
],
"start": 748
"start": 695
}
},
"vuln": "NamingConvention"
"type": "variable"
}
]

@ -1,16 +1,16 @@
[
{
"pragma": [
"0.4.21"
],
"sourceMapping": [
"check": "solc-version",
"expressions": [
{
"expression": "0.4.21",
"source_mapping": {
"filename": "old_solc.sol",
"length": 23,
"lines": [],
"start": 0
}
],
"vuln": "OldPragma"
}
]
}
]

@ -1,15 +1,21 @@
[
{
"sourceMapping": [
"check": "pragma",
"expressions": [
{
"expression": "^0.4.23",
"source_mapping": {
"filename": "tests/pragma.0.4.23.sol",
"length": 24,
"lines": [
1
],
"start": 0
}
},
{
"expression": "^0.4.24",
"source_mapping": {
"filename": "tests/pragma.0.4.24.sol",
"length": 24,
"lines": [
@ -17,11 +23,7 @@
],
"start": 0
}
],
"versions": [
"^0.4.23",
"^0.4.24"
],
"vuln": "ConstantPragma"
}
]
}
]

@ -1,24 +1,10 @@
[
{
"calls": [
"! (msg.sender.call.value(userBalance[msg.sender])())"
],
"contract": "Reentrancy",
"filename": "tests/reentrancy.sol",
"function": "withdrawBalance",
"send_eth": [
"! (msg.sender.call.value(userBalance[msg.sender])())"
],
"sourceMapping": [
{
"filename": "tests/reentrancy.sol",
"length": 37,
"lines": [
4
],
"start": 52
},
"check": "reentrancy",
"external_calls": [
{
"expression": "! (msg.sender.call.value(userBalance[msg.sender])())",
"source_mapping": {
"filename": "tests/reentrancy.sol",
"length": 92,
"lines": [
@ -27,21 +13,41 @@
19
],
"start": 478
},
{
}
}
],
"external_calls_sending_eth": [],
"function": {
"name": "withdrawBalance",
"source_mapping": {
"filename": "tests/reentrancy.sol",
"length": 92,
"length": 314,
"lines": [
14,
15,
16,
17,
18,
19
19,
20,
21
],
"start": 478
"start": 299
}
},
"variables_written": [
{
"expression": "userBalance[msg.sender] = 0",
"name": "userBalance",
"source_mapping": {
"filename": "tests/reentrancy.sol",
"length": 27,
"lines": [
20
],
"varsWritten": [
"userBalance"
],
"vuln": "Reentrancy"
"start": 579
}
}
]
}
]

@ -1,10 +1,10 @@
[
{
"contract": "TxOrigin",
"filename": "tests/tx_origin.sol",
"function": "bug0",
"sourceMapping": [
"check": "tx-origin",
"expressions": [
{
"expression": "require(bool)(tx.origin == owner)",
"source_mapping": {
"filename": "tests/tx_origin.sol",
"length": 27,
"lines": [
@ -12,15 +12,28 @@
],
"start": 140
}
}
],
"function": {
"name": "bug0",
"source_mapping": {
"filename": "tests/tx_origin.sol",
"length": 60,
"lines": [
9,
10,
11
],
"vuln": "TxOrigin"
"start": 114
}
}
},
{
"contract": "TxOrigin",
"filename": "tests/tx_origin.sol",
"function": "bug2",
"sourceMapping": [
"check": "tx-origin",
"expressions": [
{
"expression": "tx.origin != owner",
"source_mapping": {
"filename": "tests/tx_origin.sol",
"length": 57,
"lines": [
@ -30,7 +43,22 @@
],
"start": 206
}
}
],
"function": {
"name": "bug2",
"source_mapping": {
"filename": "tests/tx_origin.sol",
"length": 89,
"lines": [
13,
14,
15,
16,
17
],
"vuln": "TxOrigin"
"start": 180
}
}
}
]

@ -1,20 +1,39 @@
[
{
"contract": "Test",
"filename": "tests/uninitialized.sol",
"check": "uninitialized-state",
"functions": [
"use"
],
"sourceMapping": [
{
"name": "transfer",
"source_mapping": {
"filename": "tests/uninitialized.sol",
"length": 34,
"length": 82,
"lines": [
15
7,
8,
9
],
"start": 189
"start": 81
}
}
],
"variable": {
"name": "destination",
"source_mapping": {
"filename": "tests/uninitialized.sol",
"length": 19,
"lines": [
5
],
"start": 55
}
}
},
{
"check": "uninitialized-state",
"functions": [
{
"name": "use",
"source_mapping": {
"filename": "tests/uninitialized.sol",
"length": 143,
"lines": [
@ -25,26 +44,26 @@
],
"start": 356
}
}
],
"variable": "balances",
"vuln": "UninitializedStateVars"
},
{
"contract": "Test2",
"filename": "tests/uninitialized.sol",
"functions": [
"use"
],
"sourceMapping": [
{
"variable": {
"name": "balances",
"source_mapping": {
"filename": "tests/uninitialized.sol",
"length": 15,
"length": 34,
"lines": [
45
15
],
"start": 695
"start": 189
}
}
},
{
"check": "uninitialized-state",
"functions": [
{
"name": "use",
"source_mapping": {
"filename": "tests/uninitialized.sol",
"length": 117,
"lines": [
@ -55,26 +74,26 @@
],
"start": 875
}
}
],
"variable": "st",
"vuln": "UninitializedStateVars"
},
{
"contract": "Test2",
"filename": "tests/uninitialized.sol",
"functions": [
"init"
],
"sourceMapping": [
{
"variable": {
"name": "st",
"source_mapping": {
"filename": "tests/uninitialized.sol",
"length": 6,
"length": 15,
"lines": [
47
45
],
"start": 748
"start": 695
}
}
},
{
"check": "uninitialized-state",
"functions": [
{
"name": "init",
"source_mapping": {
"filename": "tests/uninitialized.sol",
"length": 52,
"lines": [
@ -84,37 +103,18 @@
],
"start": 817
}
}
],
"variable": "v",
"vuln": "UninitializedStateVars"
},
{
"contract": "Uninitialized",
"filename": "tests/uninitialized.sol",
"functions": [
"transfer"
],
"sourceMapping": [
{
"filename": "tests/uninitialized.sol",
"length": 19,
"lines": [
5
],
"start": 55
},
{
"variable": {
"name": "v",
"source_mapping": {
"filename": "tests/uninitialized.sol",
"length": 82,
"length": 6,
"lines": [
7,
8,
9
47
],
"start": 81
"start": 748
}
}
],
"variable": "destination",
"vuln": "UninitializedStateVars"
}
]

@ -1,18 +1,9 @@
[
{
"contract": "Uninitialized",
"filename": "tests/uninitialized_local_variable.sol",
"function": "func",
"sourceMapping": [
{
"filename": "tests/uninitialized_local_variable.sol",
"length": 18,
"lines": [
4
],
"start": 77
},
{
"check": "uninitialized-local",
"function": {
"name": "func",
"source_mapping": {
"filename": "tests/uninitialized_local_variable.sol",
"length": 143,
"lines": [
@ -24,8 +15,17 @@
],
"start": 29
}
},
"variable": {
"name": "uint_not_init",
"source_mapping": {
"filename": "tests/uninitialized_local_variable.sol",
"length": 18,
"lines": [
4
],
"variable": "uint_not_init",
"vuln": "UninitializedLocalVars"
"start": 77
}
}
}
]

@ -1,18 +1,9 @@
[
{
"contract": "Uninitialized",
"filename": "tests/uninitialized_storage_pointer.sol",
"function": "func",
"sourceMapping": [
{
"filename": "tests/uninitialized_storage_pointer.sol",
"length": 9,
"lines": [
10
],
"start": 171
},
{
"check": "uninitialized-storage",
"function": {
"name": "func",
"source_mapping": {
"filename": "tests/uninitialized_storage_pointer.sol",
"length": 138,
"lines": [
@ -25,8 +16,17 @@
],
"start": 67
}
},
"variable": {
"name": "st_bug",
"source_mapping": {
"filename": "tests/uninitialized_storage_pointer.sol",
"length": 9,
"lines": [
10
],
"variable": "st_bug",
"vuln": "UninitializedStorageVars"
"start": 171
}
}
}
]

@ -1,29 +1,52 @@
[
{
"contract": "User",
"check": "unused-return",
"expressions": [
"a.add(0)",
"t.f()"
],
{
"expression": "a.add(0)",
"source_mapping": {
"filename": "tests/unused_return.sol",
"sourceMapping": [
"length": 8,
"lines": [
22
],
"start": 337
}
},
{
"expression": "t.f()",
"source_mapping": {
"filename": "tests/unused_return.sol",
"length": 5,
"lines": [
18
],
"start": 263
},
{
}
}
],
"function": {
"name": "test",
"source_mapping": {
"filename": "tests/unused_return.sol",
"length": 8,
"length": 347,
"lines": [
22
17,
18,
19,
20,
21,
22,
23,
24,
25,
26,
27,
28,
29
],
"start": 337
"start": 230
}
}
],
"vuln": "UnusedReturn"
}
]

@ -1,9 +1,10 @@
[
{
"contract": "B",
"filename": "tests/unused_state.sol",
"sourceMapping": [
"check": "unused-state",
"variables": [
{
"name": "unused",
"source_mapping": {
"filename": "tests/unused_state.sol",
"length": 14,
"lines": [
@ -11,10 +12,7 @@
],
"start": 42
}
],
"unusedVars": [
"unused"
],
"vuln": "unusedStateVars"
}
]
}
]
Loading…
Cancel
Save