From 43fa9c73df038cda9dd3d4ccbf9e700fec2f36ba Mon Sep 17 00:00:00 2001 From: ggrieco-tob Date: Thu, 18 Apr 2019 09:46:47 -0300 Subject: [PATCH 01/55] first version of slither-simil --- setup.py | 3 +- utils/similarity/__init__.py | 0 utils/similarity/__main__.py | 107 +++++++++++++++++++++ utils/similarity/cache.py | 22 +++++ utils/similarity/encode.py | 168 +++++++++++++++++++++++++++++++++ utils/similarity/info.py | 47 +++++++++ utils/similarity/similarity.py | 6 ++ utils/similarity/test.py | 49 ++++++++++ utils/similarity/train.py | 37 ++++++++ 9 files changed, 438 insertions(+), 1 deletion(-) create mode 100644 utils/similarity/__init__.py create mode 100755 utils/similarity/__main__.py create mode 100644 utils/similarity/cache.py create mode 100644 utils/similarity/encode.py create mode 100644 utils/similarity/info.py create mode 100644 utils/similarity/similarity.py create mode 100755 utils/similarity/test.py create mode 100755 utils/similarity/train.py diff --git a/setup.py b/setup.py index 525839e69..7b8bead4c 100644 --- a/setup.py +++ b/setup.py @@ -15,7 +15,8 @@ setup( 'console_scripts': [ 'slither = slither.__main__:main', 'slither-check-upgradeability = utils.upgradeability.__main__:main', - 'slither-find-paths = utils.possible_paths.__main__:main' + 'slither-find-paths = utils.possible_paths.__main__:main', + 'slither-simil = utils.similarity.__main__:main' ] } ) diff --git a/utils/similarity/__init__.py b/utils/similarity/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/utils/similarity/__main__.py b/utils/similarity/__main__.py new file mode 100755 index 000000000..c456ae0a9 --- /dev/null +++ b/utils/similarity/__main__.py @@ -0,0 +1,107 @@ +#!/usr/bin/env python3 + +import argparse +import logging +import sys +import traceback +import operator +import numpy as np + +from .info import info +from .test import test +from .train import train + + +logging.basicConfig() +logger = logging.getLogger("Slither") + +slither_simil_usage = "USAGE" # TODO +modes = ["info", "test", "train"] + +def parse_args(): + parser = argparse.ArgumentParser(description='', + usage=slither_simil_usage) + + parser.add_argument('mode', + help="|".join(modes)) + + parser.add_argument('model', + help='model.bin') + + parser.add_argument('--solc', + help='solc path', + action='store', + default='solc') + + parser.add_argument('--filename', + action='store', + dest='filename', + help='contract.sol') + + parser.add_argument('--contract', + action='store', + dest='contract', + help='Contract') + + parser.add_argument('--filter', + action='store', + dest='filter', + help='Extension to filter contracts') + + parser.add_argument('--fname', + action='store', + dest='fname', + help='Function name') + + parser.add_argument('--input', + action='store', + dest='input', + help='File or directory used as input') + + parser.add_argument('--version', + help='displays the current version', + version="0.0", + action='version') + + if len(sys.argv) == 1: + parser.print_help(sys.stderr) + sys.exit(1) + + args = parser.parse_args() + return args + +# endregion +################################################################################### +################################################################################### +# region Main +################################################################################### +################################################################################### + +def main(): + args = parse_args() + + default_log = logging.INFO + logger.setLevel(default_log) + + try: + mode = args.mode + + if mode == "info": + info(args) + elif mode == "train": + train(args) + elif mode == "test": + test(args) + else: + logger.error('Invalid mode!. It should be one of these: %s' % ", ".join(modes)) + sys.exit(-1) + + except Exception: + logger.error('Error in %s' % args.filename) + logger.error(traceback.format_exc()) + sys.exit(-1) + +if __name__ == '__main__': + main() + +# endregion diff --git a/utils/similarity/cache.py b/utils/similarity/cache.py new file mode 100644 index 000000000..8093134cf --- /dev/null +++ b/utils/similarity/cache.py @@ -0,0 +1,22 @@ +import numpy as np + +from .encode import encode_contract, load_contracts + +def load_cache(infile, model, ext=None, solc='solc'): + cache = dict() + if infile.endswith(".npz"): + with np.load(infile) as data: + array = data['arr_0'][0] + for x,y in array: + cache[x] = y + else: + contracts = load_contracts(infile, ext=ext) + for contract in contracts: + for x,ir in encode_contract(contract, solc=solc).items(): + if ir != []: + y = " ".join(ir) + cache[x] = model.get_sentence_vector(y) + return cache + +def save_cache(cache, outfile): + np.savez(outfile,[np.array(list(cache.items()))]) diff --git a/utils/similarity/encode.py b/utils/similarity/encode.py new file mode 100644 index 000000000..75e022f7a --- /dev/null +++ b/utils/similarity/encode.py @@ -0,0 +1,168 @@ +import os +import sys + +from slither import Slither +from slither.slithir.operations import * +from slither.slithir.variables import * +from slither.core.declarations import * +from slither.solc_parsing.declarations.function import * + +from slither.solc_parsing.variables.state_variable import * +from slither.solc_parsing.variables.local_variable import * +from slither.solc_parsing.variables.local_variable_init_from_tuple import * + +def load_contracts(dirname, ext=None): + r = [] + walk = list(os.walk(dirname)) + for x, y, files in walk: + for f in files: + if ext is None or f.endswith(ext): + r.append(x + "/".join(y) + "/" + f) + return r + +def ntype(_type): + if type(_type) is not str: + _type = str(_type) + + if "struct" in _type: + return "struct" + elif "enum" in _type: + return "enum" + elif "tuple" in _type: + return "tuple" + elif "contract" in _type: + return "contract" + elif "mapping" in _type: + return "mapping" + elif "." in _type or _type[0].isupper(): + return "" + else: + return _type.replace(" ","_") + +def encode_ir(ir): + # operations + if isinstance(ir, Assignment): + return '({}):=({})'.format(encode_ir(ir.lvalue), encode_ir(ir.rvalue)) + if isinstance(ir, Index): + return 'index({})'.format(ntype(ir._type)) + if isinstance(ir, Member): + return 'member' #.format(ntype(ir._type)) + if isinstance(ir, Length): + return 'length' + if isinstance(ir, Balance): + return 'balance' + if isinstance(ir, Binary): + return 'binary({})'.format(ir.type_str) + if isinstance(ir, Unary): + return 'unary({})'.format(ir.type_str) + if isinstance(ir, Condition): + return 'condition({})'.format(encode_ir(ir.value)) + if isinstance(ir, NewStructure): + return 'new_structure' + if isinstance(ir, NewContract): + return 'new_contract' + if isinstance(ir, NewArray): + return 'new_array({})'.format(ntype(ir._array_type)) + if isinstance(ir, NewElementaryType): + return 'new_elementary({})'.format(ntype(ir._type)) + if isinstance(ir, Push): + return 'push({},{})'.format(encode_ir(ir.value), encode_ir(ir.lvalue)) + if isinstance(ir, Delete): + return 'delete({},{})'.format(encode_ir(ir.lvalue), encode_ir(ir.variable)) + if isinstance(ir, SolidityCall): + return 'solidity_call({})'.format(ir.function.full_name) + if isinstance(ir, InternalCall): + return 'internal_call({})'.format(ntype(ir._type_call)) + if isinstance(ir, EventCall): # is this useful? + return 'event' + if isinstance(ir, LibraryCall): + return 'library_call' + if isinstance(ir, InternalDynamicCall): + return 'internal_dynamic_call' + if isinstance(ir, HighLevelCall): # TODO: improve + return 'high_level_call' + if isinstance(ir, LowLevelCall): # TODO: improve + return 'low_level_call' + if isinstance(ir, TypeConversion): + return 'type_conversion({})'.format(ntype(ir.type)) + if isinstance(ir, Return): # this can be improved using values + return 'return' #.format(ntype(ir.type)) + if isinstance(ir, Transfer): + return 'transfer({})'.format(encode_ir(ir.call_value)) + if isinstance(ir, Send): + return 'send({})'.format(encode_ir(ir.call_value)) + if isinstance(ir, Unpack): # TODO: improve + return 'unpack' + if isinstance(ir, InitArray): # TODO: improve + return 'init_array' + if isinstance(ir, FunctionSolc): # TODO: investigate this + return 'function_solc' + + # variables + if isinstance(ir, Constant): + return 'constant({})'.format(ntype(ir._type)) + if isinstance(ir, SolidityVariableComposed): + return 'solidity_variable_composed({})'.format(ir.name) + if isinstance(ir, SolidityVariable): + return 'solidity_variable{}'.format(ir.name) + if isinstance(ir, TemporaryVariable): + return 'temporary_variable' + if isinstance(ir, ReferenceVariable): + return 'reference({})'.format(ntype(ir._type)) + if isinstance(ir, LocalVariableSolc): + return 'local_solc_variable({})'.format(ir._location) + if isinstance(ir, StateVariableSolc): + return 'state_solc_variable({})'.format(ntype(ir._type)) + if isinstance(ir, LocalVariableInitFromTupleSolc): + return 'local_variable_init_tuple' + if isinstance(ir, TupleVariable): + return 'tuple_variable' + + # default + else: + print(type(ir),"is missing encoding!") + #sys.exit(1) + return '' + +def encode_contract(filename, solc): + r = dict() + + # Init slither + try: + slither = Slither(filename, solc=solc) + except: + print("Compilation failed") + return r + + # Iterate over all the contracts + for contract in slither.contracts: + + # Iterate over all the functions + for function in contract.functions: + + # Dont explore inherited functions + if function.contract == contract: + + if function.nodes == []: + continue + + x = "-".join([filename,contract.name,function.name]) + + r[x] = [] + + # Iterate over the nodes of the function + for node in function.nodes: + + # Print the Solidity expression of the nodes + # And the SlithIR operations + if node.expression: + + #print('\tSolidity expression: {}'.format(node.expression)) + #print('\tSlithIR:') + for ir in node.irs: + #print(ir) + r[x].append(encode_ir(ir)) + #print('\t\t\t{}'.format(ir)) + return r + + diff --git a/utils/similarity/info.py b/utils/similarity/info.py new file mode 100644 index 000000000..46625eabd --- /dev/null +++ b/utils/similarity/info.py @@ -0,0 +1,47 @@ +import logging +import sys +import traceback + +from fastText import load_model +from .encode import encode_contract + +logging.basicConfig() +logger = logging.getLogger("Slither") + +def info(args): + + try: + model = args.model + model = load_model(model) + filename = args.filename + contract = args.contract + solc = args.solc + fname = args.fname + if filename is None and contract is None and fname is None: + print(args.model,"uses the following words:") + for word in model.get_words(): + print(word) + sys.exit(0) + + if filename is None or contract is None or fname is None: + logger.error('The encode mode requires filename, contract and fname parameters.') + sys.exit(-1) + + irs = encode_contract(filename, solc=solc) + if len(irs) == 0: + sys.exit(-1) + + x = "-".join([filename,contract,fname]) + y = " ".join(irs[x]) + + fvector = model.get_sentence_vector(y) + print("Function {} in contract {} is encoded as:".format(fname, contract)) + print(y) + print(fvector) + + except Exception: + logger.error('Error in %s' % args.filename) + logger.error(traceback.format_exc()) + sys.exit(-1) + + diff --git a/utils/similarity/similarity.py b/utils/similarity/similarity.py new file mode 100644 index 000000000..4cc3f2b35 --- /dev/null +++ b/utils/similarity/similarity.py @@ -0,0 +1,6 @@ +import numpy as np + +def similarity(v1, v2): + n1 = np.linalg.norm(v1) + n2 = np.linalg.norm(v2) + return np.dot(v1, v2) / n1 / n2 diff --git a/utils/similarity/test.py b/utils/similarity/test.py new file mode 100755 index 000000000..96a6e648e --- /dev/null +++ b/utils/similarity/test.py @@ -0,0 +1,49 @@ +import argparse +import logging +import sys +import traceback +import operator +import numpy as np + +from fastText import load_model +from .encode import encode_contract, load_contracts +from .cache import load_cache, save_cache +from .similarity import similarity + +logger = logging.getLogger("crytic-pred") + +def test(args): + + try: + model = args.model + model = load_model(model) + filename = args.filename + contract = args.contract + fname = args.fname + solc = args.solc + infile = args.input + ext = args.filter + if filename is None or contract is None or fname is None or infile is None: + logger.error('The test mode requires filename, contract, fname and input parameters.') + sys.exit(-1) + + irs = encode_contract(filename,solc=solc) + x = "-".join([filename,contract,fname]) + y = " ".join(irs[x]) + + fvector = model.get_sentence_vector(y) + cache = load_cache(infile, model, ext=ext, solc=solc) + #save_cache("cache.npz", cache) + + r = dict() + for x,y in cache.items(): + r[x] = similarity(fvector, y) + + r = sorted(r.items(), key=operator.itemgetter(1), reverse=True) + for x,score in r[:10]: + print(x,score) + + except Exception: + logger.error('Error in %s' % args.filename) + logger.error(traceback.format_exc()) + sys.exit(-1) diff --git a/utils/similarity/train.py b/utils/similarity/train.py new file mode 100755 index 000000000..83c7ea8bf --- /dev/null +++ b/utils/similarity/train.py @@ -0,0 +1,37 @@ +import argparse +import logging +import sys +import traceback +import operator + +from fastText import train_unsupervised +from .encode import encode_contract, load_contracts + +logger = logging.getLogger("crytic-pred") + +def train(args): + + try: + model_filename = args.model + solc = args.solc + dirname = args.input + + if dirname is None: + logger.error('The train mode requires the directory parameter.') + sys.exit(-1) + + contracts = load_contracts(dirname) + with open("data.txt", 'w') as f: + for contract in contracts: + for function,ir in encode_contract(contract,solc).items(): + if ir != []: + f.write(" ".join(ir)+"\n") + + model = train_unsupervised(input='data.txt', model='skipgram') + model.save_model(model_filename) + print(model.get_words()) + + except Exception: + logger.error('Error in %s' % args.filename) + logger.error(traceback.format_exc()) + sys.exit(-1) From 32f2f6f0d103baab01a1bbbc030f93aaeb0f3d99 Mon Sep 17 00:00:00 2001 From: ggrieco-tob Date: Thu, 18 Apr 2019 10:41:49 -0300 Subject: [PATCH 02/55] fixes + logger --- utils/similarity/__main__.py | 4 +--- utils/similarity/encode.py | 11 +++-------- utils/similarity/info.py | 2 +- utils/similarity/test.py | 5 ++++- utils/similarity/train.py | 2 +- 5 files changed, 10 insertions(+), 14 deletions(-) diff --git a/utils/similarity/__main__.py b/utils/similarity/__main__.py index c456ae0a9..2e2abd26c 100755 --- a/utils/similarity/__main__.py +++ b/utils/similarity/__main__.py @@ -5,13 +5,11 @@ import logging import sys import traceback import operator -import numpy as np from .info import info from .test import test from .train import train - logging.basicConfig() logger = logging.getLogger("Slither") @@ -19,7 +17,7 @@ slither_simil_usage = "USAGE" # TODO modes = ["info", "test", "train"] def parse_args(): - parser = argparse.ArgumentParser(description='', + parser = argparse.ArgumentParser(description='Code similarity detection tool', usage=slither_simil_usage) parser.add_argument('mode', diff --git a/utils/similarity/encode.py b/utils/similarity/encode.py index 75e022f7a..f6ad95517 100644 --- a/utils/similarity/encode.py +++ b/utils/similarity/encode.py @@ -11,6 +11,8 @@ from slither.solc_parsing.variables.state_variable import * from slither.solc_parsing.variables.local_variable import * from slither.solc_parsing.variables.local_variable_init_from_tuple import * +logger = logging.getLogger("Slither-simil") + def load_contracts(dirname, ext=None): r = [] walk = list(os.walk(dirname)) @@ -121,7 +123,6 @@ def encode_ir(ir): # default else: print(type(ir),"is missing encoding!") - #sys.exit(1) return '' def encode_contract(filename, solc): @@ -131,7 +132,7 @@ def encode_contract(filename, solc): try: slither = Slither(filename, solc=solc) except: - print("Compilation failed") + logger.error("Compilation failed") return r # Iterate over all the contracts @@ -152,17 +153,11 @@ def encode_contract(filename, solc): # Iterate over the nodes of the function for node in function.nodes: - # Print the Solidity expression of the nodes # And the SlithIR operations if node.expression: - - #print('\tSolidity expression: {}'.format(node.expression)) - #print('\tSlithIR:') for ir in node.irs: - #print(ir) r[x].append(encode_ir(ir)) - #print('\t\t\t{}'.format(ir)) return r diff --git a/utils/similarity/info.py b/utils/similarity/info.py index 46625eabd..947d9b40b 100644 --- a/utils/similarity/info.py +++ b/utils/similarity/info.py @@ -6,7 +6,7 @@ from fastText import load_model from .encode import encode_contract logging.basicConfig() -logger = logging.getLogger("Slither") +logger = logging.getLogger("Slither-simil") def info(args): diff --git a/utils/similarity/test.py b/utils/similarity/test.py index 96a6e648e..1ea803546 100755 --- a/utils/similarity/test.py +++ b/utils/similarity/test.py @@ -10,7 +10,7 @@ from .encode import encode_contract, load_contracts from .cache import load_cache, save_cache from .similarity import similarity -logger = logging.getLogger("crytic-pred") +logger = logging.getLogger("Slither-simil") def test(args): @@ -28,6 +28,9 @@ def test(args): sys.exit(-1) irs = encode_contract(filename,solc=solc) + if len(irs) == 0: + sys.exit(-1) + x = "-".join([filename,contract,fname]) y = " ".join(irs[x]) diff --git a/utils/similarity/train.py b/utils/similarity/train.py index 83c7ea8bf..0d99963de 100755 --- a/utils/similarity/train.py +++ b/utils/similarity/train.py @@ -7,7 +7,7 @@ import operator from fastText import train_unsupervised from .encode import encode_contract, load_contracts -logger = logging.getLogger("crytic-pred") +logger = logging.getLogger("Slither-simil") def train(args): From 7affd05610252185b38334d99df9caf2e9ff390c Mon Sep 17 00:00:00 2001 From: ggrieco-tob Date: Thu, 18 Apr 2019 11:06:24 -0300 Subject: [PATCH 03/55] handling fastText dependency --- utils/similarity/__init__.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/utils/similarity/__init__.py b/utils/similarity/__init__.py index e69de29bb..ffbc13f30 100644 --- a/utils/similarity/__init__.py +++ b/utils/similarity/__init__.py @@ -0,0 +1,12 @@ +# from https://stackoverflow.com/questions/563022/whats-python-good-practice-for-importing-and-offering-optional-features +import sys + +try: + import fastText +except ImportError: + fastText = None + +if fastText is None: + print("In order to use slither-simil, you need to install fastText 0.2.0:") + print("$ pip3 install https://github.com/facebookresearch/fastText/archive/0.2.0.zip --user") + sys.exit(-1) From 3fd50a40a6162cddeab4b11b3e42488b238f9d95 Mon Sep 17 00:00:00 2001 From: ggrieco-tob Date: Thu, 18 Apr 2019 15:55:01 -0300 Subject: [PATCH 04/55] fixes --- utils/similarity/encode.py | 35 ++++++++++++++++++++++++++++++----- utils/similarity/train.py | 5 +++-- 2 files changed, 33 insertions(+), 7 deletions(-) diff --git a/utils/similarity/encode.py b/utils/similarity/encode.py index f6ad95517..6c6c48906 100644 --- a/utils/similarity/encode.py +++ b/utils/similarity/encode.py @@ -6,6 +6,7 @@ from slither.slithir.operations import * from slither.slithir.variables import * from slither.core.declarations import * from slither.solc_parsing.declarations.function import * +from slither.core.solidity_types import * from slither.solc_parsing.variables.state_variable import * from slither.solc_parsing.variables.local_variable import * @@ -13,18 +14,43 @@ from slither.solc_parsing.variables.local_variable_init_from_tuple import * logger = logging.getLogger("Slither-simil") -def load_contracts(dirname, ext=None): +def load_contracts(dirname, ext=None, nsamples=None): r = [] walk = list(os.walk(dirname)) for x, y, files in walk: for f in files: if ext is None or f.endswith(ext): r.append(x + "/".join(y) + "/" + f) - return r + + if nsamples is None: + return r + else: + # TODO: shuffle + return r[:nsamples] def ntype(_type): - if type(_type) is not str: + if isinstance(_type, ElementaryType): + _type = str(_type) + elif isinstance(_type, ArrayType): + if isinstance(_type.type, ElementaryType): + _type = str(_type) + else: + _type = "user_defined_array" + elif isinstance(_type, Structure): + print(_type) _type = str(_type) + elif isinstance(_type, Enum): + print(_type) + _type = str(_type) + elif isinstance(_type, MappingType): + _type = str(_type) + elif isinstance(_type, UserDefinedType): + _type = "user_defined_type" # TODO: this could be Contract, Enum or Struct + else: + _type = str(_type) + + _type = _type.replace("_memory","") + _type = _type.replace("_storage_ref","") if "struct" in _type: return "struct" @@ -36,8 +62,6 @@ def ntype(_type): return "contract" elif "mapping" in _type: return "mapping" - elif "." in _type or _type[0].isupper(): - return "" else: return _type.replace(" ","_") @@ -46,6 +70,7 @@ def encode_ir(ir): if isinstance(ir, Assignment): return '({}):=({})'.format(encode_ir(ir.lvalue), encode_ir(ir.rvalue)) if isinstance(ir, Index): + #print(type(ir._type)) return 'index({})'.format(ntype(ir._type)) if isinstance(ir, Member): return 'member' #.format(ntype(ir._type)) diff --git a/utils/similarity/train.py b/utils/similarity/train.py index 0d99963de..6892c8c80 100755 --- a/utils/similarity/train.py +++ b/utils/similarity/train.py @@ -15,12 +15,13 @@ def train(args): model_filename = args.model solc = args.solc dirname = args.input + ext = args.filter if dirname is None: - logger.error('The train mode requires the directory parameter.') + logger.error('The train mode requires the input parameter.') sys.exit(-1) - contracts = load_contracts(dirname) + contracts = load_contracts(dirname, ext=ext, nsamples=None) with open("data.txt", 'w') as f: for contract in contracts: for function,ir in encode_contract(contract,solc).items(): From 03b318b55e5ff5b0db5c86b0082c69e5dce0ed40 Mon Sep 17 00:00:00 2001 From: ggrieco-tob Date: Fri, 19 Apr 2019 12:30:14 -0300 Subject: [PATCH 05/55] fixes + enable contract sampling during training --- utils/similarity/__main__.py | 6 ++++++ utils/similarity/encode.py | 4 ++-- utils/similarity/train.py | 9 ++++++--- 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/utils/similarity/__main__.py b/utils/similarity/__main__.py index 2e2abd26c..9e9860fd8 100755 --- a/utils/similarity/__main__.py +++ b/utils/similarity/__main__.py @@ -51,6 +51,12 @@ def parse_args(): dest='fname', help='Function name') + parser.add_argument('--nsamples', + action='store', + type=int, + dest='nsamples', + help='Number of contract samples used for training') + parser.add_argument('--input', action='store', dest='input', diff --git a/utils/similarity/encode.py b/utils/similarity/encode.py index 6c6c48906..6630b1bfc 100644 --- a/utils/similarity/encode.py +++ b/utils/similarity/encode.py @@ -49,8 +49,8 @@ def ntype(_type): else: _type = str(_type) - _type = _type.replace("_memory","") - _type = _type.replace("_storage_ref","") + _type = _type.replace(" memory","") + _type = _type.replace(" storage ref","") if "struct" in _type: return "struct" diff --git a/utils/similarity/train.py b/utils/similarity/train.py index 6892c8c80..8f8e7a888 100755 --- a/utils/similarity/train.py +++ b/utils/similarity/train.py @@ -12,23 +12,26 @@ logger = logging.getLogger("Slither-simil") def train(args): try: + last_data_train_filename = "last_data_train.txt" model_filename = args.model solc = args.solc dirname = args.input ext = args.filter + nsamples = args.nsamples if dirname is None: logger.error('The train mode requires the input parameter.') sys.exit(-1) - contracts = load_contracts(dirname, ext=ext, nsamples=None) - with open("data.txt", 'w') as f: + contracts = load_contracts(dirname, ext=ext, nsamples=nsamples) + logger.info('Saving extracted data into', last_data_train_filename) + with open(last_data_train_filename, 'w') as f: for contract in contracts: for function,ir in encode_contract(contract,solc).items(): if ir != []: f.write(" ".join(ir)+"\n") - model = train_unsupervised(input='data.txt', model='skipgram') + model = train_unsupervised(input=last_data_train_filename, model='skipgram') model.save_model(model_filename) print(model.get_words()) From 8f2bad8905f9ba27bd0188fe6fb2d0f051d7a47f Mon Sep 17 00:00:00 2001 From: ggrieco-tob Date: Fri, 19 Apr 2019 17:45:25 -0300 Subject: [PATCH 06/55] fixes --- utils/similarity/__main__.py | 2 +- utils/similarity/cache.py | 2 +- utils/similarity/encode.py | 2 +- utils/similarity/test.py | 4 ++-- utils/similarity/train.py | 25 +++++++++++++++++++------ 5 files changed, 24 insertions(+), 11 deletions(-) diff --git a/utils/similarity/__main__.py b/utils/similarity/__main__.py index 9e9860fd8..b241f15cd 100755 --- a/utils/similarity/__main__.py +++ b/utils/similarity/__main__.py @@ -11,7 +11,7 @@ from .test import test from .train import train logging.basicConfig() -logger = logging.getLogger("Slither") +logger = logging.getLogger("Slither-simil") slither_simil_usage = "USAGE" # TODO modes = ["info", "test", "train"] diff --git a/utils/similarity/cache.py b/utils/similarity/cache.py index 8093134cf..b11bbf499 100644 --- a/utils/similarity/cache.py +++ b/utils/similarity/cache.py @@ -19,4 +19,4 @@ def load_cache(infile, model, ext=None, solc='solc'): return cache def save_cache(cache, outfile): - np.savez(outfile,[np.array(list(cache.items()))]) + np.savez(outfile,[np.array(cache)]) diff --git a/utils/similarity/encode.py b/utils/similarity/encode.py index 6630b1bfc..081b66671 100644 --- a/utils/similarity/encode.py +++ b/utils/similarity/encode.py @@ -172,7 +172,7 @@ def encode_contract(filename, solc): if function.nodes == []: continue - x = "-".join([filename,contract.name,function.name]) + x = (filename,contract.name,function.name) r[x] = [] diff --git a/utils/similarity/test.py b/utils/similarity/test.py index 1ea803546..4f28801e0 100755 --- a/utils/similarity/test.py +++ b/utils/similarity/test.py @@ -23,6 +23,7 @@ def test(args): solc = args.solc infile = args.input ext = args.filter + if filename is None or contract is None or fname is None or infile is None: logger.error('The test mode requires filename, contract, fname and input parameters.') sys.exit(-1) @@ -31,8 +32,7 @@ def test(args): if len(irs) == 0: sys.exit(-1) - x = "-".join([filename,contract,fname]) - y = " ".join(irs[x]) + y = " ".join(irs[(filename,contract,fname)]) fvector = model.get_sentence_vector(y) cache = load_cache(infile, model, ext=ext, solc=solc) diff --git a/utils/similarity/train.py b/utils/similarity/train.py index 8f8e7a888..cbe037cf0 100755 --- a/utils/similarity/train.py +++ b/utils/similarity/train.py @@ -3,9 +3,11 @@ import logging import sys import traceback import operator +import os from fastText import train_unsupervised -from .encode import encode_contract, load_contracts +from .encode import encode_contract, load_contracts +from .cache import save_cache logger = logging.getLogger("Slither-simil") @@ -25,15 +27,26 @@ def train(args): contracts = load_contracts(dirname, ext=ext, nsamples=nsamples) logger.info('Saving extracted data into', last_data_train_filename) + cache = [] with open(last_data_train_filename, 'w') as f: - for contract in contracts: - for function,ir in encode_contract(contract,solc).items(): + for filename in contracts: + #cache[filename] = dict() + for (filename, contract, function), ir in encode_contract(filename,solc).items(): if ir != []: - f.write(" ".join(ir)+"\n") - + x = " ".join(ir) + f.write(x+"\n") + cache.append((os.path.split(filename)[-1], contract, function, x)) + + logger.info('Starting training') model = train_unsupervised(input=last_data_train_filename, model='skipgram') + logger.info('Training complete') model.save_model(model_filename) - print(model.get_words()) + + for i,(filename, contract, function, irs) in enumerate(cache): + cache[i] = ((filename, contract, function), model.get_sentence_vector(irs)) + + logger.info('Saved cache in cache.npz') + save_cache(cache, "cache.npz") except Exception: logger.error('Error in %s' % args.filename) From d8d793881301c1a61831574387578612ba2aa240 Mon Sep 17 00:00:00 2001 From: ggrieco-tob Date: Fri, 19 Apr 2019 18:17:21 -0300 Subject: [PATCH 07/55] improved logging --- utils/similarity/train.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/utils/similarity/train.py b/utils/similarity/train.py index cbe037cf0..679f8b7df 100755 --- a/utils/similarity/train.py +++ b/utils/similarity/train.py @@ -26,7 +26,7 @@ def train(args): sys.exit(-1) contracts = load_contracts(dirname, ext=ext, nsamples=nsamples) - logger.info('Saving extracted data into', last_data_train_filename) + logger.info('Saving extracted data into %s', last_data_train_filename) cache = [] with open(last_data_train_filename, 'w') as f: for filename in contracts: @@ -40,13 +40,15 @@ def train(args): logger.info('Starting training') model = train_unsupervised(input=last_data_train_filename, model='skipgram') logger.info('Training complete') + logger.info('Saving model') model.save_model(model_filename) for i,(filename, contract, function, irs) in enumerate(cache): cache[i] = ((filename, contract, function), model.get_sentence_vector(irs)) - logger.info('Saved cache in cache.npz') + logger.info('Saving cache in cache.npz') save_cache(cache, "cache.npz") + logger.info('Done!') except Exception: logger.error('Error in %s' % args.filename) From 0978700a50802a5ec7d35fb1361e6a335c1b6f66 Mon Sep 17 00:00:00 2001 From: ggrieco-tob Date: Sat, 20 Apr 2019 18:16:19 -0300 Subject: [PATCH 08/55] added plot mode --- utils/similarity/__main__.py | 12 ++++++- utils/similarity/plot.py | 62 ++++++++++++++++++++++++++++++++++++ utils/similarity/test.py | 3 +- 3 files changed, 75 insertions(+), 2 deletions(-) create mode 100644 utils/similarity/plot.py diff --git a/utils/similarity/__main__.py b/utils/similarity/__main__.py index b241f15cd..50cc09a43 100755 --- a/utils/similarity/__main__.py +++ b/utils/similarity/__main__.py @@ -9,12 +9,13 @@ import operator from .info import info from .test import test from .train import train +from .plot import plot logging.basicConfig() logger = logging.getLogger("Slither-simil") slither_simil_usage = "USAGE" # TODO -modes = ["info", "test", "train"] +modes = ["info", "test", "train", "plot"] def parse_args(): parser = argparse.ArgumentParser(description='Code similarity detection tool', @@ -57,6 +58,13 @@ def parse_args(): dest='nsamples', help='Number of contract samples used for training') + parser.add_argument('--ntop', + action='store', + type=int, + dest='ntop', + default=10, + help='Number of more similar contracts to show for testing') + parser.add_argument('--input', action='store', dest='input', @@ -96,6 +104,8 @@ def main(): train(args) elif mode == "test": test(args) + elif mode == "plot": + plot(args) else: logger.error('Invalid mode!. It should be one of these: %s' % ", ".join(modes)) sys.exit(-1) diff --git a/utils/similarity/plot.py b/utils/similarity/plot.py new file mode 100644 index 000000000..84fcd69b9 --- /dev/null +++ b/utils/similarity/plot.py @@ -0,0 +1,62 @@ +import logging +import sys +import traceback +import operator +import numpy as np +import random + +from sklearn import decomposition +import matplotlib.pyplot as plt + +from fastText import load_model +from .cache import load_cache + +logger = logging.getLogger("crytic-pred") + +def plot(args): + + try: + model = args.model + model = load_model(model) + filename = args.filename + contract = args.contract + fname = args.fname + solc = args.solc + infile = args.input + ext = args.filter + + if contract is None or fname is None or infile is None: + logger.error('The plot mode requieres contract, fname and input parameters.') + sys.exit(-1) + + cache = load_cache(infile, model, ext=ext, solc=solc) + #save_cache("cache.npz", cache) + + data = list() + fs = list() + for (f,c,n),y in cache.items(): + if c == contract and n == fname: + fs.append(f) + data.append(y) + #r[x] = similarity(fvector, y) + + + data = np.array(data) + pca = decomposition.PCA(n_components=2) + tdata = pca.fit_transform(data) + plt.figure() + assert(len(tdata) == len(fs)) + for ([x,y],l) in zip(tdata, fs): + x = random.gauss(0, 0.01) + x + y = random.gauss(0, 0.01) + y + plt.scatter(x, y, c='blue') + plt.text(x-0.001,y+0.001, l.split("_")[1].replace(".sol.ast.compact.json","")) + + plt.show() + #r = sorted(r.items(), key=operator.itemgetter(1), reverse=True) + #for x,score in r[:10]: + + except Exception: + logger.error('Error in %s' % args.filename) + logger.error(traceback.format_exc()) + sys.exit(-1) diff --git a/utils/similarity/test.py b/utils/similarity/test.py index 4f28801e0..342551499 100755 --- a/utils/similarity/test.py +++ b/utils/similarity/test.py @@ -23,6 +23,7 @@ def test(args): solc = args.solc infile = args.input ext = args.filter + ntop = args.ntop if filename is None or contract is None or fname is None or infile is None: logger.error('The test mode requires filename, contract, fname and input parameters.') @@ -43,7 +44,7 @@ def test(args): r[x] = similarity(fvector, y) r = sorted(r.items(), key=operator.itemgetter(1), reverse=True) - for x,score in r[:10]: + for x,score in r[:ntop]: print(x,score) except Exception: From 1eb84785954d437b7f0b05d41b1a9d5fd6e83fdc Mon Sep 17 00:00:00 2001 From: ggrieco-tob Date: Sat, 20 Apr 2019 18:18:46 -0300 Subject: [PATCH 09/55] verification of sklearn (optional) dependency --- utils/similarity/__init__.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/utils/similarity/__init__.py b/utils/similarity/__init__.py index ffbc13f30..dc48cf579 100644 --- a/utils/similarity/__init__.py +++ b/utils/similarity/__init__.py @@ -10,3 +10,12 @@ if fastText is None: print("In order to use slither-simil, you need to install fastText 0.2.0:") print("$ pip3 install https://github.com/facebookresearch/fastText/archive/0.2.0.zip --user") sys.exit(-1) + +try: + import sklearn +except ImportError: + sklearn = None + +if sklearn is None: + print("In order to use plot mode in slither-simil, you need to install sklearn:") + print("$ pip3 install sklearn --user") From 2b4edbda8cf29454aec6008088e50684101a37c1 Mon Sep 17 00:00:00 2001 From: g Date: Sat, 20 Apr 2019 17:56:26 -0400 Subject: [PATCH 10/55] fixes --- utils/similarity/__init__.py | 13 ++----------- utils/similarity/plot.py | 33 ++++++++++++++++++++++----------- 2 files changed, 24 insertions(+), 22 deletions(-) diff --git a/utils/similarity/__init__.py b/utils/similarity/__init__.py index dc48cf579..5a1473b46 100644 --- a/utils/similarity/__init__.py +++ b/utils/similarity/__init__.py @@ -7,15 +7,6 @@ except ImportError: fastText = None if fastText is None: - print("In order to use slither-simil, you need to install fastText 0.2.0:") - print("$ pip3 install https://github.com/facebookresearch/fastText/archive/0.2.0.zip --user") + print("ERROR: in order to use slither-simil, you need to install fastText 0.2.0:") + print("$ pip3 install https://github.com/facebookresearch/fastText/archive/0.2.0.zip --user\n") sys.exit(-1) - -try: - import sklearn -except ImportError: - sklearn = None - -if sklearn is None: - print("In order to use plot mode in slither-simil, you need to install sklearn:") - print("$ pip3 install sklearn --user") diff --git a/utils/similarity/plot.py b/utils/similarity/plot.py index 84fcd69b9..d6bd75e33 100644 --- a/utils/similarity/plot.py +++ b/utils/similarity/plot.py @@ -3,19 +3,30 @@ import sys import traceback import operator import numpy as np +import tqdm import random -from sklearn import decomposition -import matplotlib.pyplot as plt - +try: + from sklearn import decomposition + import matplotlib.pyplot as plt +except ImportError: + decomposition = None + plt = None + from fastText import load_model from .cache import load_cache -logger = logging.getLogger("crytic-pred") +logger = logging.getLogger("Slither-simil") def plot(args): + if decomposition is None or plt is None: + print("ERROR: In order to use plot mode in slither-simil, you need to install sklearn and matplotlib:") + print("$ pip3 install sklearn matplotlib --user") + sys.exit(-1) + try: + model = args.model model = load_model(model) filename = args.filename @@ -29,32 +40,32 @@ def plot(args): logger.error('The plot mode requieres contract, fname and input parameters.') sys.exit(-1) + logger.info('Loading data..') cache = load_cache(infile, model, ext=ext, solc=solc) - #save_cache("cache.npz", cache) data = list() fs = list() + + logger.info('Procesing data..') for (f,c,n),y in cache.items(): if c == contract and n == fname: fs.append(f) data.append(y) - #r[x] = similarity(fvector, y) - data = np.array(data) pca = decomposition.PCA(n_components=2) tdata = pca.fit_transform(data) + + logger.info('Plotting data..') plt.figure() assert(len(tdata) == len(fs)) for ([x,y],l) in zip(tdata, fs): x = random.gauss(0, 0.01) + x y = random.gauss(0, 0.01) + y plt.scatter(x, y, c='blue') - plt.text(x-0.001,y+0.001, l.split("_")[1].replace(".sol.ast.compact.json","")) + #plt.text(x-0.001,y+0.001, l.split("_")[1].replace(".sol.ast.compact.json","")) - plt.show() - #r = sorted(r.items(), key=operator.itemgetter(1), reverse=True) - #for x,score in r[:10]: + plt.savefig('plot.png', bbox_inches='tight') except Exception: logger.error('Error in %s' % args.filename) From e013338f812f2b2f946bea8455aec7976a3a6d4b Mon Sep 17 00:00:00 2001 From: Josselin Date: Wed, 24 Apr 2019 20:12:25 +0100 Subject: [PATCH 11/55] Use crytic-compile from pip --- scripts/travis_install.sh | 5 ----- setup.py | 2 +- slither/slithir/variables/state_variable.py | 2 +- 3 files changed, 2 insertions(+), 7 deletions(-) diff --git a/scripts/travis_install.sh b/scripts/travis_install.sh index fed178c60..637f3f748 100755 --- a/scripts/travis_install.sh +++ b/scripts/travis_install.sh @@ -16,8 +16,3 @@ function install_solc { install_solc - -git clone https://github.com/crytic/crytic-compile -cd crytic-compile -pip install . - diff --git a/setup.py b/setup.py index 525839e69..3e8902de6 100644 --- a/setup.py +++ b/setup.py @@ -8,7 +8,7 @@ setup( version='0.6.2', packages=find_packages(), python_requires='>=3.6', - install_requires=['prettytable>=0.7.2', 'pysha3>=1.0.2'], + install_requires=['prettytable>=0.7.2', 'pysha3>=1.0.2', 'crytic-compile>=0.1.0'], license='AGPL-3.0', long_description=open('README.md').read(), entry_points={ diff --git a/slither/slithir/variables/state_variable.py b/slither/slithir/variables/state_variable.py index ecefe98c7..d2f5d1d6b 100644 --- a/slither/slithir/variables/state_variable.py +++ b/slither/slithir/variables/state_variable.py @@ -43,4 +43,4 @@ class StateIRVariable(StateVariable, SlithIRVariable): @property def ssa_name(self): - return '{}_{}'.format(self._name, self.index) + return '{}.{}_{}'.format(self.id, self._name, self.index) From 3991f6e4941c88996639148195ce14e712fb85b0 Mon Sep 17 00:00:00 2001 From: Josselin Date: Fri, 26 Apr 2019 13:24:04 +0100 Subject: [PATCH 12/55] Breaking change: functions and modifiers are not shared accross contracts, each contract has an own copy of all the functions/modifiers Changed: - function/modifier inherits from ChildInheritance, which contains original_contract, pointing to the base contract - function.contract will point to the contract where the instance is stored - function.is_shadowed indicates if a function is shadowed - function.canonical_name returns original_contract+ '.'+ name - contract._functions/_modifiers are indexes by their canonical_name - contract.functions_as_dict is rename available_functions_as_dict and return non-shadowed functions (same for modifiers_as_dict) - For better clarity, all the detectors use now canoncal_name, for variable/function/structure/... rather than contract.name + name - abstract_detector.add_event_to_json/ abstract_detector.add_events_to_json (the json type is still 'function' to simplify the 3-party parsing) --- examples/scripts/functions_called.py | 2 +- examples/scripts/possible_paths.py | 4 +- examples/scripts/slithIR.py | 2 +- slither/core/children/child_contract.py | 2 + slither/core/children/child_inheritance.py | 13 +++ slither/core/declarations/contract.py | 44 ++++++++-- slither/core/declarations/event.py | 8 ++ slither/core/declarations/function.py | 26 +++++- slither/core/variables/local_variable.py | 5 ++ slither/detectors/abstract_detector.py | 17 +++- .../detectors/attributes/const_functions.py | 13 ++- .../detectors/erc20/incorrect_interface.py | 2 +- .../erc20/unindexed_event_parameters.py | 2 +- slither/detectors/functions/arbitrary_send.py | 7 +- .../detectors/functions/complex_function.py | 5 +- .../detectors/functions/external_function.py | 5 +- slither/detectors/functions/suicidal.py | 7 +- .../naming_convention/naming_convention.py | 38 ++++---- .../detectors/operations/block_timestamp.py | 7 +- .../detectors/operations/low_level_calls.py | 6 +- .../operations/unused_return_values.py | 7 +- .../detectors/reentrancy/reentrancy_benign.py | 4 +- .../detectors/reentrancy/reentrancy_eth.py | 4 +- .../reentrancy_read_before_write.py | 4 +- .../detectors/shadowing/builtin_symbols.py | 8 +- slither/detectors/shadowing/local.py | 11 +-- slither/detectors/shadowing/state.py | 10 +-- slither/detectors/statements/assembly.py | 6 +- slither/detectors/statements/calls_in_loop.py | 6 +- .../statements/controlled_delegatecall.py | 2 +- .../statements/incorrect_strict_equality.py | 5 +- slither/detectors/statements/tx_origin.py | 4 +- .../possible_const_state_variables.py | 5 +- .../uninitialized_local_variables.py | 7 +- .../uninitialized_state_variables.py | 5 +- .../uninitialized_storage_variables.py | 4 +- .../variables/unused_state_variables.py | 7 +- .../printers/inheritance/inheritance_graph.py | 6 +- slither/printers/summary/slithir.py | 40 ++++----- slither/printers/summary/slithir_ssa.py | 36 ++++---- slither/slithir/operations/internal_call.py | 5 +- slither/slithir/variables/state_variable.py | 2 +- slither/solc_parsing/declarations/contract.py | 88 +++++++++++++------ slither/solc_parsing/declarations/function.py | 3 +- .../expressions/expression_parsing.py | 32 ++++--- .../solidity_types/type_parsing.py | 6 +- slither/utils/inheritance_analysis.py | 2 +- utils/possible_paths/__main__.py | 6 +- utils/upgradeability/check_initialization.py | 4 +- 49 files changed, 322 insertions(+), 222 deletions(-) create mode 100644 slither/core/children/child_inheritance.py diff --git a/examples/scripts/functions_called.py b/examples/scripts/functions_called.py index 5f25477d0..4324ac902 100644 --- a/examples/scripts/functions_called.py +++ b/examples/scripts/functions_called.py @@ -16,7 +16,7 @@ entry_point = contract.get_function_from_signature('entry_point()') all_calls = entry_point.all_internal_calls() -all_calls_formated = [f.contract.name + '.' + f.name for f in all_calls] +all_calls_formated = [f.canonical_name for f in all_calls] # Print the result print('From entry_point the functions reached are {}'.format(all_calls_formated)) diff --git a/examples/scripts/possible_paths.py b/examples/scripts/possible_paths.py index e65ddb1c8..6c3b6d0be 100644 --- a/examples/scripts/possible_paths.py +++ b/examples/scripts/possible_paths.py @@ -179,12 +179,12 @@ reaching_functions = set([y for x in reaching_paths for y in x if y not in targe # Print out all function names which can reach the targets. print(f"The following functions reach the specified targets:") -for function_desc in sorted([f"{f.contract.name}.{f.full_name}" for f in reaching_functions]): +for function_desc in sorted([f"{f.canonical_name}" for f in reaching_functions]): print(f"-{function_desc}") print("\n") # Format all function paths. -reaching_paths_str = [' -> '.join([f"{f.contract.name}.{f.full_name}" for f in reaching_path]) for reaching_path in reaching_paths] +reaching_paths_str = [' -> '.join([f"{f.canonical_name}" for f in reaching_path]) for reaching_path in reaching_paths] # Print a sorted list of all function paths which can reach the targets. print(f"The following paths reach the specified targets:") diff --git a/examples/scripts/slithIR.py b/examples/scripts/slithIR.py index 04fe255c8..b58e06f10 100644 --- a/examples/scripts/slithIR.py +++ b/examples/scripts/slithIR.py @@ -15,7 +15,7 @@ for contract in slither.contracts: for function in contract.functions: # Dont explore inherited functions - if function.contract == contract: + if function.original_contract == contract: print('Function: {}'.format(function.name)) diff --git a/slither/core/children/child_contract.py b/slither/core/children/child_contract.py index d5a613bc9..6e476d59f 100644 --- a/slither/core/children/child_contract.py +++ b/slither/core/children/child_contract.py @@ -4,6 +4,7 @@ class ChildContract: def __init__(self): super(ChildContract, self).__init__() self._contract = None + self._original_contract = None def set_contract(self, contract): self._contract = contract @@ -11,3 +12,4 @@ class ChildContract: @property def contract(self): return self._contract + diff --git a/slither/core/children/child_inheritance.py b/slither/core/children/child_inheritance.py new file mode 100644 index 000000000..668c37a5f --- /dev/null +++ b/slither/core/children/child_inheritance.py @@ -0,0 +1,13 @@ + +class ChildInheritance: + + def __init__(self): + super(ChildInheritance, self).__init__() + self._original_contract = None + + def set_original_contract(self, original_contract): + self._original_contract = original_contract + + @property + def original_contract(self): + return self._original_contract diff --git a/slither/core/declarations/contract.py b/slither/core/declarations/contract.py index 787172843..5f1c0a2e9 100644 --- a/slither/core/declarations/contract.py +++ b/slither/core/declarations/contract.py @@ -32,6 +32,7 @@ class Contract(ChildSlither, SourceMapping): self._variables = {} self._modifiers = {} self._functions = {} + self._using_for = {} self._kind = None @@ -183,7 +184,7 @@ class Contract(ChildSlither, SourceMapping): @property def constructor_not_inherited(self): - return next((func for func in self.functions if func.is_constructor and func.contract == self), None) + return next((func for func in self.functions if func.is_constructor and func.original_contract == self), None) @property def constructors(self): @@ -219,22 +220,22 @@ class Contract(ChildSlither, SourceMapping): ''' return list(self._functions.values()) - def functions_as_dict(self): - return self._functions + def available_functions_as_dict(self): + return {f.full_name: f for f in self._functions.values() if not f.is_shadowed} @property def functions_inherited(self): ''' list(Function): List of the inherited functions ''' - return [f for f in self.functions if f.contract != self] + return [f for f in self.functions if f.original_contract != self] @property def functions_not_inherited(self): ''' list(Function): List of the functions defined within the contract (not inherited) ''' - return [f for f in self.functions if f.contract == self] + return [f for f in self.functions if f.original_contract == self] @property def functions_entry_points(self): @@ -250,22 +251,22 @@ class Contract(ChildSlither, SourceMapping): ''' return list(self._modifiers.values()) - def modifiers_as_dict(self): - return self._modifiers + def available_modifiers_as_dict(self): + return {m.full_name: m for m in self._modifiers.values() if not m.is_shadowed} @property def modifiers_inherited(self): ''' list(Modifier): List of the inherited modifiers ''' - return [m for m in self.modifiers if m.contract != self] + return [m for m in self.modifiers if m.original_contract != self] @property def modifiers_not_inherited(self): ''' list(Modifier): List of the modifiers defined within the contract (not inherited) ''' - return [m for m in self.modifiers if m.contract == self] + return [m for m in self.modifiers if m.original_contract == self] @property def functions_and_modifiers(self): @@ -288,6 +289,31 @@ class Contract(ChildSlither, SourceMapping): ''' return self.functions_not_inherited + self.modifiers_not_inherited + def available_elements_from_inheritances(self, elements, getter_available): + """ + + :param elements: dict(canonical_name -> elements) + :param getter_available: fun x + :return: + """ + # keep track of the contracts visited + # to prevent an ovveride due to multiple inheritance of the same contract + # A is B, C, D is C, --> the second C was already seen + inherited_elements = {} + accessible_elements = {} + contracts_visited = [] + for father in self.inheritance_reverse: + functions = {v.full_name: v for (_, v) in getter_available(father) + if not v.contract in contracts_visited} + contracts_visited.append(father) + inherited_elements.update(functions) + + for element in inherited_elements.values(): + accessible_elements[element.full_name] = elements[element.canonical_name] + + return accessible_elements + + # endregion ################################################################################### ################################################################################### diff --git a/slither/core/declarations/event.py b/slither/core/declarations/event.py index 0974c4773..29811f946 100644 --- a/slither/core/declarations/event.py +++ b/slither/core/declarations/event.py @@ -29,6 +29,14 @@ class Event(ChildContract, SourceMapping): name, parameters = self.signature return name+'('+','.join(parameters)+')' + @property + def canonical_name(self): + ''' Return the function signature as a str + Returns: + str: contract.func_name(type1,type2) + ''' + return self.contract.name + self.full_name + @property def elems(self): return self._elems diff --git a/slither/core/declarations/function.py b/slither/core/declarations/function.py index 5c8849880..27ffa6996 100644 --- a/slither/core/declarations/function.py +++ b/slither/core/declarations/function.py @@ -6,6 +6,7 @@ from collections import namedtuple from itertools import groupby from slither.core.children.child_contract import ChildContract +from slither.core.children.child_inheritance import ChildInheritance from slither.core.declarations.solidity_variables import (SolidityFunction, SolidityVariable, SolidityVariableComposed) @@ -18,7 +19,7 @@ logger = logging.getLogger("Function") ReacheableNode = namedtuple('ReacheableNode', ['node', 'ir']) -class Function(ChildContract, SourceMapping): +class Function(ChildContract, ChildInheritance, SourceMapping): """ Function class """ @@ -82,6 +83,8 @@ class Function(ChildContract, SourceMapping): self._all_conditional_solidity_variables_read_with_loop = None self._all_solidity_variables_used_as_args = None + self._is_shadowed = False + # set(ReacheableNode) self._reachable_from_nodes = set() self._reachable_from_functions = set() @@ -113,12 +116,21 @@ class Function(ChildContract, SourceMapping): name, parameters, _ = self.signature return name+'('+','.join(parameters)+')' + @property + def canonical_name(self): + """ + str: contract.func_name(type1,type2) + Return the function signature without the return values + """ + name, parameters, _ = self.signature + return self.original_contract.name + '.' + name + '(' + ','.join(parameters) + ')' + @property def is_constructor(self): """ bool: True if the function is the constructor """ - return self._is_constructor or self._name == self.contract.name + return self._is_constructor or self._name == self.original_contract.name @property def contains_assembly(self): @@ -170,6 +182,14 @@ class Function(ChildContract, SourceMapping): """ return self._pure + @property + def is_shadowed(self): + return self._is_shadowed + + @is_shadowed.setter + def is_shadowed(self, is_shadowed): + self._is_shadowed = is_shadowed + # endregion ################################################################################### ################################################################################### @@ -930,7 +950,7 @@ class Function(ChildContract, SourceMapping): (str, str, str, list(str), list(str), listr(str), list(str), list(str); contract_name, name, visibility, modifiers, vars read, vars written, internal_calls, external_calls_as_expressions """ - return (self.contract.name, self.full_name, self.visibility, + return (self.original_contract.name, self.full_name, self.visibility, [str(x) for x in self.modifiers], [str(x) for x in self.state_variables_read + self.solidity_variables_read], [str(x) for x in self.state_variables_written], diff --git a/slither/core/variables/local_variable.py b/slither/core/variables/local_variable.py index 414910f67..39e237271 100644 --- a/slither/core/variables/local_variable.py +++ b/slither/core/variables/local_variable.py @@ -50,3 +50,8 @@ class LocalVariable(ChildFunction, Variable): return False + @property + def canonical_name(self): + return self.name + + diff --git a/slither/detectors/abstract_detector.py b/slither/detectors/abstract_detector.py index 0763ea75c..37324f80a 100644 --- a/slither/detectors/abstract_detector.py +++ b/slither/detectors/abstract_detector.py @@ -169,17 +169,32 @@ class AbstractDetector(metaclass=abc.ABCMeta): @staticmethod def add_function_to_json(function, d): contract = {'elements':[]} - AbstractDetector.add_contract_to_json(function.contract, contract) + AbstractDetector.add_contract_to_json(function.original_contract, contract) d['elements'].append({'type': 'function', 'name': function.name, 'source_mapping': function.source_mapping, 'contract': contract['elements'][0]}) + # We use the same json type for function and event to facilitate the third-party tools parsing + @staticmethod + def add_event_to_json(event, d): + contract = {'elements':[]} + AbstractDetector.add_contract_to_json(event.contract, contract) + d['elements'].append({'type': 'function', + 'name': event.name, + 'source_mapping': event.source_mapping, + 'contract': contract['elements'][0]}) + @staticmethod def add_functions_to_json(functions, d): for function in sorted(functions, key=lambda x: x.name): AbstractDetector.add_function_to_json(function, d) + @staticmethod + def add_events_to_json(events, d): + for event in sorted(events, key=lambda x: x.name): + AbstractDetector.add_event_to_json(event, d) + @staticmethod def add_nodes_to_json(nodes, d): for node in sorted(nodes, key=lambda x: x.node_id): diff --git a/slither/detectors/attributes/const_functions.py b/slither/detectors/attributes/const_functions.py index 029cfda8c..f38693f77 100644 --- a/slither/detectors/attributes/const_functions.py +++ b/slither/detectors/attributes/const_functions.py @@ -51,13 +51,13 @@ All the calls to `get` revert, breaking Bob's smart contract execution.''' results = [] for c in self.contracts: for f in c.functions: - if f.contract != c: + if f.original_contract != c: continue if f.view or f.pure: if f.contains_assembly: attr = 'view' if f.view else 'pure' - info = '{}.{} ({}) is declared {} but contains assembly code\n' - info = info.format(f.contract.name, f.name, f.source_mapping_str, attr) + info = '{} ({}) is declared {} but contains assembly code\n' + info = info.format(f.canonical_name, f.source_mapping_str, attr) json = self.generate_json_result(info) self.add_function_to_json(f, json) json['elements'].append({'type': 'info', @@ -67,11 +67,10 @@ All the calls to `get` revert, breaking Bob's smart contract execution.''' variables_written = f.all_state_variables_written() if variables_written: attr = 'view' if f.view else 'pure' - info = '{}.{} ({}) is declared {} but changes state variables:\n' - info = info.format(f.contract.name, f.name, f.source_mapping_str, attr) + info = '{} ({}) is declared {} but changes state variables:\n' + info = info.format(f.canonical_name, f.source_mapping_str, attr) for variable_written in variables_written: - info += '\t- {}.{}\n'.format(variable_written.contract.name, - variable_written.name) + info += '\t- {}\n'.format(variable_written.canonical_name) json = self.generate_json_result(info) diff --git a/slither/detectors/erc20/incorrect_interface.py b/slither/detectors/erc20/incorrect_interface.py index 94dc6f15b..dbd0feb92 100644 --- a/slither/detectors/erc20/incorrect_interface.py +++ b/slither/detectors/erc20/incorrect_interface.py @@ -52,7 +52,7 @@ contract Token{ Returns: list(str) : list of incorrect function signatures """ - functions = [f for f in contract.functions if f.contract == contract and \ + functions = [f for f in contract.functions if f.original_contract == contract and \ IncorrectERC20InterfaceDetection.incorrect_erc20_interface(f.signature)] return functions diff --git a/slither/detectors/erc20/unindexed_event_parameters.py b/slither/detectors/erc20/unindexed_event_parameters.py index c64a7681a..71327f94e 100644 --- a/slither/detectors/erc20/unindexed_event_parameters.py +++ b/slither/detectors/erc20/unindexed_event_parameters.py @@ -79,7 +79,7 @@ In this case, Transfer and Approval events should have the 'indexed' keyword on # 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) + self.add_events_to_json([event for event, _ in unindexed_params], json) results.append(json) return results diff --git a/slither/detectors/functions/arbitrary_send.py b/slither/detectors/functions/arbitrary_send.py index 59f33fcab..e5900a3c5 100644 --- a/slither/detectors/functions/arbitrary_send.py +++ b/slither/detectors/functions/arbitrary_send.py @@ -94,7 +94,7 @@ Bob calls `setDestination` and `withdraw`. As a result he withdraws the contract list((Function), (list (Node))) """ ret = [] - for f in [f for f in contract.functions if f.contract == contract]: + for f in [f for f in contract.functions if f.original_contract == contract]: nodes = self.arbitrary_send(f) if nodes: ret.append((f, nodes)) @@ -109,9 +109,8 @@ Bob calls `setDestination` and `withdraw`. As a result he withdraws the contract arbitrary_send = self.detect_arbitrary_send(c) for (func, nodes) in arbitrary_send: - info = "{}.{} ({}) sends eth to arbitrary user\n" - info = info.format(func.contract.name, - func.name, + info = "{} ({}) sends eth to arbitrary user\n" + info = info.format(func.canonical_name, func.source_mapping_str) info += '\tDangerous calls:\n' for node in nodes: diff --git a/slither/detectors/functions/complex_function.py b/slither/detectors/functions/complex_function.py index 4f0c9093a..2e3c0ac26 100644 --- a/slither/detectors/functions/complex_function.py +++ b/slither/detectors/functions/complex_function.py @@ -90,7 +90,7 @@ class ComplexFunction(AbstractDetector): for issue in issues: func, cause = issue.values() - txt = "{}.{} ({}) is a complex function:\n" + txt = "{} ({}) is a complex function:\n" if cause == self.CAUSE_EXTERNAL_CALL: txt += "\t- Reason: High number of external calls" @@ -99,8 +99,7 @@ class ComplexFunction(AbstractDetector): if cause == self.CAUSE_STATE_VARS: txt += "\t- Reason: High number of modified state variables" - info = txt.format(func.contract.name, - func.name, + info = txt.format(func.canonical_name, func.source_mapping_str) info = info + "\n" self.log(info) diff --git a/slither/detectors/functions/external_function.py b/slither/detectors/functions/external_function.py index 1d80e4e95..50e0d52b2 100644 --- a/slither/detectors/functions/external_function.py +++ b/slither/detectors/functions/external_function.py @@ -165,9 +165,8 @@ class ExternalFunction(AbstractDetector): # Loop for each function definition, and recommend it be declared external. for function_definition in all_function_definitions: - txt = "{}.{} ({}) should be declared external\n" - info = txt.format(function_definition.contract.name, - function_definition.name, + txt = "{} ({}) should be declared external\n" + info = txt.format(function_definition.canonical_name, function_definition.source_mapping_str) json = self.generate_json_result(info) diff --git a/slither/detectors/functions/suicidal.py b/slither/detectors/functions/suicidal.py index 66751dc9c..f20c4da13 100644 --- a/slither/detectors/functions/suicidal.py +++ b/slither/detectors/functions/suicidal.py @@ -59,7 +59,7 @@ Bob calls `kill` and destructs the contract.''' def detect_suicidal(self, contract): ret = [] - for f in [f for f in contract.functions if f.contract == contract]: + for f in [f for f in contract.functions if f.original_contract == contract]: if self.detect_suicidal_func(f): ret.append(f) return ret @@ -72,9 +72,8 @@ Bob calls `kill` and destructs the contract.''' functions = self.detect_suicidal(c) for func in functions: - txt = "{}.{} ({}) allows anyone to destruct the contract\n" - info = txt.format(func.contract.name, - func.name, + txt = "{} ({}) allows anyone to destruct the contract\n" + info = txt.format(func.canonical_name, func.source_mapping_str) json = self.generate_json_result(info) diff --git a/slither/detectors/naming_convention/naming_convention.py b/slither/detectors/naming_convention/naming_convention.py index 545d14e06..4ec7fc6d1 100644 --- a/slither/detectors/naming_convention/naming_convention.py +++ b/slither/detectors/naming_convention/naming_convention.py @@ -90,8 +90,8 @@ Solidity defines a [naming convention](https://solidity.readthedocs.io/en/v0.4.2 continue if not self.is_cap_words(event.name): - info = "Event '{}.{}' ({}) is not in CapWords\n" - info = info.format(event.contract.name, event.name, event.source_mapping_str) + info = "Event '{}' ({}) is not in CapWords\n" + info = info.format(event.canonical_name, event.source_mapping_str) json = self.generate_json_result(info) elem = dict() @@ -103,12 +103,12 @@ Solidity defines a [naming convention](https://solidity.readthedocs.io/en/v0.4.2 results.append(json) for func in contract.functions: - if func.contract != contract: + if func.original_contract != contract: continue if not self.is_mixed_case(func.name): - info = "Function '{}.{}' ({}) is not in mixedCase\n" - info = info.format(func.contract.name, func.name, func.source_mapping_str) + info = "Function '{}' ({}) is not in mixedCase\n" + info = info.format(func.canonical_name, func.source_mapping_str) json = self.generate_json_result(info) elem = dict() @@ -125,10 +125,9 @@ Solidity defines a [naming convention](https://solidity.readthedocs.io/en/v0.4.2 else: correct_naming = self.is_mixed_case_with_underscore(argument.name) if not correct_naming: - info = "Parameter '{}' of {}.{} ({}) is not in mixedCase\n" + info = "Parameter '{}' of {} ({}) is not in mixedCase\n" info = info.format(argument.name, - argument.function.contract.name, - argument.function, + argument.canonical_name, argument.source_mapping_str) json = self.generate_json_result(info) @@ -146,8 +145,8 @@ Solidity defines a [naming convention](https://solidity.readthedocs.io/en/v0.4.2 if self.should_avoid_name(var.name): if not self.is_upper_case_with_underscores(var.name): - info = "Variable '{}.{}' ({}) used l, O, I, which should not be used\n" - info = info.format(var.contract.name, var.name, var.source_mapping_str) + info = "Variable '{}' ({}) used l, O, I, which should not be used\n" + info = info.format(var.canonical_name, var.source_mapping_str) json = self.generate_json_result(info) elem = dict() @@ -164,8 +163,8 @@ Solidity defines a [naming convention](https://solidity.readthedocs.io/en/v0.4.2 continue if not self.is_upper_case_with_underscores(var.name): - info = "Constant '{}.{}' ({}) is not in UPPER_CASE_WITH_UNDERSCORES\n" - info = info.format(var.contract.name, var.name, var.source_mapping_str) + info = "Constant '{}' ({}) is not in UPPER_CASE_WITH_UNDERSCORES\n" + info = info.format(var.canonical_name, var.source_mapping_str) json = self.generate_json_result(info) elem = dict() @@ -182,8 +181,8 @@ Solidity defines a [naming convention](https://solidity.readthedocs.io/en/v0.4.2 else: correct_naming = self.is_mixed_case(var.name) if not correct_naming: - info = "Variable '{}.{}' ({}) is not in mixedCase\n" - info = info.format(var.contract.name, var.name, var.source_mapping_str) + info = "Variable '{}' ({}) is not in mixedCase\n" + info = info.format(var.canonical_name, var.source_mapping_str) json = self.generate_json_result(info) elem = dict() @@ -199,8 +198,8 @@ Solidity defines a [naming convention](https://solidity.readthedocs.io/en/v0.4.2 continue if not self.is_cap_words(enum.name): - info = "Enum '{}.{}' ({}) is not in CapWords\n" - info = info.format(enum.contract.name, enum.name, enum.source_mapping_str) + info = "Enum '{}' ({}) is not in CapWords\n" + info = info.format(enum.canonical_name, enum.source_mapping_str) json = self.generate_json_result(info) elem = dict() @@ -213,13 +212,12 @@ Solidity defines a [naming convention](https://solidity.readthedocs.io/en/v0.4.2 for modifier in contract.modifiers: - if modifier.contract != contract: + if modifier.original_contract != contract: continue if not self.is_mixed_case(modifier.name): - info = "Modifier '{}.{}' ({}) is not in mixedCase\n" - info = info.format(modifier.contract.name, - modifier.name, + info = "Modifier '{}' ({}) is not in mixedCase\n" + info = info.format(modifier.canonical_name, modifier.source_mapping_str) json = self.generate_json_result(info) diff --git a/slither/detectors/operations/block_timestamp.py b/slither/detectors/operations/block_timestamp.py index 86912098d..ecadb2e94 100644 --- a/slither/detectors/operations/block_timestamp.py +++ b/slither/detectors/operations/block_timestamp.py @@ -54,7 +54,7 @@ class Timestamp(AbstractDetector): list((Function), (list (Node))) """ ret = [] - for f in [f for f in contract.functions if f.contract == contract]: + for f in [f for f in contract.functions if f.original_contract == contract]: nodes = self.timestamp(f) if nodes: ret.append((f, nodes)) @@ -69,9 +69,8 @@ class Timestamp(AbstractDetector): dangerous_timestamp = self.detect_dangerous_timestamp(c) for (func, nodes) in dangerous_timestamp: - info = "{}.{} ({}) uses timestamp for comparisons\n" - info = info.format(func.contract.name, - func.name, + info = "{} ({}) uses timestamp for comparisons\n" + info = info.format(func.canonical_name, func.source_mapping_str) info += '\tDangerous comparisons:\n' for node in nodes: diff --git a/slither/detectors/operations/low_level_calls.py b/slither/detectors/operations/low_level_calls.py index 9123a2c67..9a819518d 100644 --- a/slither/detectors/operations/low_level_calls.py +++ b/slither/detectors/operations/low_level_calls.py @@ -33,7 +33,7 @@ class LowLevelCalls(AbstractDetector): def detect_low_level_calls(self, contract): ret = [] - for f in [f for f in contract.functions if contract == f.contract]: + for f in [f for f in contract.functions if contract == f.original_contract]: nodes = f.nodes assembly_nodes = [n for n in nodes if self._contains_low_level_calls(n)] @@ -48,8 +48,8 @@ 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 = info.format(func.contract.name, func.name, func.source_mapping_str) + info = "Low level call in {} ({}):\n" + info = info.format(func.canonical_name, func.source_mapping_str) for node in nodes: info += "\t-{} {}\n".format(str(node.expression), node.source_mapping_str) diff --git a/slither/detectors/operations/unused_return_values.py b/slither/detectors/operations/unused_return_values.py index 04e50398b..ee153f03a 100644 --- a/slither/detectors/operations/unused_return_values.py +++ b/slither/detectors/operations/unused_return_values.py @@ -64,13 +64,12 @@ contract MyConc{ results = [] for c in self.slither.contracts: for f in c.functions + c.modifiers: - if f.contract != c: + if f.original_contract != c: continue unused_return = self.detect_unused_return_values(f) if unused_return: - info = "{}.{} ({}) does not use the value returned by external calls:\n" - info = info.format(f.contract.name, - f.name, + info = "{} ({}) does not use the value returned by external calls:\n" + info = info.format(f.canonical_name, f.source_mapping_str) for node in unused_return: info += "\t-{} ({})\n".format(node.expression, node.source_mapping_str) diff --git a/slither/detectors/reentrancy/reentrancy_benign.py b/slither/detectors/reentrancy/reentrancy_benign.py index a2d570e60..7cecc3e64 100644 --- a/slither/detectors/reentrancy/reentrancy_benign.py +++ b/slither/detectors/reentrancy/reentrancy_benign.py @@ -84,8 +84,8 @@ Only report reentrancy that acts as a double call (see `reentrancy-eth`, `reentr for (func, calls, send_eth), varsWritten in result_sorted: calls = sorted(list(set(calls)), key=lambda x: x.node_id) send_eth = sorted(list(set(send_eth)), key=lambda x: x.node_id) - info = 'Reentrancy in {}.{} ({}):\n' - info = info.format(func.contract.name, func.name, func.source_mapping_str) + info = 'Reentrancy in {} ({}):\n' + info = info.format(func.canonical_name, func.source_mapping_str) info += '\tExternal calls:\n' for call_info in calls: info += '\t- {} ({})\n'.format(call_info.expression, call_info.source_mapping_str) diff --git a/slither/detectors/reentrancy/reentrancy_eth.py b/slither/detectors/reentrancy/reentrancy_eth.py index 8d0691a5b..0ea1b9357 100644 --- a/slither/detectors/reentrancy/reentrancy_eth.py +++ b/slither/detectors/reentrancy/reentrancy_eth.py @@ -87,8 +87,8 @@ Bob uses the re-entrancy bug to call `withdrawBalance` two times, and withdraw m calls = sorted(list(set(calls)), key=lambda x: x.node_id) send_eth = sorted(list(set(send_eth)), key=lambda x: x.node_id) - info = 'Reentrancy in {}.{} ({}):\n' - info = info.format(func.contract.name, func.name, func.source_mapping_str) + info = 'Reentrancy in {} ({}):\n' + info = info.format(func.canonical_name, func.source_mapping_str) info += '\tExternal calls:\n' for call_info in calls: info += '\t- {} ({})\n'.format(call_info.expression, call_info.source_mapping_str) diff --git a/slither/detectors/reentrancy/reentrancy_read_before_write.py b/slither/detectors/reentrancy/reentrancy_read_before_write.py index 379585285..95c0e5012 100644 --- a/slither/detectors/reentrancy/reentrancy_read_before_write.py +++ b/slither/detectors/reentrancy/reentrancy_read_before_write.py @@ -82,8 +82,8 @@ Do not report reentrancies that involve ethers (see `reentrancy-eth`)''' result_sorted = sorted(list(reentrancies.items()), key=lambda x:x[0][0].name) for (func, calls), varsWritten in result_sorted: calls = sorted(list(set(calls)), key=lambda x: x.node_id) - info = 'Reentrancy in {}.{} ({}):\n' - info = info.format(func.contract.name, func.name, func.source_mapping_str) + info = 'Reentrancy in {} ({}):\n' + info = info.format(func.canonical_name, func.source_mapping_str) info += '\tExternal calls:\n' for call_info in calls: info += '\t- {} ({})\n'.format(call_info.expression, call_info.source_mapping_str) diff --git a/slither/detectors/shadowing/builtin_symbols.py b/slither/detectors/shadowing/builtin_symbols.py index dc9981c41..cc8a1f19e 100644 --- a/slither/detectors/shadowing/builtin_symbols.py +++ b/slither/detectors/shadowing/builtin_symbols.py @@ -91,12 +91,12 @@ contract Bug { # Loop through all functions, modifiers, variables (state and local) to detect any built-in symbol keywords. for function in contract.functions: - if function.contract == contract: + if function.original_contract == contract: if self.is_builtin_symbol(function.name): result.append((self.SHADOWING_FUNCTION, function, None)) result += self.detect_builtin_shadowing_locals(function) for modifier in contract.modifiers: - if modifier.contract == contract: + if modifier.original_contract == contract: if self.is_builtin_symbol(modifier.name): result.append((self.SHADOWING_MODIFIER, modifier, None)) result += self.detect_builtin_shadowing_locals(modifier) @@ -143,8 +143,10 @@ contract Bug { # Generate relevant JSON data for this shadowing definition. json = self.generate_json_result(info) - if shadow_type in [self.SHADOWING_FUNCTION, self.SHADOWING_MODIFIER, self.SHADOWING_EVENT]: + if shadow_type in [self.SHADOWING_FUNCTION, self.SHADOWING_MODIFIER]: self.add_function_to_json(shadow_object, json) + elif shadow_type == self.SHADOWING_EVENT: + self.add_event_to_json(shadow_object, json) elif shadow_type in [self.SHADOWING_STATE_VARIABLE, self.SHADOWING_LOCAL_VARIABLE]: self.add_variable_to_json(shadow_object, json) results.append(json) diff --git a/slither/detectors/shadowing/local.py b/slither/detectors/shadowing/local.py index 0a04ebed7..20d5cebc7 100644 --- a/slither/detectors/shadowing/local.py +++ b/slither/detectors/shadowing/local.py @@ -59,7 +59,7 @@ contract Bug { # Loop through all functions + modifiers in this contract. for function in contract.functions + contract.modifiers: # We should only look for functions declared directly in this contract (not in a base contract). - if function.contract != contract: + if function.original_contract != contract: continue # This function was declared in this contract, we check what its local variables might shadow. @@ -68,11 +68,11 @@ contract Bug { for scope_contract in [contract] + contract.inheritance: # Check functions for scope_function in scope_contract.functions: - if variable.name == scope_function.name and scope_function.contract == scope_contract: + if variable.name == scope_function.name and scope_function.original_contract == scope_contract: overshadowed.append((self.OVERSHADOWED_FUNCTION, scope_contract.name, scope_function)) # Check modifiers for scope_modifier in scope_contract.modifiers: - if variable.name == scope_modifier.name and scope_modifier.contract == scope_contract: + if variable.name == scope_modifier.name and scope_modifier.original_contract == scope_contract: overshadowed.append((self.OVERSHADOWED_MODIFIER, scope_contract.name, scope_modifier)) # Check events for scope_event in scope_contract.events: @@ -121,9 +121,10 @@ contract Bug { json = self.generate_json_result(info) self.add_variable_to_json(local_variable, json) for overshadowed_entry in overshadowed: - if overshadowed_entry[0] in [self.OVERSHADOWED_FUNCTION, self.OVERSHADOWED_MODIFIER, - self.OVERSHADOWED_EVENT]: + if overshadowed_entry[0] in [self.OVERSHADOWED_FUNCTION, self.OVERSHADOWED_MODIFIER]: self.add_function_to_json(overshadowed_entry[2], json) + elif overshadowed_entry[0] == self.OVERSHADOWED_EVENT: + self.add_event_to_json(overshadowed_entry[2], json) elif overshadowed_entry[0] == self.OVERSHADOWED_STATE_VARIABLE: self.add_variable_to_json(overshadowed_entry[2], json) results.append(json) diff --git a/slither/detectors/shadowing/state.py b/slither/detectors/shadowing/state.py index bd0b67d89..75ba66132 100644 --- a/slither/detectors/shadowing/state.py +++ b/slither/detectors/shadowing/state.py @@ -76,13 +76,11 @@ contract DerivedContract is BaseContract{ for all_variables in shadowing: shadow = all_variables[0] variables = all_variables[1:] - info = '{}.{} ({}) shadows:\n'.format(shadow.contract.name, - shadow.name, - shadow.source_mapping_str) + info = '{} ({}) shadows:\n'.format(shadow.canonical_name, + shadow.source_mapping_str) for var in variables: - info += "\t- {}.{} ({})\n".format(var.contract.name, - var.name, - var.source_mapping_str) + info += "\t- {} ({})\n".format(var.canonical_name, + var.source_mapping_str) json = self.generate_json_result(info) self.add_variables_to_json(all_variables, json) diff --git a/slither/detectors/statements/assembly.py b/slither/detectors/statements/assembly.py index e1b35a6f2..d95a81731 100644 --- a/slither/detectors/statements/assembly.py +++ b/slither/detectors/statements/assembly.py @@ -35,7 +35,7 @@ class Assembly(AbstractDetector): def detect_assembly(self, contract): ret = [] for f in contract.functions: - if f.contract != contract: + if f.original_contract != contract: continue nodes = f.nodes assembly_nodes = [n for n in nodes if @@ -51,8 +51,8 @@ class Assembly(AbstractDetector): for c in self.contracts: values = self.detect_assembly(c) for func, nodes in values: - info = "{}.{} uses assembly ({})\n" - info = info.format(func.contract.name, func.name, func.source_mapping_str) + info = "{} uses assembly ({})\n" + info = info.format(func.canonical_name, func.source_mapping_str) for node in nodes: info += "\t- {}\n".format(node.source_mapping_str) diff --git a/slither/detectors/statements/calls_in_loop.py b/slither/detectors/statements/calls_in_loop.py index 807ea7e23..b3fa39f26 100644 --- a/slither/detectors/statements/calls_in_loop.py +++ b/slither/detectors/statements/calls_in_loop.py @@ -72,7 +72,7 @@ If one of the destinations has a fallback function which reverts, `bad` will alw def detect_call_in_loop(contract): ret = [] for f in contract.functions + contract.modifiers: - if f.contract == contract and f.is_implemented: + if f.original_contract == contract and f.is_implemented: MultipleCallsInLoop.call_in_loop(f.entry_point, False, [], ret) @@ -86,8 +86,8 @@ If one of the destinations has a fallback function which reverts, `bad` will alw values = self.detect_call_in_loop(c) for node in values: func = node.function - info = "{}.{} has external calls inside a loop:\n" - info = info.format(func.contract.name, func.name) + info = "{} has external calls inside a loop:\n" + info = info.format(func.canonical_name) info += "\t- {} ({})\n".format(node.expression, node.source_mapping_str) diff --git a/slither/detectors/statements/controlled_delegatecall.py b/slither/detectors/statements/controlled_delegatecall.py index fbe657f32..0f721426e 100644 --- a/slither/detectors/statements/controlled_delegatecall.py +++ b/slither/detectors/statements/controlled_delegatecall.py @@ -42,7 +42,7 @@ Bob calls `delegate` and delegates the execution to its malicious contract. As a for contract in self.slither.contracts: for f in contract.functions: - if f.contract != contract: + if f.original_contract != contract: continue nodes = self.controlled_delegatecall(f) if nodes: diff --git a/slither/detectors/statements/incorrect_strict_equality.py b/slither/detectors/statements/incorrect_strict_equality.py index a1fedf140..05f2aa42a 100644 --- a/slither/detectors/statements/incorrect_strict_equality.py +++ b/slither/detectors/statements/incorrect_strict_equality.py @@ -112,9 +112,8 @@ contract Crowdsale{ # sort ret to get deterministic results ret = sorted(list(ret.items()), key=lambda x:x[0].name) for f, nodes in ret: - info += "{}.{} ({}) uses a dangerous strict equality:\n".format(f.contract.name, - f.name, - f.source_mapping_str) + info += "{} ({}) uses a dangerous strict equality:\n".format(f.canonical_name, + f.source_mapping_str) # sort the nodes to get deterministic results nodes.sort(key=lambda x: x.node_id) diff --git a/slither/detectors/statements/tx_origin.py b/slither/detectors/statements/tx_origin.py index bbd86d9bf..995ac53d6 100644 --- a/slither/detectors/statements/tx_origin.py +++ b/slither/detectors/statements/tx_origin.py @@ -65,8 +65,8 @@ Bob is the owner of `TxOrigin`. Bob calls Eve's contract. Eve's contract calls ` for c in self.contracts: values = self.detect_tx_origin(c) for func, nodes in values: - info = "{}.{} uses tx.origin for authorization:\n" - info = info.format(func.contract.name, func.name) + info = "{} uses tx.origin for authorization:\n" + info = info.format(func.canonical_name) for node in nodes: info += "\t- {} ({})\n".format(node.expression, node.source_mapping_str) diff --git a/slither/detectors/variables/possible_const_state_variables.py b/slither/detectors/variables/possible_const_state_variables.py index 7e726be46..58c5cb66a 100644 --- a/slither/detectors/variables/possible_const_state_variables.py +++ b/slither/detectors/variables/possible_const_state_variables.py @@ -85,9 +85,8 @@ class ConstCandidateStateVars(AbstractDetector): # Order for deterministic results constable_variables = sorted(constable_variables, key=lambda x: x.canonical_name) for v in constable_variables: - info = "{}.{} should be constant ({})\n".format(v.contract.name, - v.name, - v.source_mapping_str) + info = "{} should be constant ({})\n".format(v.canonical_name, + v.source_mapping_str) all_info += info if all_info != '': json = self.generate_json_result(all_info) diff --git a/slither/detectors/variables/uninitialized_local_variables.py b/slither/detectors/variables/uninitialized_local_variables.py index d9854b339..289f844d5 100644 --- a/slither/detectors/variables/uninitialized_local_variables.py +++ b/slither/detectors/variables/uninitialized_local_variables.py @@ -90,7 +90,7 @@ Bob calls `transfer`. As a result, the ethers are sent to the address 0x0 and ar for contract in self.slither.contracts: for function in contract.functions: - if function.is_implemented and function.contract == contract: + if function.is_implemented and function.original_contract == contract: if function.contains_assembly: continue # dont consider storage variable, as they are detected by another detector @@ -101,10 +101,9 @@ Bob calls `transfer`. As a result, the ethers are sent to the address 0x0 and ar for(function, uninitialized_local_variable) in all_results: var_name = uninitialized_local_variable.name - info = "{} in {}.{} ({}) is a local variable never initialiazed\n" + info = "{} in {} ({}) is a local variable never initialiazed\n" info = info.format(var_name, - function.contract.name, - function.name, + function.canonical_name, uninitialized_local_variable.source_mapping_str) diff --git a/slither/detectors/variables/uninitialized_state_variables.py b/slither/detectors/variables/uninitialized_state_variables.py index 2dec5e7e5..18b89324b 100644 --- a/slither/detectors/variables/uninitialized_state_variables.py +++ b/slither/detectors/variables/uninitialized_state_variables.py @@ -92,9 +92,8 @@ Initialize all the variables. If a variable is meant to be initialized to zero, for c in self.slither.contracts_derived: 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, + info = "{} ({}) is never initialized. It is used in:\n" + info = info.format(variable.canonical_name, variable.source_mapping_str) for f in functions: info += "\t- {} ({})\n".format(f.name, f.source_mapping_str) diff --git a/slither/detectors/variables/uninitialized_storage_variables.py b/slither/detectors/variables/uninitialized_storage_variables.py index 3cc5a56ef..ef1d9ba3c 100644 --- a/slither/detectors/variables/uninitialized_storage_variables.py +++ b/slither/detectors/variables/uninitialized_storage_variables.py @@ -105,8 +105,8 @@ Bob calls `func`. As a result, `owner` is override to 0. for(function, uninitialized_storage_variable) in self.results: var_name = uninitialized_storage_variable.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) + info = "{} in {} ({}) is a storage variable never initialiazed\n" + info = info.format(var_name, function.canonical_name, uninitialized_storage_variable.source_mapping_str) json = self.generate_json_result(info) diff --git a/slither/detectors/variables/unused_state_variables.py b/slither/detectors/variables/unused_state_variables.py index c713c33a9..b293ecb69 100644 --- a/slither/detectors/variables/unused_state_variables.py +++ b/slither/detectors/variables/unused_state_variables.py @@ -57,10 +57,9 @@ class UnusedStateVars(AbstractDetector): if unusedVars: info = '' for var in unusedVars: - info += "{}.{} ({}) is never used in {}\n".format(var.contract.name, - var.name, - var.source_mapping_str, - c.name) + info += "{} ({}) is never used in {}\n".format(var.canonical_name, + var.source_mapping_str, + c.name) json = self.generate_json_result(info) diff --git a/slither/printers/inheritance/inheritance_graph.py b/slither/printers/inheritance/inheritance_graph.py index 468969002..fb6e7d834 100644 --- a/slither/printers/inheritance/inheritance_graph.py +++ b/slither/printers/inheritance/inheritance_graph.py @@ -116,14 +116,14 @@ class PrinterInheritanceGraph(AbstractPrinter): # Functions visibilities = ['public', 'external'] public_functions = [self._get_pattern_func(f, contract) for f in contract.functions if - not f.is_constructor and f.contract == contract and f.visibility in visibilities] + not f.is_constructor and f.original_contract == contract and f.visibility in visibilities] public_functions = ''.join(public_functions) private_functions = [self._get_pattern_func(f, contract) for f in contract.functions if - not f.is_constructor and f.contract == contract and f.visibility not in visibilities] + not f.is_constructor and f.original_contract == contract and f.visibility not in visibilities] private_functions = ''.join(private_functions) # Modifiers - modifiers = [self._get_pattern_func(m, contract) for m in contract.modifiers if m.contract == contract] + modifiers = [self._get_pattern_func(m, contract) for m in contract.modifiers if m.original_contract == contract] modifiers = ''.join(modifiers) # Public variables diff --git a/slither/printers/summary/slithir.py b/slither/printers/summary/slithir.py index 3cad7b4e4..e34c9d34d 100644 --- a/slither/printers/summary/slithir.py +++ b/slither/printers/summary/slithir.py @@ -23,26 +23,24 @@ class PrinterSlithIR(AbstractPrinter): for contract in self.contracts: print('Contract {}'.format(contract.name)) for function in contract.functions: - if function.contract == contract: - print('\tFunction {}'.format(function.full_name)) - for node in function.nodes: - if node.expression: - print('\t\tExpression: {}'.format(node.expression)) - print('\t\tIRs:') - for ir in node.irs: - print('\t\t\t{}'.format(ir)) - elif node.irs: - print('\t\tIRs:') - for ir in node.irs: - print('\t\t\t{}'.format(ir)) + print('\tFunction {}'.format(function.canonical_name)) + for node in function.nodes: + if node.expression: + print('\t\tExpression: {}'.format(node.expression)) + print('\t\tIRs:') + for ir in node.irs: + print('\t\t\t{}'.format(ir)) + elif node.irs: + print('\t\tIRs:') + for ir in node.irs: + print('\t\t\t{}'.format(ir)) for modifier in contract.modifiers: - if modifier.contract == contract: - print('\tModifier {}'.format(modifier.full_name)) - for node in modifier.nodes: - print(node) - if node.expression: - print('\t\tExpression: {}'.format(node.expression)) - print('\t\tIRs:') - for ir in node.irs: - print('\t\t\t{}'.format(ir)) + print('\tModifier {}'.format(modifier.canonical_name)) + for node in modifier.nodes: + print(node) + if node.expression: + print('\t\tExpression: {}'.format(node.expression)) + print('\t\tIRs:') + for ir in node.irs: + print('\t\t\t{}'.format(ir)) self.info(txt) diff --git a/slither/printers/summary/slithir_ssa.py b/slither/printers/summary/slithir_ssa.py index 6227c4167..c97a291fa 100644 --- a/slither/printers/summary/slithir_ssa.py +++ b/slither/printers/summary/slithir_ssa.py @@ -23,24 +23,22 @@ class PrinterSlithIRSSA(AbstractPrinter): for contract in self.contracts: print('Contract {}'.format(contract.name)) for function in contract.functions: - if function.contract == contract: - print('\tFunction {}'.format(function.full_name)) - for node in function.nodes: - if node.expression: - print('\t\tExpression: {}'.format(node.expression)) - if node.irs_ssa: - print('\t\tIRs:') - for ir in node.irs_ssa: - print('\t\t\t{}'.format(ir)) + print('\tFunction {}'.format(function.canonical_name)) + for node in function.nodes: + if node.expression: + print('\t\tExpression: {}'.format(node.expression)) + if node.irs_ssa: + print('\t\tIRs:') + for ir in node.irs_ssa: + print('\t\t\t{}'.format(ir)) for modifier in contract.modifiers: - if modifier.contract == contract: - print('\tModifier {}'.format(modifier.full_name)) - for node in modifier.nodes: - print(node) - if node.expression: - print('\t\tExpression: {}'.format(node.expression)) - if node.irs_ssa: - print('\t\tIRs:') - for ir in node.irs_ssa: - print('\t\t\t{}'.format(ir)) + print('\tModifier {}'.format(modifier.canonical_name)) + for node in modifier.nodes: + print(node) + if node.expression: + print('\t\tExpression: {}'.format(node.expression)) + if node.irs_ssa: + print('\t\tIRs:') + for ir in node.irs_ssa: + print('\t\t\t{}'.format(ir)) self.info(txt) diff --git a/slither/slithir/operations/internal_call.py b/slither/slithir/operations/internal_call.py index 5f2210e90..c0e5b54f5 100644 --- a/slither/slithir/operations/internal_call.py +++ b/slither/slithir/operations/internal_call.py @@ -56,9 +56,8 @@ class InternalCall(Call, OperationWithLValue): lvalue = '{}({}) = '.format(self.lvalue, ','.join(str(x) for x in self.lvalue.type)) else: lvalue = '{}({}) = '.format(self.lvalue, self.lvalue.type) - txt = '{}INTERNAL_CALL, {}.{}({})' + txt = '{}INTERNAL_CALL, {}({})' return txt.format(lvalue, - self.function.contract.name, - self.function.full_name, + self.function.canonical_name, ','.join(args)) diff --git a/slither/slithir/variables/state_variable.py b/slither/slithir/variables/state_variable.py index d2f5d1d6b..ecefe98c7 100644 --- a/slither/slithir/variables/state_variable.py +++ b/slither/slithir/variables/state_variable.py @@ -43,4 +43,4 @@ class StateIRVariable(StateVariable, SlithIRVariable): @property def ssa_name(self): - return '{}.{}_{}'.format(self.id, self._name, self.index) + return '{}_{}'.format(self._name, self.index) diff --git a/slither/solc_parsing/declarations/contract.py b/slither/solc_parsing/declarations/contract.py index 953210bf5..500b67a9c 100644 --- a/slither/solc_parsing/declarations/contract.py +++ b/slither/solc_parsing/declarations/contract.py @@ -232,8 +232,9 @@ class ContractSolc04(Contract): def _parse_modifier(self, modifier): - modif = ModifierSolc(modifier, self) + modif = ModifierSolc(modifier, self, self) modif.set_contract(self) + modif.set_original_contract(self) modif.set_offset(modifier['src'], self.slither) self.slither.add_modifier(modif) self._modifiers_no_params.append(modif) @@ -247,7 +248,7 @@ class ContractSolc04(Contract): return def _parse_function(self, function): - func = FunctionSolc(function, self) + func = FunctionSolc(function, self, self) func.set_offset(function['src'], self.slither) self.slither.add_function(func) self._functions_no_params.append(func) @@ -281,26 +282,52 @@ class ContractSolc04(Contract): return def analyze_params_modifiers(self): - for father in self.inheritance_reverse: - self._modifiers.update(father.modifiers_as_dict()) - for modifier in self._modifiers_no_params: - modifier.analyze_params() - self._modifiers[modifier.full_name] = modifier + elements_no_params = self._modifiers_no_params + getter = lambda f: f.modifiers + getter_available = lambda f: f.available_modifiers_as_dict().items() + Cls = ModifierSolc + self._modifiers = self._analyze_params_elements(elements_no_params, getter, getter_available, Cls) self._modifiers_no_params = [] + return def analyze_params_functions(self): - # keep track of the contracts visited - # to prevent an ovveride due to multiple inheritance of the same contract - # A is B, C, D is C, --> the second C was already seen - contracts_visited = [] - for father in self.inheritance_reverse: - functions = {k:v for (k, v) in father.functions_as_dict().items() - if not v.contract in contracts_visited} - contracts_visited.append(father) - self._functions.update(functions) + + elements_no_params = self._functions_no_params + getter = lambda f: f.functions + getter_available = lambda f: f.available_functions_as_dict().items() + Cls = FunctionSolc + self._functions = self._analyze_params_elements(elements_no_params, getter, getter_available, Cls) + + self._functions_no_params = [] + return + + + def _analyze_params_elements(self, elements_no_params, getter, getter_available, Cls): + """ + Analyze the parameters of the given elements (Function or Modifier). + The function iterates over the inheritance to create an instance or inherited elements (Function or Modifier) + If the element is shadowed, set is_shadowed to True + :param elements_no_params: list of elements to analyzer + :param getter: fun x + :param getter_available: fun x + :param Cls: Class to create for collision + :return: + """ + all_elements = {} + accessible_elements = {} + + for father in self.inheritance: + for element in getter(father): + elem = Cls(element._functionNotParsed, self, element.original_contract) + elem.set_offset(element._functionNotParsed['src'], self.slither) + elem.analyze_params() + self.slither.add_function(elem) + all_elements[elem.canonical_name] = elem + + accessible_elements = self.available_elements_from_inheritances(all_elements, getter_available) # If there is a constructor in the functions # We remove the previous constructor @@ -308,20 +335,25 @@ class ContractSolc04(Contract): # # Note: contract.all_functions_called returns the constructors of the base contracts has_constructor = False - for function in self._functions_no_params: - function.analyze_params() - if function.is_constructor: + for element in elements_no_params: + element.analyze_params() + if element.is_constructor: has_constructor = True if has_constructor: - _functions = {k:v for (k, v) in self._functions.items() if not v.is_constructor} - self._functions = _functions + _accessible_functions = {k: v for (k, v) in accessible_elements.items() if not v.is_constructor} + + for element in elements_no_params: + accessible_elements[element.full_name] = element + all_elements[element.canonical_name] = element + + for element in all_elements.values(): + if accessible_elements[element.full_name] != all_elements[element.canonical_name]: + element.is_shadowed = True + + return all_elements - for function in self._functions_no_params: - self._functions[function.full_name] = function - self._functions_no_params = [] - return def analyze_constant_state_variables(self): from slither.solc_parsing.expressions.expression_parsing import VariableNotFound @@ -434,8 +466,7 @@ class ContractSolc04(Contract): def convert_expression_to_slithir(self): for func in self.functions + self.modifiers: - if func.contract == self: - func.generate_slithir_and_analyze() + func.generate_slithir_and_analyze() all_ssa_state_variables_instances = dict() @@ -453,8 +484,7 @@ class ContractSolc04(Contract): self._initial_state_variables.append(new_var) for func in self.functions + self.modifiers: - if func.contract == self: - func.generate_slithir_ssa(all_ssa_state_variables_instances) + func.generate_slithir_ssa(all_ssa_state_variables_instances) def fix_phi(self): last_state_variables_instances = dict() diff --git a/slither/solc_parsing/declarations/function.py b/slither/solc_parsing/declarations/function.py index 6b95ca9f9..75580ecac 100644 --- a/slither/solc_parsing/declarations/function.py +++ b/slither/solc_parsing/declarations/function.py @@ -34,9 +34,10 @@ class FunctionSolc(Function): """ # elems = [(type, name)] - def __init__(self, function, contract): + def __init__(self, function, contract, original_contract): super(FunctionSolc, self).__init__() self._contract = contract + self._original_contract = original_contract # Only present if compact AST self._referenced_declaration = None diff --git a/slither/solc_parsing/expressions/expression_parsing.py b/slither/solc_parsing/expressions/expression_parsing.py index 39b2334d6..fd1e6139d 100644 --- a/slither/solc_parsing/expressions/expression_parsing.py +++ b/slither/solc_parsing/expressions/expression_parsing.py @@ -68,8 +68,7 @@ def get_pointer_name(variable): return None -def find_variable(var_name, caller_context, referenced_declaration=None): - +def find_variable(var_name, caller_context, referenced_declaration=None, is_super=False): if isinstance(caller_context, Contract): function = None @@ -108,12 +107,21 @@ def find_variable(var_name, caller_context, referenced_declaration=None): if var_name and var_name in conc_variables_ptr: return conc_variables_ptr[var_name] - - functions = contract.functions_as_dict() + if is_super: + getter_available = lambda f: f.available_functions_as_dict().items() + d = {f.canonical_name:f for f in contract.functions} + functions = {f.full_name:f for f in contract.available_elements_from_inheritances(d, getter_available).values()} + else: + functions = contract.available_functions_as_dict() if var_name in functions: return functions[var_name] - modifiers = contract.modifiers_as_dict() + if is_super: + getter_available = lambda m: m.available_modifiers_as_dict().items() + d = {m.canonical_name: m for m in contract.modifiers} + modifiers = {m.full_name: m for m in contract.available_elements_from_inheritances(d, getter_available).values()} + else: + modifiers = contract.available_modifiers_as_dict() if var_name in modifiers: return modifiers[var_name] @@ -516,6 +524,7 @@ def parse_expression(expression, caller_context): referenced_declaration = expression['referencedDeclaration'] else: referenced_declaration = None + var = find_variable(value, caller_context, referenced_declaration) identifier = Identifier(var) @@ -556,18 +565,7 @@ def parse_expression(expression, caller_context): member_expression = parse_expression(children[0], caller_context) if str(member_expression) == 'super': super_name = parse_super_name(expression, is_compact_ast) - if isinstance(caller_context, Contract): - inheritance = caller_context.inheritance - else: - assert isinstance(caller_context, Function) - inheritance = caller_context.contract.inheritance - var = None - for father in inheritance: - try: - var = find_variable(super_name, father) - break - except VariableNotFound: - continue + var = find_variable(super_name, caller_context, is_super=True) if var is None: raise VariableNotFound('Variable not found: {}'.format(super_name)) return SuperIdentifier(var) diff --git a/slither/solc_parsing/solidity_types/type_parsing.py b/slither/solc_parsing/solidity_types/type_parsing.py index 2b5057dda..3dd57c276 100644 --- a/slither/solc_parsing/solidity_types/type_parsing.py +++ b/slither/solc_parsing/solidity_types/type_parsing.py @@ -58,7 +58,7 @@ def _find_from_type_name(name, contract, contracts, structures, enums): all_enums = [item for sublist in all_enums for item in sublist] var_type = next((e for e in all_enums if e.name == enum_name), None) if not var_type: - var_type = next((e for e in all_enums if e.contract.name+"."+e.name == enum_name), None) + var_type = next((e for e in all_enums if e.canonical_name == enum_name), None) if not var_type: # any contract can refer to another contract's structure name_struct = name @@ -69,14 +69,14 @@ def _find_from_type_name(name, contract, contracts, structures, enums): all_structures = [item for sublist in all_structures for item in sublist] var_type = next((st for st in all_structures if st.name == name_struct), None) if not var_type: - var_type = next((st for st in all_structures if st.contract.name+"."+st.name == name_struct), None) + var_type = next((st for st in all_structures if st.canonical_name == name_struct), None) # case where struct xxx.xx[] where not well formed in the AST if not var_type: depth = 0 while name_struct.endswith('[]'): name_struct = name_struct[0:-2] depth+=1 - var_type = next((st for st in all_structures if st.contract.name+"."+st.name == name_struct), None) + var_type = next((st for st in all_structures if st.canonical_name == name_struct), None) if var_type: return ArrayType(UserDefinedType(var_type), Literal(depth)) diff --git a/slither/utils/inheritance_analysis.py b/slither/utils/inheritance_analysis.py index de05b246f..64e62dbc2 100644 --- a/slither/utils/inheritance_analysis.py +++ b/slither/utils/inheritance_analysis.py @@ -109,7 +109,7 @@ def detect_function_shadowing(contracts, direct_shadowing=True, indirect_shadowi for y in range(x + 1, len(colliding_functions)): # The same function definition can appear more than once in the inheritance chain, # overshadowing items between, so it is important to remember to filter it out here. - if colliding_functions[y][1].contract != colliding_functions[x][1].contract: + if colliding_functions[y][1].original_contract != colliding_functions[x][1].original_contract: results.add((contract, colliding_functions[y][0], colliding_functions[y][1], colliding_functions[x][0], colliding_functions[x][1])) diff --git a/utils/possible_paths/__main__.py b/utils/possible_paths/__main__.py index 321f1bcfd..44254a121 100644 --- a/utils/possible_paths/__main__.py +++ b/utils/possible_paths/__main__.py @@ -47,7 +47,7 @@ def main(): # Print out all target functions. print(f"Target functions:") for target in targets: - print(f"- {target.contract.name}.{target.full_name}") + print(f"- {target.original_contract.name}.{target.full_name}") print("\n") # Obtain all paths which reach the target functions. @@ -56,12 +56,12 @@ def main(): # Print out all function names which can reach the targets. print(f"The following functions reach the specified targets:") - for function_desc in sorted([f"{f.contract.name}.{f.full_name}" for f in reaching_functions]): + for function_desc in sorted([f"{f.canonical_name}" for f in reaching_functions]): print(f"- {function_desc}") print("\n") # Format all function paths. - reaching_paths_str = [' -> '.join([f"{f.contract.name}.{f.full_name}" for f in reaching_path]) for reaching_path in reaching_paths] + reaching_paths_str = [' -> '.join([f"{f.canonical_name}" for f in reaching_path]) for reaching_path in reaching_paths] # Print a sorted list of all function paths which can reach the targets. print(f"The following paths reach the specified targets:") diff --git a/utils/upgradeability/check_initialization.py b/utils/upgradeability/check_initialization.py index ac9d29d47..475f3683a 100644 --- a/utils/upgradeability/check_initialization.py +++ b/utils/upgradeability/check_initialization.py @@ -51,7 +51,7 @@ def check_initialization(s): for f in all_init_functions: if not initializer in f.modifiers: initializer_modifier_missing = True - logger.info(red(f'{f.contract.name}.{f.name} does not call initializer')) + logger.info(red(f'{f.canonical_name} does not call initializer')) most_derived_init = _get_most_derived_init(contract) if most_derived_init is None: init_info += f'{contract.name} has no initialize function\n' @@ -61,7 +61,7 @@ def check_initialization(s): all_init_functions_called = _get_all_internal_calls(most_derived_init) + [most_derived_init] missing_calls = [f for f in all_init_functions if not f in all_init_functions_called] for f in missing_calls: - logger.info(red(f'Missing call to {f.contract.name}.{f.name} in {contract.name}')) + logger.info(red(f'Missing call to {f.canonical_name} in {contract.name}')) missing_call = True double_calls = list(set([f for f in all_init_functions_called if all_init_functions_called.count(f) > 1])) for f in double_calls: From 654c2c98b7e69dcfd42ae0c143b886feee8f6951 Mon Sep 17 00:00:00 2001 From: Josselin Date: Fri, 26 Apr 2019 18:33:55 +0100 Subject: [PATCH 13/55] - add contract.get_function_from_canonical_name (same for modifier - slithir convert: fix incorrect internal call conversion (use canonical name) - slithir internalcall: use tuple(func_nale, contract_name) to init unknown internal call - Update upgradability-check with new API --- scripts/travis_test_upgradability.sh | 17 ++++++--- slither/core/declarations/contract.py | 25 ++++++++++++- slither/printers/summary/slithir.py | 2 +- slither/slithir/convert.py | 37 +++++++++++++++---- slither/slithir/operations/internal_call.py | 17 ++++----- slither/slithir/utils/ssa.py | 2 +- .../expressions/expression_parsing.py | 1 + .../visitors/slithir/expression_to_slithir.py | 2 +- tests/check-upgradeability/test_5.txt | 4 +- utils/upgradeability/check_initialization.py | 20 +++++----- 10 files changed, 88 insertions(+), 39 deletions(-) diff --git a/scripts/travis_test_upgradability.sh b/scripts/travis_test_upgradability.sh index adce735c2..d840a2fb3 100755 --- a/scripts/travis_test_upgradability.sh +++ b/scripts/travis_test_upgradability.sh @@ -8,8 +8,9 @@ slither-check-upgradeability "$DIR_TESTS/proxy.sol" Proxy "$DIR_TESTS/contractV1 DIFF=$(diff test_1.txt "$DIR_TESTS/test_1.txt") if [ "$DIFF" != "" ] then - echo "slither-check-upgradeability failed" + echo "slither-check-upgradeability 1 failed" cat test_1.txt + echo "" cat "$DIR_TESTS/test_1.txt" exit -1 fi @@ -18,8 +19,9 @@ slither-check-upgradeability "$DIR_TESTS/proxy.sol" Proxy "$DIR_TESTS/contractV1 DIFF=$(diff test_2.txt "$DIR_TESTS/test_2.txt") if [ "$DIFF" != "" ] then - echo "slither-check-upgradeability failed" + echo "slither-check-upgradeability 2 failed" cat test_2.txt + echo "" cat "$DIR_TESTS/test_2.txt" exit -1 fi @@ -28,8 +30,9 @@ slither-check-upgradeability "$DIR_TESTS/proxy.sol" Proxy "$DIR_TESTS/contractV1 DIFF=$(diff test_3.txt "$DIR_TESTS/test_3.txt") if [ "$DIFF" != "" ] then - echo "slither-check-upgradeability failed" + echo "slither-check-upgradeability 3 failed" cat test_3.txt + echo "" cat "$DIR_TESTS/test_3.txt" exit -1 fi @@ -38,8 +41,9 @@ slither-check-upgradeability "$DIR_TESTS/proxy.sol" Proxy "$DIR_TESTS/contractV1 DIFF=$(diff test_4.txt "$DIR_TESTS/test_4.txt") if [ "$DIFF" != "" ] then - echo "slither-check-upgradeability failed" + echo "slither-check-upgradeability 4 failed" cat test_4.txt + echo "" cat "$DIR_TESTS/test_4.txt" exit -1 fi @@ -48,9 +52,12 @@ slither-check-upgradeability "$DIR_TESTS/proxy.sol" Proxy "$DIR_TESTS/contract_i DIFF=$(diff test_5.txt "$DIR_TESTS/test_5.txt") if [ "$DIFF" != "" ] then - echo "slither-check-upgradeability failed" + echo "slither-check-upgradeability 5 failed" cat test_5.txt + echo "" cat "$DIR_TESTS/test_5.txt" + echo "" + echo "$DIFF" exit -1 fi diff --git a/slither/core/declarations/contract.py b/slither/core/declarations/contract.py index 5f1c0a2e9..9ef2e88bf 100644 --- a/slither/core/declarations/contract.py +++ b/slither/core/declarations/contract.py @@ -402,7 +402,7 @@ class Contract(ChildSlither, SourceMapping): Returns: Function """ - return next((f for f in self.functions if f.full_name == function_signature), None) + return next((f for f in self.functions if f.full_name == function_signature and not f.is_shadowed), None) def get_modifier_from_signature(self, modifier_signature): """ @@ -412,7 +412,28 @@ class Contract(ChildSlither, SourceMapping): Returns: Modifier """ - return next((m for m in self.modifiers if m.full_name == modifier_signature), None) + return next((m for m in self.modifiers if m.full_name == modifier_signature and not m.is_shadowed), None) + + def get_function_from_canonical_name(self, canonical_name): + """ + Return a function from a a canonical name (contract.signature()) + Args: + canonical_name (str): canonical name of the function (without return statement) + Returns: + Function + """ + return next((f for f in self.functions if f.canonical_name == canonical_name), None) + + def get_modifier_from_canonical_name(self, canonical_name): + """ + Return a modifier from a canonical name (contract.signature()) + Args: + canonical_name (str): canonical name of the modifier + Returns: + Modifier + """ + return next((m for m in self.modifiers if m.canonical_name == canonical_name), None) + def get_state_variable_from_name(self, variable_name): """ diff --git a/slither/printers/summary/slithir.py b/slither/printers/summary/slithir.py index e34c9d34d..cd4a7299f 100644 --- a/slither/printers/summary/slithir.py +++ b/slither/printers/summary/slithir.py @@ -23,7 +23,7 @@ class PrinterSlithIR(AbstractPrinter): for contract in self.contracts: print('Contract {}'.format(contract.name)) for function in contract.functions: - print('\tFunction {}'.format(function.canonical_name)) + print(f'\tFunction {function.canonical_name}') for node in function.nodes: if node.expression: print('\t\tExpression: {}'.format(node.expression)) diff --git a/slither/slithir/convert.py b/slither/slithir/convert.py index 7b9607df0..51993b2c6 100644 --- a/slither/slithir/convert.py +++ b/slither/slithir/convert.py @@ -98,6 +98,21 @@ def get_sig(ir, name): argss = convert_arguments(ir.arguments) return [sig.format(name, ','.join(args)) for args in argss] +def get_canonical_names(ir, function_name, contract_name): + ''' + Return a list of potential signature + It is a list, as Constant variables can be converted to int256 + Args: + ir (slithIR.operation) + Returns: + list(str) + ''' + sig = '{}({})' + + # list of list of arguments + argss = convert_arguments(ir.arguments) + return [sig.format(f'{contract_name}.{function_name}', ','.join(args)) for args in argss] + def convert_arguments(arguments): argss = [[]] for arg in arguments: @@ -355,7 +370,7 @@ def propagate_types(ir, node): elif isinstance(ir, InternalCall): # if its not a tuple, return a singleton if ir.function is None: - convert_type_of_high_and_internal_level_call(ir, ir.contract) + convert_type_of_high_and_internal_level_call(ir, node.function.contract) return_type = ir.function.return_type if return_type: if len(return_type) == 1: @@ -467,7 +482,7 @@ def extract_tmp_call(ins, contract): # If there is a call on an inherited contract, it is an internal call or an event if ins.ori.variable_left in contract.inheritance + [contract]: if str(ins.ori.variable_right) in [f.name for f in contract.functions]: - internalcall = InternalCall(ins.ori.variable_right, ins.ori.variable_left, ins.nbr_arguments, ins.lvalue, ins.type_call) + internalcall = InternalCall((ins.ori.variable_right, ins.ori.variable_left.name), ins.nbr_arguments, ins.lvalue, ins.type_call) internalcall.call_id = ins.call_id return internalcall if str(ins.ori.variable_right) in [f.name for f in contract.events]: @@ -704,11 +719,19 @@ def convert_type_library_call(ir, lib_contract): def convert_type_of_high_and_internal_level_call(ir, contract): func = None - sigs = get_sig(ir, ir.function_name) - for sig in sigs: - func = contract.get_function_from_signature(sig) - if not func: - func = contract.get_state_variable_from_name(ir.function_name) + if isinstance(ir, InternalCall): + sigs = get_canonical_names(ir, ir.function_name, ir.contract_name) + for sig in sigs: + func = contract.get_function_from_canonical_name(sig) + if not func: + func = contract.get_state_variable_from_name(ir.function_name) + else: + assert isinstance(ir, HighLevelCall) + sigs = get_sig(ir, ir.function_name) + for sig in sigs: + func = contract.get_function_from_canonical_name(sig) + if not func: + func = contract.get_state_variable_from_name(ir.function_name) if not func: # specific lookup when the compiler does implicit conversion # for example diff --git a/slither/slithir/operations/internal_call.py b/slither/slithir/operations/internal_call.py index c0e5b54f5..75c5d6a9d 100644 --- a/slither/slithir/operations/internal_call.py +++ b/slither/slithir/operations/internal_call.py @@ -1,21 +1,20 @@ from slither.core.declarations.function import Function from slither.slithir.operations.call import Call from slither.slithir.operations.lvalue import OperationWithLValue -from slither.core.variables.variable import Variable from slither.slithir.variables import Constant class InternalCall(Call, OperationWithLValue): - def __init__(self, function, contract, nbr_arguments, result, type_call): + def __init__(self, function, nbr_arguments, result, type_call): super(InternalCall, self).__init__() if isinstance(function, Function): self._function = function self._function_name = function.name + self._contract_name = function.original_contract.name else: - isinstance(function, Constant) self._function = None - self._function_name = function - self._contract = contract + self._function_name, self._contract_name = function + #self._contract = contract self._nbr_arguments = nbr_arguments self._type_call = type_call self._lvalue = result @@ -32,14 +31,14 @@ class InternalCall(Call, OperationWithLValue): def function(self, f): self._function = f - @property - def contract(self): - return self._contract - @property def function_name(self): return self._function_name + @property + def contract_name(self): + return self._contract_name + @property def nbr_arguments(self): return self._nbr_arguments diff --git a/slither/slithir/utils/ssa.py b/slither/slithir/utils/ssa.py index 74238589d..3ef917dbd 100644 --- a/slither/slithir/utils/ssa.py +++ b/slither/slithir/utils/ssa.py @@ -565,7 +565,7 @@ def copy_ir(ir, *instances): nbr_arguments = ir.nbr_arguments lvalue = get_variable(ir, lambda x: x.lvalue, *instances) type_call = ir.type_call - new_ir = InternalCall(function, function.contract, nbr_arguments, lvalue, type_call) + new_ir = InternalCall(function, nbr_arguments, lvalue, type_call) new_ir.arguments = get_arguments(ir, *instances) return new_ir elif isinstance(ir, InternalDynamicCall): diff --git a/slither/solc_parsing/expressions/expression_parsing.py b/slither/solc_parsing/expressions/expression_parsing.py index fd1e6139d..760d6b9a5 100644 --- a/slither/solc_parsing/expressions/expression_parsing.py +++ b/slither/solc_parsing/expressions/expression_parsing.py @@ -70,6 +70,7 @@ def get_pointer_name(variable): def find_variable(var_name, caller_context, referenced_declaration=None, is_super=False): + if isinstance(caller_context, Contract): function = None contract = caller_context diff --git a/slither/visitors/slithir/expression_to_slithir.py b/slither/visitors/slithir/expression_to_slithir.py index a1c1c5e5d..044f862bf 100644 --- a/slither/visitors/slithir/expression_to_slithir.py +++ b/slither/visitors/slithir/expression_to_slithir.py @@ -131,7 +131,7 @@ class ExpressionToSlithIR(ExpressionVisitor): val = TupleVariable(self._node) else: val = TemporaryVariable(self._node) - internal_call = InternalCall(called, called.contract, len(args), val, expression.type_call) + internal_call = InternalCall(called, len(args), val, expression.type_call) self._result.append(internal_call) set_val(expression, val) else: diff --git a/tests/check-upgradeability/test_5.txt b/tests/check-upgradeability/test_5.txt index 8ddb49d85..fc7bf6e2c 100644 --- a/tests/check-upgradeability/test_5.txt +++ b/tests/check-upgradeability/test_5.txt @@ -1,6 +1,6 @@ INFO:CheckInitialization:Run initialization checks... (see https://github.com/crytic/slither/wiki/Upgradeability-Checks#initialization-checks) -INFO:CheckInitialization:Contract_lack_to_call_modifier.initialize does not call initializer -INFO:CheckInitialization:Missing call to Contract_no_bug.initialize in Contract_not_called_super_init +INFO:CheckInitialization:Contract_lack_to_call_modifier.initialize() does not call initializer +INFO:CheckInitialization:Missing call to Contract_no_bug.initialize() in Contract_not_called_super_init INFO:CheckInitialization:Contract_no_bug.initialize() is called multiple time in Contract_double_call INFO:CheckInitialization:Check the deployement script to ensure that these functions are called: Contract_no_bug needs to be initialized by initialize() diff --git a/utils/upgradeability/check_initialization.py b/utils/upgradeability/check_initialization.py index 475f3683a..22885ed31 100644 --- a/utils/upgradeability/check_initialization.py +++ b/utils/upgradeability/check_initialization.py @@ -11,7 +11,7 @@ class MultipleInitTarget(Exception): pass def _get_initialize_functions(contract): - return [f for father in contract.inheritance + [contract] for f in father.functions_not_inherited if f.name == 'initialize'] + return [f for f in contract.functions if f.name == 'initialize'] def _get_all_internal_calls(function): all_ir = function.all_slithir_operations() @@ -19,12 +19,11 @@ def _get_all_internal_calls(function): def _get_most_derived_init(contract): - for c in [contract] + contract.inheritance: - init_functions = [f for f in c.functions_not_inherited if f.name == 'initialize'] - if len(init_functions) > 1: - raise MultipleInitTarget - if init_functions: - return init_functions[0] + init_functions = [f for f in contract.functions if not f.is_shadowed and f.name == 'initialize'] + if len(init_functions) > 1: + raise MultipleInitTarget + if init_functions: + return init_functions[0] return None def check_initialization(s): @@ -37,8 +36,6 @@ def check_initialization(s): logger.info(yellow('Initializable contract not found, the contract does not follow a standard initalization schema.')) return - initializer = initializable.get_modifier_from_signature('initializer()') - init_info = '' double_calls_found = False @@ -47,6 +44,7 @@ def check_initialization(s): for contract in s.contracts: if initializable in contract.inheritance: + initializer = contract.get_modifier_from_canonical_name('Initializable.initializer()') all_init_functions = _get_initialize_functions(contract) for f in all_init_functions: if not initializer in f.modifiers: @@ -58,14 +56,14 @@ def check_initialization(s): continue else: init_info += f'{contract.name} needs to be initialized by {most_derived_init.full_name}\n' - all_init_functions_called = _get_all_internal_calls(most_derived_init) + [most_derived_init] + all_init_functions_called = _get_all_internal_calls(most_derived_init) + [most_derived_init] missing_calls = [f for f in all_init_functions if not f in all_init_functions_called] for f in missing_calls: logger.info(red(f'Missing call to {f.canonical_name} in {contract.name}')) missing_call = True double_calls = list(set([f for f in all_init_functions_called if all_init_functions_called.count(f) > 1])) for f in double_calls: - logger.info(red(f'{f.contract.name + "." + f.full_name} is called multiple time in {contract.name}')) + logger.info(red(f'{f.canonical_name} is called multiple time in {contract.name}')) double_calls_found = True if not initializer_modifier_missing: From 92ced37b30b8e7182cd35851fad7f45b08d9c377 Mon Sep 17 00:00:00 2001 From: Josselin Date: Fri, 26 Apr 2019 19:30:18 +0100 Subject: [PATCH 14/55] Fix contract.all_functions_called --- slither/core/declarations/contract.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/slither/core/declarations/contract.py b/slither/core/declarations/contract.py index 9ef2e88bf..8a022ef86 100644 --- a/slither/core/declarations/contract.py +++ b/slither/core/declarations/contract.py @@ -520,8 +520,9 @@ class Contract(ChildSlither, SourceMapping): ''' list(Function): List of functions reachable from the contract (include super) ''' - all_calls = [f.all_internal_calls() for f in self.functions + self.modifiers] + [self.functions + self.modifiers] - all_calls = [item for sublist in all_calls for item in sublist] + self.functions + all_calls = [f for f in self.functions + self.modifiers if not f.is_shadowed] + all_calls = [f.all_internal_calls() for f in all_calls] + [all_calls] + all_calls = [item for sublist in all_calls for item in sublist] all_calls = list(set(all_calls)) all_constructors = [c.constructor for c in self.inheritance] From d37bcb6104630a4202e631a2f06659e0a076d89a Mon Sep 17 00:00:00 2001 From: Josselin Date: Mon, 29 Apr 2019 11:10:00 +0100 Subject: [PATCH 15/55] Rename original_contract -> contract_declarer --- examples/scripts/slithIR.py | 2 +- slither/core/children/child_contract.py | 1 - slither/core/children/child_inheritance.py | 10 +++++----- slither/core/declarations/contract.py | 13 +++++++------ slither/core/declarations/function.py | 6 +++--- slither/detectors/abstract_detector.py | 2 +- slither/detectors/attributes/const_functions.py | 2 +- slither/detectors/erc20/incorrect_interface.py | 2 +- slither/detectors/functions/arbitrary_send.py | 2 +- slither/detectors/functions/suicidal.py | 2 +- .../naming_convention/naming_convention.py | 4 ++-- slither/detectors/operations/block_timestamp.py | 2 +- slither/detectors/operations/low_level_calls.py | 2 +- .../detectors/operations/unused_return_values.py | 2 +- slither/detectors/shadowing/builtin_symbols.py | 4 ++-- slither/detectors/shadowing/local.py | 6 +++--- slither/detectors/statements/assembly.py | 2 +- slither/detectors/statements/calls_in_loop.py | 2 +- .../detectors/statements/controlled_delegatecall.py | 2 +- .../variables/uninitialized_local_variables.py | 2 +- slither/printers/inheritance/inheritance_graph.py | 6 +++--- slither/slithir/operations/internal_call.py | 2 +- slither/solc_parsing/declarations/contract.py | 4 ++-- slither/solc_parsing/declarations/function.py | 4 ++-- slither/utils/inheritance_analysis.py | 2 +- utils/possible_paths/__main__.py | 2 +- 26 files changed, 45 insertions(+), 45 deletions(-) diff --git a/examples/scripts/slithIR.py b/examples/scripts/slithIR.py index b58e06f10..2b65e3122 100644 --- a/examples/scripts/slithIR.py +++ b/examples/scripts/slithIR.py @@ -15,7 +15,7 @@ for contract in slither.contracts: for function in contract.functions: # Dont explore inherited functions - if function.original_contract == contract: + if function.contract_declarer == contract: print('Function: {}'.format(function.name)) diff --git a/slither/core/children/child_contract.py b/slither/core/children/child_contract.py index 6e476d59f..9ca39af8e 100644 --- a/slither/core/children/child_contract.py +++ b/slither/core/children/child_contract.py @@ -4,7 +4,6 @@ class ChildContract: def __init__(self): super(ChildContract, self).__init__() self._contract = None - self._original_contract = None def set_contract(self, contract): self._contract = contract diff --git a/slither/core/children/child_inheritance.py b/slither/core/children/child_inheritance.py index 668c37a5f..cc9c4065f 100644 --- a/slither/core/children/child_inheritance.py +++ b/slither/core/children/child_inheritance.py @@ -3,11 +3,11 @@ class ChildInheritance: def __init__(self): super(ChildInheritance, self).__init__() - self._original_contract = None + self._contract_declarer = None - def set_original_contract(self, original_contract): - self._original_contract = original_contract + def set_contract_declarer(self, contract): + self._contract_declarer = contract @property - def original_contract(self): - return self._original_contract + def contract_declarer(self): + return self._contract_declarer diff --git a/slither/core/declarations/contract.py b/slither/core/declarations/contract.py index 8a022ef86..a116f22c1 100644 --- a/slither/core/declarations/contract.py +++ b/slither/core/declarations/contract.py @@ -184,7 +184,7 @@ class Contract(ChildSlither, SourceMapping): @property def constructor_not_inherited(self): - return next((func for func in self.functions if func.is_constructor and func.original_contract == self), None) + return next((func for func in self.functions if func.is_constructor and func.contract_declarer == self), None) @property def constructors(self): @@ -228,14 +228,14 @@ class Contract(ChildSlither, SourceMapping): ''' list(Function): List of the inherited functions ''' - return [f for f in self.functions if f.original_contract != self] + return [f for f in self.functions if f.contract_declarer != self] @property def functions_not_inherited(self): ''' list(Function): List of the functions defined within the contract (not inherited) ''' - return [f for f in self.functions if f.original_contract == self] + return [f for f in self.functions if f.contract_declarer == self] @property def functions_entry_points(self): @@ -259,14 +259,14 @@ class Contract(ChildSlither, SourceMapping): ''' list(Modifier): List of the inherited modifiers ''' - return [m for m in self.modifiers if m.original_contract != self] + return [m for m in self.modifiers if m.contract_declarer != self] @property def modifiers_not_inherited(self): ''' list(Modifier): List of the modifiers defined within the contract (not inherited) ''' - return [m for m in self.modifiers if m.original_contract == self] + return [m for m in self.modifiers if m.contract_declarer == self] @property def functions_and_modifiers(self): @@ -518,7 +518,8 @@ class Contract(ChildSlither, SourceMapping): @property def all_functions_called(self): ''' - list(Function): List of functions reachable from the contract (include super) + list(Function): List of functions reachable from the contract + Includes super, and private/internal functions not shadowed ''' all_calls = [f for f in self.functions + self.modifiers if not f.is_shadowed] all_calls = [f.all_internal_calls() for f in all_calls] + [all_calls] diff --git a/slither/core/declarations/function.py b/slither/core/declarations/function.py index 27ffa6996..fa0542ea3 100644 --- a/slither/core/declarations/function.py +++ b/slither/core/declarations/function.py @@ -123,14 +123,14 @@ class Function(ChildContract, ChildInheritance, SourceMapping): Return the function signature without the return values """ name, parameters, _ = self.signature - return self.original_contract.name + '.' + name + '(' + ','.join(parameters) + ')' + return self.contract_declarer.name + '.' + name + '(' + ','.join(parameters) + ')' @property def is_constructor(self): """ bool: True if the function is the constructor """ - return self._is_constructor or self._name == self.original_contract.name + return self._is_constructor or self._name == self.contract_declarer.name @property def contains_assembly(self): @@ -950,7 +950,7 @@ class Function(ChildContract, ChildInheritance, SourceMapping): (str, str, str, list(str), list(str), listr(str), list(str), list(str); contract_name, name, visibility, modifiers, vars read, vars written, internal_calls, external_calls_as_expressions """ - return (self.original_contract.name, self.full_name, self.visibility, + return (self.contract_declarer.name, self.full_name, self.visibility, [str(x) for x in self.modifiers], [str(x) for x in self.state_variables_read + self.solidity_variables_read], [str(x) for x in self.state_variables_written], diff --git a/slither/detectors/abstract_detector.py b/slither/detectors/abstract_detector.py index 37324f80a..9b7fa20c0 100644 --- a/slither/detectors/abstract_detector.py +++ b/slither/detectors/abstract_detector.py @@ -169,7 +169,7 @@ class AbstractDetector(metaclass=abc.ABCMeta): @staticmethod def add_function_to_json(function, d): contract = {'elements':[]} - AbstractDetector.add_contract_to_json(function.original_contract, contract) + AbstractDetector.add_contract_to_json(function.contract_declarer, contract) d['elements'].append({'type': 'function', 'name': function.name, 'source_mapping': function.source_mapping, diff --git a/slither/detectors/attributes/const_functions.py b/slither/detectors/attributes/const_functions.py index f38693f77..1b3b95319 100644 --- a/slither/detectors/attributes/const_functions.py +++ b/slither/detectors/attributes/const_functions.py @@ -51,7 +51,7 @@ All the calls to `get` revert, breaking Bob's smart contract execution.''' results = [] for c in self.contracts: for f in c.functions: - if f.original_contract != c: + if f.contract_declarer != c: continue if f.view or f.pure: if f.contains_assembly: diff --git a/slither/detectors/erc20/incorrect_interface.py b/slither/detectors/erc20/incorrect_interface.py index dbd0feb92..0c7bb6bd5 100644 --- a/slither/detectors/erc20/incorrect_interface.py +++ b/slither/detectors/erc20/incorrect_interface.py @@ -52,7 +52,7 @@ contract Token{ Returns: list(str) : list of incorrect function signatures """ - functions = [f for f in contract.functions if f.original_contract == contract and \ + functions = [f for f in contract.functions if f.contract_declarer == contract and \ IncorrectERC20InterfaceDetection.incorrect_erc20_interface(f.signature)] return functions diff --git a/slither/detectors/functions/arbitrary_send.py b/slither/detectors/functions/arbitrary_send.py index e5900a3c5..d28cd1258 100644 --- a/slither/detectors/functions/arbitrary_send.py +++ b/slither/detectors/functions/arbitrary_send.py @@ -94,7 +94,7 @@ Bob calls `setDestination` and `withdraw`. As a result he withdraws the contract list((Function), (list (Node))) """ ret = [] - for f in [f for f in contract.functions if f.original_contract == contract]: + for f in [f for f in contract.functions if f.contract_declarer == contract]: nodes = self.arbitrary_send(f) if nodes: ret.append((f, nodes)) diff --git a/slither/detectors/functions/suicidal.py b/slither/detectors/functions/suicidal.py index f20c4da13..fef1c1224 100644 --- a/slither/detectors/functions/suicidal.py +++ b/slither/detectors/functions/suicidal.py @@ -59,7 +59,7 @@ Bob calls `kill` and destructs the contract.''' def detect_suicidal(self, contract): ret = [] - for f in [f for f in contract.functions if f.original_contract == contract]: + for f in [f for f in contract.functions if f.contract_declarer == contract]: if self.detect_suicidal_func(f): ret.append(f) return ret diff --git a/slither/detectors/naming_convention/naming_convention.py b/slither/detectors/naming_convention/naming_convention.py index 4ec7fc6d1..b74696f34 100644 --- a/slither/detectors/naming_convention/naming_convention.py +++ b/slither/detectors/naming_convention/naming_convention.py @@ -103,7 +103,7 @@ Solidity defines a [naming convention](https://solidity.readthedocs.io/en/v0.4.2 results.append(json) for func in contract.functions: - if func.original_contract != contract: + if func.contract_declarer != contract: continue if not self.is_mixed_case(func.name): @@ -212,7 +212,7 @@ Solidity defines a [naming convention](https://solidity.readthedocs.io/en/v0.4.2 for modifier in contract.modifiers: - if modifier.original_contract != contract: + if modifier.contract_declarer != contract: continue if not self.is_mixed_case(modifier.name): diff --git a/slither/detectors/operations/block_timestamp.py b/slither/detectors/operations/block_timestamp.py index ecadb2e94..81c115341 100644 --- a/slither/detectors/operations/block_timestamp.py +++ b/slither/detectors/operations/block_timestamp.py @@ -54,7 +54,7 @@ class Timestamp(AbstractDetector): list((Function), (list (Node))) """ ret = [] - for f in [f for f in contract.functions if f.original_contract == contract]: + for f in [f for f in contract.functions if f.contract_declarer == contract]: nodes = self.timestamp(f) if nodes: ret.append((f, nodes)) diff --git a/slither/detectors/operations/low_level_calls.py b/slither/detectors/operations/low_level_calls.py index 9a819518d..4e36448a4 100644 --- a/slither/detectors/operations/low_level_calls.py +++ b/slither/detectors/operations/low_level_calls.py @@ -33,7 +33,7 @@ class LowLevelCalls(AbstractDetector): def detect_low_level_calls(self, contract): ret = [] - for f in [f for f in contract.functions if contract == f.original_contract]: + for f in [f for f in contract.functions if contract == f.contract_declarer]: nodes = f.nodes assembly_nodes = [n for n in nodes if self._contains_low_level_calls(n)] diff --git a/slither/detectors/operations/unused_return_values.py b/slither/detectors/operations/unused_return_values.py index ee153f03a..1bf9ef3d2 100644 --- a/slither/detectors/operations/unused_return_values.py +++ b/slither/detectors/operations/unused_return_values.py @@ -64,7 +64,7 @@ contract MyConc{ results = [] for c in self.slither.contracts: for f in c.functions + c.modifiers: - if f.original_contract != c: + if f.contract_declarer != c: continue unused_return = self.detect_unused_return_values(f) if unused_return: diff --git a/slither/detectors/shadowing/builtin_symbols.py b/slither/detectors/shadowing/builtin_symbols.py index cc8a1f19e..d04f24d54 100644 --- a/slither/detectors/shadowing/builtin_symbols.py +++ b/slither/detectors/shadowing/builtin_symbols.py @@ -91,12 +91,12 @@ contract Bug { # Loop through all functions, modifiers, variables (state and local) to detect any built-in symbol keywords. for function in contract.functions: - if function.original_contract == contract: + if function.contract_declarer == contract: if self.is_builtin_symbol(function.name): result.append((self.SHADOWING_FUNCTION, function, None)) result += self.detect_builtin_shadowing_locals(function) for modifier in contract.modifiers: - if modifier.original_contract == contract: + if modifier.contract_declarer == contract: if self.is_builtin_symbol(modifier.name): result.append((self.SHADOWING_MODIFIER, modifier, None)) result += self.detect_builtin_shadowing_locals(modifier) diff --git a/slither/detectors/shadowing/local.py b/slither/detectors/shadowing/local.py index 20d5cebc7..aadc637b9 100644 --- a/slither/detectors/shadowing/local.py +++ b/slither/detectors/shadowing/local.py @@ -59,7 +59,7 @@ contract Bug { # Loop through all functions + modifiers in this contract. for function in contract.functions + contract.modifiers: # We should only look for functions declared directly in this contract (not in a base contract). - if function.original_contract != contract: + if function.contract_declarer != contract: continue # This function was declared in this contract, we check what its local variables might shadow. @@ -68,11 +68,11 @@ contract Bug { for scope_contract in [contract] + contract.inheritance: # Check functions for scope_function in scope_contract.functions: - if variable.name == scope_function.name and scope_function.original_contract == scope_contract: + if variable.name == scope_function.name and scope_function.contract_declarer == scope_contract: overshadowed.append((self.OVERSHADOWED_FUNCTION, scope_contract.name, scope_function)) # Check modifiers for scope_modifier in scope_contract.modifiers: - if variable.name == scope_modifier.name and scope_modifier.original_contract == scope_contract: + if variable.name == scope_modifier.name and scope_modifier.contract_declarer == scope_contract: overshadowed.append((self.OVERSHADOWED_MODIFIER, scope_contract.name, scope_modifier)) # Check events for scope_event in scope_contract.events: diff --git a/slither/detectors/statements/assembly.py b/slither/detectors/statements/assembly.py index d95a81731..936794366 100644 --- a/slither/detectors/statements/assembly.py +++ b/slither/detectors/statements/assembly.py @@ -35,7 +35,7 @@ class Assembly(AbstractDetector): def detect_assembly(self, contract): ret = [] for f in contract.functions: - if f.original_contract != contract: + if f.contract_declarer != contract: continue nodes = f.nodes assembly_nodes = [n for n in nodes if diff --git a/slither/detectors/statements/calls_in_loop.py b/slither/detectors/statements/calls_in_loop.py index b3fa39f26..223ddbb42 100644 --- a/slither/detectors/statements/calls_in_loop.py +++ b/slither/detectors/statements/calls_in_loop.py @@ -72,7 +72,7 @@ If one of the destinations has a fallback function which reverts, `bad` will alw def detect_call_in_loop(contract): ret = [] for f in contract.functions + contract.modifiers: - if f.original_contract == contract and f.is_implemented: + if f.contract_declarer == contract and f.is_implemented: MultipleCallsInLoop.call_in_loop(f.entry_point, False, [], ret) diff --git a/slither/detectors/statements/controlled_delegatecall.py b/slither/detectors/statements/controlled_delegatecall.py index 0f721426e..81a25f71d 100644 --- a/slither/detectors/statements/controlled_delegatecall.py +++ b/slither/detectors/statements/controlled_delegatecall.py @@ -42,7 +42,7 @@ Bob calls `delegate` and delegates the execution to its malicious contract. As a for contract in self.slither.contracts: for f in contract.functions: - if f.original_contract != contract: + if f.contract_declarer != contract: continue nodes = self.controlled_delegatecall(f) if nodes: diff --git a/slither/detectors/variables/uninitialized_local_variables.py b/slither/detectors/variables/uninitialized_local_variables.py index 289f844d5..39219ae4a 100644 --- a/slither/detectors/variables/uninitialized_local_variables.py +++ b/slither/detectors/variables/uninitialized_local_variables.py @@ -90,7 +90,7 @@ Bob calls `transfer`. As a result, the ethers are sent to the address 0x0 and ar for contract in self.slither.contracts: for function in contract.functions: - if function.is_implemented and function.original_contract == contract: + if function.is_implemented and function.contract_declarer == contract: if function.contains_assembly: continue # dont consider storage variable, as they are detected by another detector diff --git a/slither/printers/inheritance/inheritance_graph.py b/slither/printers/inheritance/inheritance_graph.py index fb6e7d834..75c60b5e1 100644 --- a/slither/printers/inheritance/inheritance_graph.py +++ b/slither/printers/inheritance/inheritance_graph.py @@ -116,14 +116,14 @@ class PrinterInheritanceGraph(AbstractPrinter): # Functions visibilities = ['public', 'external'] public_functions = [self._get_pattern_func(f, contract) for f in contract.functions if - not f.is_constructor and f.original_contract == contract and f.visibility in visibilities] + not f.is_constructor and f.contract_declarer == contract and f.visibility in visibilities] public_functions = ''.join(public_functions) private_functions = [self._get_pattern_func(f, contract) for f in contract.functions if - not f.is_constructor and f.original_contract == contract and f.visibility not in visibilities] + not f.is_constructor and f.contract_declarer == contract and f.visibility not in visibilities] private_functions = ''.join(private_functions) # Modifiers - modifiers = [self._get_pattern_func(m, contract) for m in contract.modifiers if m.original_contract == contract] + modifiers = [self._get_pattern_func(m, contract) for m in contract.modifiers if m.contract_declarer == contract] modifiers = ''.join(modifiers) # Public variables diff --git a/slither/slithir/operations/internal_call.py b/slither/slithir/operations/internal_call.py index 75c5d6a9d..8056695f3 100644 --- a/slither/slithir/operations/internal_call.py +++ b/slither/slithir/operations/internal_call.py @@ -10,7 +10,7 @@ class InternalCall(Call, OperationWithLValue): if isinstance(function, Function): self._function = function self._function_name = function.name - self._contract_name = function.original_contract.name + self._contract_name = function.contract_declarer.name else: self._function = None self._function_name, self._contract_name = function diff --git a/slither/solc_parsing/declarations/contract.py b/slither/solc_parsing/declarations/contract.py index 500b67a9c..27de7b4b1 100644 --- a/slither/solc_parsing/declarations/contract.py +++ b/slither/solc_parsing/declarations/contract.py @@ -234,7 +234,7 @@ class ContractSolc04(Contract): modif = ModifierSolc(modifier, self, self) modif.set_contract(self) - modif.set_original_contract(self) + modif.set_contract_declarer(self) modif.set_offset(modifier['src'], self.slither) self.slither.add_modifier(modif) self._modifiers_no_params.append(modif) @@ -321,7 +321,7 @@ class ContractSolc04(Contract): for father in self.inheritance: for element in getter(father): - elem = Cls(element._functionNotParsed, self, element.original_contract) + elem = Cls(element._functionNotParsed, self, element.contract_declarer) elem.set_offset(element._functionNotParsed['src'], self.slither) elem.analyze_params() self.slither.add_function(elem) diff --git a/slither/solc_parsing/declarations/function.py b/slither/solc_parsing/declarations/function.py index 75580ecac..290f3d929 100644 --- a/slither/solc_parsing/declarations/function.py +++ b/slither/solc_parsing/declarations/function.py @@ -34,10 +34,10 @@ class FunctionSolc(Function): """ # elems = [(type, name)] - def __init__(self, function, contract, original_contract): + def __init__(self, function, contract, contract_declarer): super(FunctionSolc, self).__init__() self._contract = contract - self._original_contract = original_contract + self._contract_declarer = contract_declarer # Only present if compact AST self._referenced_declaration = None diff --git a/slither/utils/inheritance_analysis.py b/slither/utils/inheritance_analysis.py index 64e62dbc2..0c0f7c6da 100644 --- a/slither/utils/inheritance_analysis.py +++ b/slither/utils/inheritance_analysis.py @@ -109,7 +109,7 @@ def detect_function_shadowing(contracts, direct_shadowing=True, indirect_shadowi for y in range(x + 1, len(colliding_functions)): # The same function definition can appear more than once in the inheritance chain, # overshadowing items between, so it is important to remember to filter it out here. - if colliding_functions[y][1].original_contract != colliding_functions[x][1].original_contract: + if colliding_functions[y][1].contract_declarer != colliding_functions[x][1].contract_declarer: results.add((contract, colliding_functions[y][0], colliding_functions[y][1], colliding_functions[x][0], colliding_functions[x][1])) diff --git a/utils/possible_paths/__main__.py b/utils/possible_paths/__main__.py index 44254a121..8e05a29b7 100644 --- a/utils/possible_paths/__main__.py +++ b/utils/possible_paths/__main__.py @@ -47,7 +47,7 @@ def main(): # Print out all target functions. print(f"Target functions:") for target in targets: - print(f"- {target.original_contract.name}.{target.full_name}") + print(f"- {target.contract_declarer.name}.{target.full_name}") print("\n") # Obtain all paths which reach the target functions. From 5d5466e59ffba4c697b6942bab8c921f42d6b492 Mon Sep 17 00:00:00 2001 From: Josselin Date: Mon, 29 Apr 2019 13:30:59 +0100 Subject: [PATCH 16/55] Fix incorrect variable lookup --- slither/core/variables/state_variable.py | 4 +++- .../expressions/expression_parsing.py | 22 +++++++++++++++++-- 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/slither/core/variables/state_variable.py b/slither/core/variables/state_variable.py index adca10c19..86c21e30e 100644 --- a/slither/core/variables/state_variable.py +++ b/slither/core/variables/state_variable.py @@ -6,4 +6,6 @@ class StateVariable(ChildContract, Variable): @property def canonical_name(self): - return '{}:{}'.format(self.contract.name, self.name) + return '{}.{}'.format(self.contract.name, self.name) + + diff --git a/slither/solc_parsing/expressions/expression_parsing.py b/slither/solc_parsing/expressions/expression_parsing.py index 760d6b9a5..f7614b3ce 100644 --- a/slither/solc_parsing/expressions/expression_parsing.py +++ b/slither/solc_parsing/expressions/expression_parsing.py @@ -70,13 +70,29 @@ def get_pointer_name(variable): def find_variable(var_name, caller_context, referenced_declaration=None, is_super=False): + # variable are looked from the contract declarer + # functions can be shadowed, but are looked from the contract instance, rather than the contract declarer + # the difference between function and variable come from the fact that an internal call, or an variable access + # in a function does not behave similariy, for example in: + # contract C{ + # function f(){ + # state_var = 1 + # f2() + # } + # state_var will refer to C.state_var, no mater if C is inherited + # while f2() will refer to the function definition of the inherited contract (C.f2() in the context of C, or + # the contract inheriting from C) + # for events it's unclear what should be the behavior, as they can be shadowed, but there is not impact + # structure/enums cannot be shadowed if isinstance(caller_context, Contract): function = None contract = caller_context + contract_declarer = caller_context elif isinstance(caller_context, Function): function = caller_context contract = function.contract + contract_declarer = function.contract_declarer else: logger.error('Incorrect caller context') exit(-1) @@ -99,12 +115,13 @@ def find_variable(var_name, caller_context, referenced_declaration=None, is_supe if var_name and var_name in func_variables_ptr: return func_variables_ptr[var_name] - contract_variables = contract.variables_as_dict() + # variable are looked from the contract declarer + contract_variables = contract_declarer.variables_as_dict() if var_name in contract_variables: return contract_variables[var_name] # A state variable can be a pointer - conc_variables_ptr = {get_pointer_name(f) : f for f in contract.variables} + conc_variables_ptr = {get_pointer_name(f) : f for f in contract_declarer.variables} if var_name and var_name in conc_variables_ptr: return conc_variables_ptr[var_name] @@ -126,6 +143,7 @@ def find_variable(var_name, caller_context, referenced_declaration=None, is_supe if var_name in modifiers: return modifiers[var_name] + # structures are looked on the contract declarer structures = contract.structures_as_dict() if var_name in structures: return structures[var_name] From 8af18a884ec51e983878780af31c585c3e0beec6 Mon Sep 17 00:00:00 2001 From: Josselin Date: Mon, 29 Apr 2019 15:49:51 +0100 Subject: [PATCH 17/55] API change: contracts.*not_inherited -> contracts.*_declared Add *_inherited *_declared for events/enums/state_variables/structures Use *_declared in core and detectors (remove *.contract == contract type of check) --- examples/scripts/possible_paths.py | 4 +- slither/core/declarations/contract.py | 74 ++++++++++++++++--- slither/core/declarations/enum.py | 8 ++ slither/core/declarations/event.py | 8 ++ slither/core/declarations/function.py | 12 ++- slither/core/declarations/structure.py | 8 ++ slither/core/variables/variable.py | 8 ++ .../erc20/unindexed_event_parameters.py | 6 +- .../detectors/functions/external_function.py | 4 +- .../naming_convention/naming_convention.py | 35 ++------- slither/detectors/reentrancy/reentrancy.py | 2 +- .../detectors/reentrancy/reentrancy_benign.py | 2 +- .../detectors/reentrancy/reentrancy_eth.py | 2 +- .../reentrancy_read_before_write.py | 2 +- slither/detectors/shadowing/abstract.py | 12 ++- .../detectors/shadowing/builtin_symbols.py | 32 ++++---- slither/detectors/shadowing/local.py | 16 ++-- slither/detectors/shadowing/state.py | 4 +- .../detectors/statements/deprecated_calls.py | 10 +-- .../printers/inheritance/inheritance_graph.py | 12 +-- slither/printers/summary/data_depenency.py | 2 +- slither/slithir/convert.py | 5 +- slither/solc_parsing/declarations/contract.py | 9 +-- slither/utils/inheritance_analysis.py | 5 +- utils/possible_paths/possible_paths.py | 4 +- 25 files changed, 174 insertions(+), 112 deletions(-) diff --git a/examples/scripts/possible_paths.py b/examples/scripts/possible_paths.py index 6c3b6d0be..87806520f 100644 --- a/examples/scripts/possible_paths.py +++ b/examples/scripts/possible_paths.py @@ -69,7 +69,7 @@ def all_function_definitions(function): :return: Returns a list composed of the provided function definition and any base definitions. """ return [function] + [f for c in function.contract.inheritance - for f in c.functions_and_modifiers_not_inherited + for f in c.functions_and_modifiers_declared if f.full_name == function.full_name] @@ -86,7 +86,7 @@ def __find_target_paths(target_function, current_path=[]): # Look through all functions for contract in slither.contracts: - for function in contract.functions_and_modifiers_not_inherited: + for function in contract.functions_and_modifiers_declared: # If the function is already in our path, skip it. if function in current_path: diff --git a/slither/core/declarations/contract.py b/slither/core/declarations/contract.py index a116f22c1..a79a70e4e 100644 --- a/slither/core/declarations/contract.py +++ b/slither/core/declarations/contract.py @@ -73,6 +73,20 @@ class Contract(ChildSlither, SourceMapping): ''' return list(self._structures.values()) + @property + def structures_inherited(self): + ''' + list(Structure): List of the inherited structures + ''' + return [s for s in self.structures if s.contract != self] + + @property + def structures_declared(self): + ''' + list(Structues): List of the structures declared within the contract (not inherited) + ''' + return [s for s in self.structures if s.contract == self] + def structures_as_dict(self): return self._structures @@ -87,6 +101,20 @@ class Contract(ChildSlither, SourceMapping): def enums(self): return list(self._enums.values()) + @property + def enums_inherited(self): + ''' + list(Enum): List of the inherited enums + ''' + return [e for e in self.enums if e.contract != self] + + @property + def enums_declared(self): + ''' + list(Enum): List of the enums declared within the contract (not inherited) + ''' + return [e for e in self.enums if e.contract == self] + def enums_as_dict(self): return self._enums @@ -104,6 +132,20 @@ class Contract(ChildSlither, SourceMapping): ''' return list(self._events.values()) + @property + def events_inherited(self): + ''' + list(Event): List of the inherited events + ''' + return [e for e in self.events if e.contract != self] + + @property + def events_declared(self): + ''' + list(Event): List of the events declared within the contract (not inherited) + ''' + return [e for e in self.events if e.contract == self] + def events_as_dict(self): return self._events @@ -149,6 +191,20 @@ class Contract(ChildSlither, SourceMapping): ''' return list(self._variables.values()) + @property + def state_variables_inherited(self): + ''' + list(StateVariable): List of the inherited state variables + ''' + return [s for s in self.state_variables if s.contract != self] + + @property + def state_variables_declared(self): + ''' + list(StateVariable): List of the state variables declared within the contract (not inherited) + ''' + return [s for s in self.state_variables if s.contract == self] + @property def slithir_variables(self): ''' @@ -173,17 +229,17 @@ class Contract(ChildSlither, SourceMapping): executed, following the c3 linearization Return None if there is no constructor. ''' - cst = self.constructor_not_inherited + cst = self.constructors_declared if cst: return cst for inherited_contract in self.inheritance: - cst = inherited_contract.constructor_not_inherited + cst = inherited_contract.constructors_declared if cst: return cst return None @property - def constructor_not_inherited(self): + def constructors_declared(self): return next((func for func in self.functions if func.is_constructor and func.contract_declarer == self), None) @property @@ -231,7 +287,7 @@ class Contract(ChildSlither, SourceMapping): return [f for f in self.functions if f.contract_declarer != self] @property - def functions_not_inherited(self): + def functions_declared(self): ''' list(Function): List of the functions defined within the contract (not inherited) ''' @@ -242,7 +298,7 @@ class Contract(ChildSlither, SourceMapping): ''' list(Functions): List of public and external functions ''' - return [f for f in self.functions if f.visibility in ['public', 'external']] + return [f for f in self.functions if f.visibility in ['public', 'external'] and not f.is_shadowed] @property def modifiers(self): @@ -262,7 +318,7 @@ class Contract(ChildSlither, SourceMapping): return [m for m in self.modifiers if m.contract_declarer != self] @property - def modifiers_not_inherited(self): + def modifiers_declared(self): ''' list(Modifier): List of the modifiers defined within the contract (not inherited) ''' @@ -283,11 +339,11 @@ class Contract(ChildSlither, SourceMapping): return self.functions_inherited + self.modifiers_inherited @property - def functions_and_modifiers_not_inherited(self): + def functions_and_modifiers_declared(self): ''' list(Function|Modifier): List of the functions and modifiers defined within the contract (not inherited) ''' - return self.functions_not_inherited + self.modifiers_not_inherited + return self.functions_declared + self.modifiers_declared def available_elements_from_inheritances(self, elements, getter_available): """ @@ -504,7 +560,7 @@ class Contract(ChildSlither, SourceMapping): list(core.Function) ''' - candidates = [c.functions_not_inherited for c in self.inheritance] + candidates = [c.functions_declared for c in self.inheritance] candidates = [candidate for sublist in candidates for candidate in sublist] return [f for f in candidates if f.full_name == function.full_name] diff --git a/slither/core/declarations/enum.py b/slither/core/declarations/enum.py index d04d0f6eb..ace9b2095 100644 --- a/slither/core/declarations/enum.py +++ b/slither/core/declarations/enum.py @@ -19,5 +19,13 @@ class Enum(ChildContract, SourceMapping): def values(self): return self._values + def is_declared_by(self, contract): + """ + Check if the element is declared by the contract + :param contract: + :return: + """ + return self.contract == contract + def __str__(self): return self.name diff --git a/slither/core/declarations/event.py b/slither/core/declarations/event.py index 29811f946..7d4eeeaf7 100644 --- a/slither/core/declarations/event.py +++ b/slither/core/declarations/event.py @@ -41,5 +41,13 @@ class Event(ChildContract, SourceMapping): def elems(self): return self._elems + def is_declared_by(self, contract): + """ + Check if the element is declared by the contract + :param contract: + :return: + """ + return self.contract == contract + def __str__(self): return self.name diff --git a/slither/core/declarations/function.py b/slither/core/declarations/function.py index fa0542ea3..1c8a9103c 100644 --- a/slither/core/declarations/function.py +++ b/slither/core/declarations/function.py @@ -140,6 +140,14 @@ class Function(ChildContract, ChildInheritance, SourceMapping): def slither(self): return self.contract.slither + def is_declared_by(self, contract): + """ + Check if the element is declared by the contract + :param contract: + :return: + """ + return self.contract_declarer == contract + # endregion ################################################################################### ################################################################################### @@ -324,7 +332,7 @@ class Function(ChildContract, ChildInheritance, SourceMapping): included. """ # This is a list of contracts internally, so we convert it to a list of constructor functions. - return [c.constructor_not_inherited for c in self._explicit_base_constructor_calls if c.constructor_not_inherited] + return [c.constructors_declared for c in self._explicit_base_constructor_calls if c.constructors_declared] # endregion @@ -577,7 +585,7 @@ class Function(ChildContract, ChildInheritance, SourceMapping): list(core.Function) ''' - candidates = [c.functions_not_inherited for c in self.contract.inheritance] + candidates = [c.functions_declared for c in self.contract.inheritance] candidates = [candidate for sublist in candidates for candidate in sublist] return [f for f in candidates if f.full_name == self.full_name] diff --git a/slither/core/declarations/structure.py b/slither/core/declarations/structure.py index b11fb7e35..5d36ffe7c 100644 --- a/slither/core/declarations/structure.py +++ b/slither/core/declarations/structure.py @@ -23,5 +23,13 @@ class Structure(ChildContract, SourceMapping): def elems(self): return self._elems + def is_declared_by(self, contract): + """ + Check if the element is declared by the contract + :param contract: + :return: + """ + return self.contract == contract + def __str__(self): return self.name diff --git a/slither/core/variables/variable.py b/slither/core/variables/variable.py index e1476ed19..2f54db6e2 100644 --- a/slither/core/variables/variable.py +++ b/slither/core/variables/variable.py @@ -78,6 +78,14 @@ class Variable(SourceMapping): assert isinstance(t, (Type, list)) or t is None self._type = t + def is_declared_by(self, contract): + """ + Check if the element is declared by the contract + :param contract: + :return: + """ + return self.contract == contract + def __str__(self): return self._name diff --git a/slither/detectors/erc20/unindexed_event_parameters.py b/slither/detectors/erc20/unindexed_event_parameters.py index 71327f94e..dd10267f9 100644 --- a/slither/detectors/erc20/unindexed_event_parameters.py +++ b/slither/detectors/erc20/unindexed_event_parameters.py @@ -47,11 +47,7 @@ In this case, Transfer and Approval events should have the 'indexed' keyword on return results # Loop through all events to look for poor form. - for event in contract.events: - - # Only handle events which are declared in this contract. - if event.contract != contract: - continue + for event in contract.events_declared: # If this is transfer/approval events, expect the first two parameters to be indexed. if event.full_name in ["Transfer(address,address,uint256)", diff --git a/slither/detectors/functions/external_function.py b/slither/detectors/functions/external_function.py index 50e0d52b2..9c95bde31 100644 --- a/slither/detectors/functions/external_function.py +++ b/slither/detectors/functions/external_function.py @@ -71,7 +71,7 @@ class ExternalFunction(AbstractDetector): for contract in function.contract.inheritance + [function.contract]: # Loop through the functions not inherited (explicitly defined in this contract). - for f in contract.functions_not_inherited: + for f in contract.functions_declared: # If it matches names, this is the base most function. if f.full_name == function.full_name: @@ -120,7 +120,7 @@ class ExternalFunction(AbstractDetector): continue # Next we'll want to loop through all functions defined directly in this contract. - for function in contract.functions_not_inherited: + for function in contract.functions_declared: # If the function is a constructor, or is public, we skip it. if function.is_constructor or function.visibility != "public": diff --git a/slither/detectors/naming_convention/naming_convention.py b/slither/detectors/naming_convention/naming_convention.py index b74696f34..b20382b83 100644 --- a/slither/detectors/naming_convention/naming_convention.py +++ b/slither/detectors/naming_convention/naming_convention.py @@ -69,13 +69,10 @@ Solidity defines a [naming convention](https://solidity.readthedocs.io/en/v0.4.2 json['elements'] = [elem] results.append(json) - for struct in contract.structures: - if struct.contract != contract: - continue - + for struct in contract.structures_declared: if not self.is_cap_words(struct.name): - info = "Struct '{}.{}' ({}) is not in CapWords\n" - info = info.format(struct.contract.name, struct.name, struct.source_mapping_str) + info = "Struct '{}' ({}) is not in CapWords\n" + info = info.format(struct.canonical_name, struct.source_mapping_str) json = self.generate_json_result(info) elem = dict() @@ -85,10 +82,8 @@ Solidity defines a [naming convention](https://solidity.readthedocs.io/en/v0.4.2 elem['source_mapping'] = struct.source_mapping json['elements'] = [elem] results.append(json) - for event in contract.events: - if event.contract != contract: - continue + for event in contract.events_declared: if not self.is_cap_words(event.name): info = "Event '{}' ({}) is not in CapWords\n" info = info.format(event.canonical_name, event.source_mapping_str) @@ -102,10 +97,7 @@ Solidity defines a [naming convention](https://solidity.readthedocs.io/en/v0.4.2 json['elements'] = [elem] results.append(json) - for func in contract.functions: - if func.contract_declarer != contract: - continue - + for func in contract.functions_declared: if not self.is_mixed_case(func.name): info = "Function '{}' ({}) is not in mixedCase\n" info = info.format(func.canonical_name, func.source_mapping_str) @@ -139,10 +131,7 @@ Solidity defines a [naming convention](https://solidity.readthedocs.io/en/v0.4.2 json['elements'] = [elem] results.append(json) - for var in contract.state_variables: - if var.contract != contract: - continue - + for var in contract.state_variables_declared: if self.should_avoid_name(var.name): if not self.is_upper_case_with_underscores(var.name): info = "Variable '{}' ({}) used l, O, I, which should not be used\n" @@ -193,10 +182,7 @@ Solidity defines a [naming convention](https://solidity.readthedocs.io/en/v0.4.2 json['elements'] = [elem] results.append(json) - for enum in contract.enums: - if enum.contract != contract: - continue - + for enum in contract.enums_declared: if not self.is_cap_words(enum.name): info = "Enum '{}' ({}) is not in CapWords\n" info = info.format(enum.canonical_name, enum.source_mapping_str) @@ -210,11 +196,7 @@ Solidity defines a [naming convention](https://solidity.readthedocs.io/en/v0.4.2 json['elements'] = [elem] results.append(json) - - for modifier in contract.modifiers: - if modifier.contract_declarer != contract: - continue - + for modifier in contract.modifiers_declared: if not self.is_mixed_case(modifier.name): info = "Modifier '{}' ({}) is not in mixedCase\n" info = info.format(modifier.canonical_name, @@ -229,5 +211,4 @@ Solidity defines a [naming convention](https://solidity.readthedocs.io/en/v0.4.2 json['elements'] = [elem] results.append(json) - return results diff --git a/slither/detectors/reentrancy/reentrancy.py b/slither/detectors/reentrancy/reentrancy.py index 527e80273..be5f95dd9 100644 --- a/slither/detectors/reentrancy/reentrancy.py +++ b/slither/detectors/reentrancy/reentrancy.py @@ -181,7 +181,7 @@ class Reentrancy(AbstractDetector): def detect_reentrancy(self, contract): """ """ - for function in contract.functions_and_modifiers_not_inherited: + for function in contract.functions_and_modifiers_declared: if function.is_implemented: if self.KEY in function.context: continue diff --git a/slither/detectors/reentrancy/reentrancy_benign.py b/slither/detectors/reentrancy/reentrancy_benign.py index 7cecc3e64..7a6ee795e 100644 --- a/slither/detectors/reentrancy/reentrancy_benign.py +++ b/slither/detectors/reentrancy/reentrancy_benign.py @@ -45,7 +45,7 @@ Only report reentrancy that acts as a double call (see `reentrancy-eth`, `reentr def find_reentrancies(self): result = {} for contract in self.contracts: - for f in contract.functions_and_modifiers_not_inherited: + for f in contract.functions_and_modifiers_declared: for node in f.nodes: # dead code if not self.KEY in node.context: diff --git a/slither/detectors/reentrancy/reentrancy_eth.py b/slither/detectors/reentrancy/reentrancy_eth.py index 0ea1b9357..39b30a42d 100644 --- a/slither/detectors/reentrancy/reentrancy_eth.py +++ b/slither/detectors/reentrancy/reentrancy_eth.py @@ -47,7 +47,7 @@ Bob uses the re-entrancy bug to call `withdrawBalance` two times, and withdraw m def find_reentrancies(self): result = {} for contract in self.contracts: - for f in contract.functions_and_modifiers_not_inherited: + for f in contract.functions_and_modifiers_declared: for node in f.nodes: # dead code if not self.KEY in node.context: diff --git a/slither/detectors/reentrancy/reentrancy_read_before_write.py b/slither/detectors/reentrancy/reentrancy_read_before_write.py index 95c0e5012..80962bfab 100644 --- a/slither/detectors/reentrancy/reentrancy_read_before_write.py +++ b/slither/detectors/reentrancy/reentrancy_read_before_write.py @@ -46,7 +46,7 @@ Do not report reentrancies that involve ethers (see `reentrancy-eth`)''' def find_reentrancies(self): result = {} for contract in self.contracts: - for f in contract.functions_and_modifiers_not_inherited: + for f in contract.functions_and_modifiers_declared: for node in f.nodes: # dead code if not self.KEY in node.context: diff --git a/slither/detectors/shadowing/abstract.py b/slither/detectors/shadowing/abstract.py index cafdf96f2..15bb7e2c1 100644 --- a/slither/detectors/shadowing/abstract.py +++ b/slither/detectors/shadowing/abstract.py @@ -41,9 +41,9 @@ contract DerivedContract is BaseContract{ variables_fathers = [] for father in contract.inheritance: if all(not f.is_implemented for f in father.functions + father.modifiers): - variables_fathers += [v for v in father.variables if v.contract == father] + variables_fathers += father.state_variables_declared - for var in [v for v in contract.variables if v.contract == contract]: + for var in contract.state_variables_declared: shadow = [v for v in variables_fathers if v.name == var.name] if shadow: ret.append([var] + shadow) @@ -65,12 +65,10 @@ contract DerivedContract is BaseContract{ for all_variables in shadowing: shadow = all_variables[0] variables = all_variables[1:] - info = '{}.{} ({}) shadows:\n'.format(shadow.contract.name, - shadow.name, - shadow.source_mapping_str) + info = '{} ({}) shadows:\n'.format(shadow.canonical_name, + shadow.source_mapping_str) for var in variables: - info += "\t- {}.{} ({})\n".format(var.contract.name, - var.name, + info += "\t- {} ({})\n".format(var.canonical_name, var.source_mapping_str) json = self.generate_json_result(info) diff --git a/slither/detectors/shadowing/builtin_symbols.py b/slither/detectors/shadowing/builtin_symbols.py index d04f24d54..2cd4cff09 100644 --- a/slither/detectors/shadowing/builtin_symbols.py +++ b/slither/detectors/shadowing/builtin_symbols.py @@ -90,24 +90,20 @@ contract Bug { result = [] # Loop through all functions, modifiers, variables (state and local) to detect any built-in symbol keywords. - for function in contract.functions: - if function.contract_declarer == contract: - if self.is_builtin_symbol(function.name): - result.append((self.SHADOWING_FUNCTION, function, None)) - result += self.detect_builtin_shadowing_locals(function) - for modifier in contract.modifiers: - if modifier.contract_declarer == contract: - if self.is_builtin_symbol(modifier.name): - result.append((self.SHADOWING_MODIFIER, modifier, None)) - result += self.detect_builtin_shadowing_locals(modifier) - for variable in contract.variables: - if variable.contract == contract: - if self.is_builtin_symbol(variable.name): - result.append((self.SHADOWING_STATE_VARIABLE, variable, None)) - for event in contract.events: - if event.contract == contract: - if self.is_builtin_symbol(event.name): - result.append((self.SHADOWING_EVENT, event, None)) + for function in contract.functions_declared: + if self.is_builtin_symbol(function.name): + result.append((self.SHADOWING_FUNCTION, function, None)) + result += self.detect_builtin_shadowing_locals(function) + for modifier in contract.modifiers_declared: + if self.is_builtin_symbol(modifier.name): + result.append((self.SHADOWING_MODIFIER, modifier, None)) + result += self.detect_builtin_shadowing_locals(modifier) + for variable in contract.state_variables_declared: + if self.is_builtin_symbol(variable.name): + result.append((self.SHADOWING_STATE_VARIABLE, variable, None)) + for event in contract.events_declared: + if self.is_builtin_symbol(event.name): + result.append((self.SHADOWING_EVENT, event, None)) return result diff --git a/slither/detectors/shadowing/local.py b/slither/detectors/shadowing/local.py index aadc637b9..0ba24811f 100644 --- a/slither/detectors/shadowing/local.py +++ b/slither/detectors/shadowing/local.py @@ -67,20 +67,20 @@ contract Bug { overshadowed = [] for scope_contract in [contract] + contract.inheritance: # Check functions - for scope_function in scope_contract.functions: - if variable.name == scope_function.name and scope_function.contract_declarer == scope_contract: + for scope_function in scope_contract.functions_declared: + if variable.name == scope_function.name: overshadowed.append((self.OVERSHADOWED_FUNCTION, scope_contract.name, scope_function)) # Check modifiers - for scope_modifier in scope_contract.modifiers: - if variable.name == scope_modifier.name and scope_modifier.contract_declarer == scope_contract: + for scope_modifier in scope_contract.modifiers_declared: + if variable.name == scope_modifier.name: overshadowed.append((self.OVERSHADOWED_MODIFIER, scope_contract.name, scope_modifier)) # Check events - for scope_event in scope_contract.events: - if variable.name == scope_event.name and scope_event.contract == scope_contract: + for scope_event in scope_contract.events_declared: + if variable.name == scope_event.name: overshadowed.append((self.OVERSHADOWED_EVENT, scope_contract.name, scope_event)) # Check state variables - for scope_state_variable in scope_contract.variables: - if variable.name == scope_state_variable.name and scope_state_variable.contract == scope_contract: + for scope_state_variable in scope_contract.state_variables_declared: + if variable.name == scope_state_variable.name: overshadowed.append((self.OVERSHADOWED_STATE_VARIABLE, scope_contract.name, scope_state_variable)) # If we have found any overshadowed objects, we'll want to add it to our result list. diff --git a/slither/detectors/shadowing/state.py b/slither/detectors/shadowing/state.py index 75ba66132..41da711f3 100644 --- a/slither/detectors/shadowing/state.py +++ b/slither/detectors/shadowing/state.py @@ -53,9 +53,9 @@ contract DerivedContract is BaseContract{ variables_fathers = [] for father in contract.inheritance: if any(f.is_implemented for f in father.functions + father.modifiers): - variables_fathers += [v for v in father.variables if v.contract == father] + variables_fathers += father.state_variables_declared - for var in [v for v in contract.variables if v.contract == contract]: + for var in contract.state_variables_declared: shadow = [v for v in variables_fathers if v.name == var.name] if shadow: ret.append([var] + shadow) diff --git a/slither/detectors/statements/deprecated_calls.py b/slither/detectors/statements/deprecated_calls.py index 6d0566549..c18843125 100644 --- a/slither/detectors/statements/deprecated_calls.py +++ b/slither/detectors/statements/deprecated_calls.py @@ -111,20 +111,14 @@ contract ContractWithDeprecatedReferences { list of tuple: (state_variable | node, (detecting_signature, original_text, recommended_text))""" results = [] - for state_variable in contract.variables: - if state_variable.contract != contract: - continue + for state_variable in contract.state_variables_declared: if state_variable.expression: deprecated_results = self.detect_deprecation_in_expression(state_variable.expression) if deprecated_results: results.append((state_variable, deprecated_results)) # Loop through all functions + modifiers in this contract. - for function in contract.functions + contract.modifiers: - # We should only look for functions declared directly in this contract (not in a base contract). - if function.contract != contract: - continue - + for function in contract.functions_and_modifiers_declared: # Loop through each node in this function. for node in function.nodes: # Detect deprecated references in the node. diff --git a/slither/printers/inheritance/inheritance_graph.py b/slither/printers/inheritance/inheritance_graph.py index 75c60b5e1..73ee72af8 100644 --- a/slither/printers/inheritance/inheritance_graph.py +++ b/slither/printers/inheritance/inheritance_graph.py @@ -91,8 +91,8 @@ class PrinterInheritanceGraph(AbstractPrinter): indirect_shadows = detect_c3_function_shadowing(contract) if indirect_shadows: for collision_set in sorted(indirect_shadows, key=lambda x: x[0][1].name): - winner = collision_set[-1][1].contract.name - collision_steps = [colliding_function.contract.name for _, colliding_function in collision_set] + winner = collision_set[-1][1].contract_declarer.name + collision_steps = [colliding_function.contract_declarer.name for _, colliding_function in collision_set] collision_steps = ', '.join(collision_steps) result.append(f"'{collision_set[0][1].full_name}' collides in inherited contracts {collision_steps} where {winner} is chosen.") return '\n'.join(result) @@ -127,12 +127,12 @@ class PrinterInheritanceGraph(AbstractPrinter): modifiers = ''.join(modifiers) # Public variables - public_variables = [self._get_pattern_var(v, contract) for v in contract.variables if - v.contract == contract and v.visibility in visibilities] + public_variables = [self._get_pattern_var(v, contract) for v in contract.state_variables_declared + if v.visibility in visibilities] public_variables = ''.join(public_variables) - private_variables = [self._get_pattern_var(v, contract) for v in contract.variables if - v.contract == contract and v.visibility not in visibilities] + private_variables = [self._get_pattern_var(v, contract) for v in contract.state_variables_declared + if v.visibility not in visibilities] private_variables = ''.join(private_variables) # Obtain any indirect shadowing information for this node. diff --git a/slither/printers/summary/data_depenency.py b/slither/printers/summary/data_depenency.py index d64a0f638..c8fb38277 100644 --- a/slither/printers/summary/data_depenency.py +++ b/slither/printers/summary/data_depenency.py @@ -35,7 +35,7 @@ class DataDependency(AbstractPrinter): txt += str(table) txt += "\n" - for f in c.functions_and_modifiers_not_inherited: + for f in c.functions_and_modifiers_declared: txt += "\nFunction %s\n"%f.full_name table = PrettyTable(['Variable', 'Dependencies']) for v in f.variables: diff --git a/slither/slithir/convert.py b/slither/slithir/convert.py index 51993b2c6..2bff4b33d 100644 --- a/slither/slithir/convert.py +++ b/slither/slithir/convert.py @@ -658,7 +658,10 @@ def look_for_library(contract, ir, node, using_for, t): return None def convert_to_library(ir, node, using_for): - contract = node.function.contract + # We use contract_declarer, because Solidity resolve the library + # before resolving the inheritance. + # Though we could use .contract as libraries cannot be shadowed + contract = node.function.contract_declarer t = ir.destination.type if t in using_for: diff --git a/slither/solc_parsing/declarations/contract.py b/slither/solc_parsing/declarations/contract.py index 27de7b4b1..c70e449c3 100644 --- a/slither/solc_parsing/declarations/contract.py +++ b/slither/solc_parsing/declarations/contract.py @@ -471,11 +471,10 @@ class ContractSolc04(Contract): all_ssa_state_variables_instances = dict() for contract in self.inheritance: - for v in contract.variables: - if v.contract == contract: - new_var = StateIRVariable(v) - all_ssa_state_variables_instances[v.canonical_name] = new_var - self._initial_state_variables.append(new_var) + for v in contract.state_variables_declared: + new_var = StateIRVariable(v) + all_ssa_state_variables_instances[v.canonical_name] = new_var + self._initial_state_variables.append(new_var) for v in self.variables: if v.contract == self: diff --git a/slither/utils/inheritance_analysis.py b/slither/utils/inheritance_analysis.py index 0c0f7c6da..3caa06b74 100644 --- a/slither/utils/inheritance_analysis.py +++ b/slither/utils/inheritance_analysis.py @@ -61,7 +61,7 @@ def detect_direct_function_shadowing(contract): function (could have provided it through inheritance, does not need to directly define it). -overshadowed_function is the function definition which is overshadowed by the provided contract's definition. """ - functions_declared = {function.full_name: function for function in contract.functions_and_modifiers_not_inherited} + functions_declared = {function.full_name: function for function in contract.functions_and_modifiers_declared} results = {} for base_contract in reversed(contract.immediate_inheritance): for base_function in base_contract.functions_and_modifiers: @@ -128,8 +128,7 @@ def detect_state_variable_shadowing(contracts): """ results = set() for contract in contracts: - variables_declared = {variable.name: variable for variable in contract.variables - if variable.contract == contract} + variables_declared = {variable.name: variable for variable in contract.state_variables_declared} for immediate_base_contract in contract.immediate_inheritance: for variable in immediate_base_contract.variables: if variable.name in variables_declared: diff --git a/utils/possible_paths/possible_paths.py b/utils/possible_paths/possible_paths.py index 0d9976e08..e638b00ad 100644 --- a/utils/possible_paths/possible_paths.py +++ b/utils/possible_paths/possible_paths.py @@ -67,7 +67,7 @@ def all_function_definitions(function): :return: Returns a list composed of the provided function definition and any base definitions. """ return [function] + [f for c in function.contract.inheritance - for f in c.functions_and_modifiers_not_inherited + for f in c.functions_and_modifiers_declared if f.full_name == function.full_name] @@ -84,7 +84,7 @@ def __find_target_paths(slither, target_function, current_path=[]): # Look through all functions for contract in slither.contracts: - for function in contract.functions_and_modifiers_not_inherited: + for function in contract.functions_and_modifiers_declared: # If the function is already in our path, skip it. if function in current_path: From d20b226da7f69b30323220a89c1abd30889d1751 Mon Sep 17 00:00:00 2001 From: Josselin Date: Mon, 29 Apr 2019 16:13:46 +0100 Subject: [PATCH 18/55] Fix bugs in call graph printer --- slither/printers/call/call_graph.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/slither/printers/call/call_graph.py b/slither/printers/call/call_graph.py index cf6776e69..4c9b9e385 100644 --- a/slither/printers/call/call_graph.py +++ b/slither/printers/call/call_graph.py @@ -71,7 +71,7 @@ class PrinterCallGraph(AbstractPrinter): for contract in all_contracts: render_internal_calls += self._render_internal_calls(contract, contract_functions, contract_calls) - render_solidity_calls = '' #self._render_solidity_calls(solidity_functions, solidity_calls) + render_solidity_calls = self._render_solidity_calls(solidity_functions, solidity_calls) render_external_calls = self._render_external_calls(external_calls) @@ -110,7 +110,6 @@ class PrinterCallGraph(AbstractPrinter): # add variable as node to respective contract if isinstance(external_function, (Variable)): - return contract_functions[external_contract].add(_node( _function_node(external_contract, external_function), external_function.name From 5a9db1d11862c69c99963c1c27aec1cda89b2f9a Mon Sep 17 00:00:00 2001 From: Josselin Date: Mon, 29 Apr 2019 16:40:39 +0100 Subject: [PATCH 19/55] Fix inheritance graph --- slither/utils/inheritance_analysis.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/slither/utils/inheritance_analysis.py b/slither/utils/inheritance_analysis.py index 3caa06b74..013de531e 100644 --- a/slither/utils/inheritance_analysis.py +++ b/slither/utils/inheritance_analysis.py @@ -19,7 +19,7 @@ def detect_c3_function_shadowing(contract): for i in range(0, len(contract.immediate_inheritance) - 1): inherited_contract1 = contract.immediate_inheritance[i] - for function1 in inherited_contract1.functions_and_modifiers: + for function1 in inherited_contract1.functions_and_modifiers_declared: # If this function has already be handled or is unimplemented, we skip it if function1.full_name in results or function1.is_constructor or not function1.is_implemented: continue From ea9e46b313b25a60a45f8c3e90b97fc6f4185d38 Mon Sep 17 00:00:00 2001 From: Josselin Date: Mon, 29 Apr 2019 17:06:32 +0100 Subject: [PATCH 20/55] Fix incorrect is_declared_by func --- slither/core/variables/state_variable.py | 7 +++++++ slither/core/variables/variable.py | 7 ------- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/slither/core/variables/state_variable.py b/slither/core/variables/state_variable.py index 86c21e30e..8fee502bb 100644 --- a/slither/core/variables/state_variable.py +++ b/slither/core/variables/state_variable.py @@ -3,6 +3,13 @@ from slither.core.children.child_contract import ChildContract class StateVariable(ChildContract, Variable): + def is_declared_by(self, contract): + """ + Check if the element is declared by the contract + :param contract: + :return: + """ + return self.contract == contract @property def canonical_name(self): diff --git a/slither/core/variables/variable.py b/slither/core/variables/variable.py index 2f54db6e2..8b37c6da1 100644 --- a/slither/core/variables/variable.py +++ b/slither/core/variables/variable.py @@ -78,13 +78,6 @@ class Variable(SourceMapping): assert isinstance(t, (Type, list)) or t is None self._type = t - def is_declared_by(self, contract): - """ - Check if the element is declared by the contract - :param contract: - :return: - """ - return self.contract == contract def __str__(self): return self._name From 92a0ca0e22cba978ff6738c1eee4797ebde7d0d0 Mon Sep 17 00:00:00 2001 From: ggrieco-tob Date: Tue, 7 May 2019 18:13:32 -0300 Subject: [PATCH 21/55] fixed bug in simil info --- utils/similarity/info.py | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/utils/similarity/info.py b/utils/similarity/info.py index 947d9b40b..76da37d99 100644 --- a/utils/similarity/info.py +++ b/utils/similarity/info.py @@ -1,5 +1,6 @@ import logging import sys +import os.path import traceback from fastText import load_model @@ -11,8 +12,13 @@ logger = logging.getLogger("Slither-simil") def info(args): try: + model = args.model - model = load_model(model) + if os.path.isfile(model): + model = load_model(model) + else: + model = None + filename = args.filename contract = args.contract solc = args.solc @@ -30,14 +36,15 @@ def info(args): irs = encode_contract(filename, solc=solc) if len(irs) == 0: sys.exit(-1) - - x = "-".join([filename,contract,fname]) - y = " ".join(irs[x]) - fvector = model.get_sentence_vector(y) + x = (filename,contract,fname) + y = " ".join(irs[x]) + print("Function {} in contract {} is encoded as:".format(fname, contract)) print(y) - print(fvector) + if model is not None: + fvector = model.get_sentence_vector(y) + print(fvector) except Exception: logger.error('Error in %s' % args.filename) From c41bddd3930773d697a666034438e02cddf56c2b Mon Sep 17 00:00:00 2001 From: ggrieco-tob Date: Tue, 7 May 2019 18:16:29 -0300 Subject: [PATCH 22/55] added basic tests for slither-simil --- .travis.yml | 1 + scripts/travis_test_simil.sh | 16 ++++++++++++++++ tests/simil/test_1.txt | 1 + 3 files changed, 18 insertions(+) create mode 100755 scripts/travis_test_simil.sh create mode 100644 tests/simil/test_1.txt diff --git a/.travis.yml b/.travis.yml index d3ccde3c2..b33582446 100644 --- a/.travis.yml +++ b/.travis.yml @@ -18,6 +18,7 @@ env: - TEST_SUITE=scripts/travis_test_cli.sh - TEST_SUITE=scripts/travis_test_printers.sh - TEST_SUITE=scripts/travis_test_slither_config.sh + - TEST_SUITE=scripts/travis_test_simil.sh branches: only: - master diff --git a/scripts/travis_test_simil.sh b/scripts/travis_test_simil.sh new file mode 100755 index 000000000..c4123191a --- /dev/null +++ b/scripts/travis_test_simil.sh @@ -0,0 +1,16 @@ +#!/usr/bin/env bash + +### Test slither-simil + +DIR_TESTS="tests/simil" +slither-simil info "" --filename $DIR_TESTS/../complex_func.sol --contract Complex --fname complexExternalWrites --solc solc-0.4.25 > test_1.txt 2>&1 +DIFF=$(diff test_1.txt "$DIR_TESTS/test_1.txt") +if [ "$DIFF" != "" ] +then + echo "slither-simil failed" + cat test_1.txt + cat "$DIR_TESTS/test_1.txt" + exit -1 +fi + +rm test_1.txt diff --git a/tests/simil/test_1.txt b/tests/simil/test_1.txt new file mode 100644 index 000000000..8baef1b4a --- /dev/null +++ b/tests/simil/test_1.txt @@ -0,0 +1 @@ +abc From b00b37552089f8049e895e2ceff4ee227e0aefe9 Mon Sep 17 00:00:00 2001 From: ggrieco-tob Date: Tue, 7 May 2019 18:29:56 -0300 Subject: [PATCH 23/55] added installation of requisites --- scripts/travis_test_simil.sh | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/scripts/travis_test_simil.sh b/scripts/travis_test_simil.sh index c4123191a..0d571aa82 100755 --- a/scripts/travis_test_simil.sh +++ b/scripts/travis_test_simil.sh @@ -1,5 +1,10 @@ #!/usr/bin/env bash +### Install requisites + +pip3.6 install pybind11 --user +pip3.6 install https://github.com/facebookresearch/fastText/archive/0.2.0.zip --user + ### Test slither-simil DIR_TESTS="tests/simil" From 2664045e6f21674976015f1a76732633a3d91e8c Mon Sep 17 00:00:00 2001 From: ggrieco-tob Date: Tue, 7 May 2019 18:39:02 -0300 Subject: [PATCH 24/55] added installation of requisites --- scripts/travis_test_simil.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/travis_test_simil.sh b/scripts/travis_test_simil.sh index 0d571aa82..d520ea748 100755 --- a/scripts/travis_test_simil.sh +++ b/scripts/travis_test_simil.sh @@ -2,8 +2,8 @@ ### Install requisites -pip3.6 install pybind11 --user -pip3.6 install https://github.com/facebookresearch/fastText/archive/0.2.0.zip --user +pip3.6 install pybind11 +pip3.6 install https://github.com/facebookresearch/fastText/archive/0.2.0.zip ### Test slither-simil From 96c9417705b1bdc134f2738fd4e856658e23ea5a Mon Sep 17 00:00:00 2001 From: ggrieco-tob Date: Tue, 7 May 2019 18:57:00 -0300 Subject: [PATCH 25/55] removed useless module --- utils/similarity/plot.py | 1 - 1 file changed, 1 deletion(-) diff --git a/utils/similarity/plot.py b/utils/similarity/plot.py index d6bd75e33..bfa4059f4 100644 --- a/utils/similarity/plot.py +++ b/utils/similarity/plot.py @@ -3,7 +3,6 @@ import sys import traceback import operator import numpy as np -import tqdm import random try: From ee37919ca76fd4b0fc44f6cec86163bee2a2e157 Mon Sep 17 00:00:00 2001 From: ggrieco-tob Date: Tue, 7 May 2019 19:07:25 -0300 Subject: [PATCH 26/55] fixed test --- tests/simil/test_1.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/simil/test_1.txt b/tests/simil/test_1.txt index 8baef1b4a..f722b9880 100644 --- a/tests/simil/test_1.txt +++ b/tests/simil/test_1.txt @@ -1 +1,2 @@ -abc +Function complexExternalWrites in contract Complex is encoded as: +new_contract (local_solc_variable(default)):=(temporary_variable) high_level_call high_level_call high_level_call high_level_call high_level_call new_contract (local_solc_variable(default)):=(temporary_variable) high_level_call new_contract (local_solc_variable(default)):=(temporary_variable) solidity_call(keccak256()) type_conversion(bytes4) low_level_call new_contract (local_solc_variable(default)):=(temporary_variable) solidity_call(keccak256()) type_conversion(bytes4) low_level_call From 5a1d30e1ab78379af792d990b31597fef4b12b08 Mon Sep 17 00:00:00 2001 From: ggrieco-tob Date: Thu, 9 May 2019 08:59:09 -0300 Subject: [PATCH 27/55] fixes --- utils/similarity/cache.py | 23 ++++++++--------------- utils/similarity/encode.py | 19 +++++++++++++++++++ utils/similarity/plot.py | 21 ++++++++++++++------- utils/similarity/test.py | 5 +++-- 4 files changed, 44 insertions(+), 24 deletions(-) diff --git a/utils/similarity/cache.py b/utils/similarity/cache.py index b11bbf499..f5973b4b3 100644 --- a/utils/similarity/cache.py +++ b/utils/similarity/cache.py @@ -1,21 +1,14 @@ import numpy as np -from .encode import encode_contract, load_contracts - -def load_cache(infile, model, ext=None, solc='solc'): +def load_cache(infile, nsamples=None): cache = dict() - if infile.endswith(".npz"): - with np.load(infile) as data: - array = data['arr_0'][0] - for x,y in array: - cache[x] = y - else: - contracts = load_contracts(infile, ext=ext) - for contract in contracts: - for x,ir in encode_contract(contract, solc=solc).items(): - if ir != []: - y = " ".join(ir) - cache[x] = model.get_sentence_vector(y) + with np.load(infile) as data: + array = data['arr_0'][0] + for i,(x,y) in enumerate(array): + cache[x] = y + if i == nsamples: + break + return cache def save_cache(cache, outfile): diff --git a/utils/similarity/encode.py b/utils/similarity/encode.py index 081b66671..8dbac9f3d 100644 --- a/utils/similarity/encode.py +++ b/utils/similarity/encode.py @@ -12,8 +12,27 @@ from slither.solc_parsing.variables.state_variable import * from slither.solc_parsing.variables.local_variable import * from slither.solc_parsing.variables.local_variable_init_from_tuple import * +from .cache import load_cache + logger = logging.getLogger("Slither-simil") +def load_and_encode(infile, model, ext=None, solc='solc', nsamples=None): + r = dict() + if infile.endswith(".npz"): + r = load_cache(infile, nsamples=nsamples) + else: + contracts = load_contracts(infile, ext=ext, nsamples=nsamples) + for contract in contracts: + for x,ir in encode_contract(contract, solc=solc).items(): + if ir != []: + y = " ".join(ir) + r[x] = model.get_sentence_vector(y) + + return r + + + + def load_contracts(dirname, ext=None, nsamples=None): r = [] walk = list(os.walk(dirname)) diff --git a/utils/similarity/plot.py b/utils/similarity/plot.py index bfa4059f4..83809faa3 100644 --- a/utils/similarity/plot.py +++ b/utils/similarity/plot.py @@ -13,7 +13,7 @@ except ImportError: plt = None from fastText import load_model -from .cache import load_cache +from .encode import load_and_encode logger = logging.getLogger("Slither-simil") @@ -34,23 +34,29 @@ def plot(args): solc = args.solc infile = args.input ext = args.filter + nsamples = args.nsamples - if contract is None or fname is None or infile is None: - logger.error('The plot mode requieres contract, fname and input parameters.') + if fname is None or infile is None: + logger.error('The plot mode requieres fname and input parameters.') sys.exit(-1) logger.info('Loading data..') - cache = load_cache(infile, model, ext=ext, solc=solc) + cache = load_and_encode(infile, model, ext=ext, solc=solc, nsamples=nsamples) + #cache = load_cache(infile, model, ext=ext, solc=solc) data = list() fs = list() logger.info('Procesing data..') for (f,c,n),y in cache.items(): - if c == contract and n == fname: + if (c == contract or contract is None) and n == fname: fs.append(f) data.append(y) - + + if len(data) == 0: + logger.error('No contract was found with function %s', fname) + sys.exit(-1) + data = np.array(data) pca = decomposition.PCA(n_components=2) tdata = pca.fit_transform(data) @@ -62,8 +68,9 @@ def plot(args): x = random.gauss(0, 0.01) + x y = random.gauss(0, 0.01) + y plt.scatter(x, y, c='blue') - #plt.text(x-0.001,y+0.001, l.split("_")[1].replace(".sol.ast.compact.json","")) + plt.text(x-0.001,y+0.001, l) + logger.info('Saving figure to plot.png..') plt.savefig('plot.png', bbox_inches='tight') except Exception: diff --git a/utils/similarity/test.py b/utils/similarity/test.py index 342551499..7fd7c7f56 100755 --- a/utils/similarity/test.py +++ b/utils/similarity/test.py @@ -6,7 +6,7 @@ import operator import numpy as np from fastText import load_model -from .encode import encode_contract, load_contracts +from .encode import encode_contract, load_and_encode from .cache import load_cache, save_cache from .similarity import similarity @@ -36,7 +36,7 @@ def test(args): y = " ".join(irs[(filename,contract,fname)]) fvector = model.get_sentence_vector(y) - cache = load_cache(infile, model, ext=ext, solc=solc) + cache = load_and_encode(infile, model, ext=ext, solc=solc) #save_cache("cache.npz", cache) r = dict() @@ -44,6 +44,7 @@ def test(args): r[x] = similarity(fvector, y) r = sorted(r.items(), key=operator.itemgetter(1), reverse=True) + logger.info("Reviewed %d functions, listing the %d most similar ones:", len(r), ntop) for x,score in r[:ntop]: print(x,score) From 1752a1abfba5d15ab90c8aaa628e94aec80f085b Mon Sep 17 00:00:00 2001 From: ggrieco-tob Date: Thu, 9 May 2019 14:26:20 -0300 Subject: [PATCH 28/55] added crytic-compile options into the slither-simil command line --- utils/similarity/__main__.py | 9 ++++----- utils/similarity/encode.py | 11 ++++------- 2 files changed, 8 insertions(+), 12 deletions(-) diff --git a/utils/similarity/__main__.py b/utils/similarity/__main__.py index 50cc09a43..f7eca662e 100755 --- a/utils/similarity/__main__.py +++ b/utils/similarity/__main__.py @@ -6,6 +6,8 @@ import sys import traceback import operator +from crytic_compile import cryticparser + from .info import info from .test import test from .train import train @@ -27,11 +29,6 @@ def parse_args(): parser.add_argument('model', help='model.bin') - parser.add_argument('--solc', - help='solc path', - action='store', - default='solc') - parser.add_argument('--filename', action='store', dest='filename', @@ -75,6 +72,8 @@ def parse_args(): version="0.0", action='version') + cryticparser.init(parser) + if len(sys.argv) == 1: parser.print_help(sys.stderr) sys.exit(1) diff --git a/utils/similarity/encode.py b/utils/similarity/encode.py index 8dbac9f3d..2e3cbd4a9 100644 --- a/utils/similarity/encode.py +++ b/utils/similarity/encode.py @@ -16,23 +16,20 @@ from .cache import load_cache logger = logging.getLogger("Slither-simil") -def load_and_encode(infile, model, ext=None, solc='solc', nsamples=None): +def load_and_encode(infile, model, ext=None, nsamples=None, **kwargs): r = dict() if infile.endswith(".npz"): r = load_cache(infile, nsamples=nsamples) else: contracts = load_contracts(infile, ext=ext, nsamples=nsamples) for contract in contracts: - for x,ir in encode_contract(contract, solc=solc).items(): + for x,ir in encode_contract(contract, **kwargs).items(): if ir != []: y = " ".join(ir) r[x] = model.get_sentence_vector(y) return r - - - def load_contracts(dirname, ext=None, nsamples=None): r = [] walk = list(os.walk(dirname)) @@ -169,12 +166,12 @@ def encode_ir(ir): print(type(ir),"is missing encoding!") return '' -def encode_contract(filename, solc): +def encode_contract(filename, **kwargs): r = dict() # Init slither try: - slither = Slither(filename, solc=solc) + slither = Slither(filename, **kwargs) except: logger.error("Compilation failed") return r From 6c613dde8cd8132aff83630209737533d97b9371 Mon Sep 17 00:00:00 2001 From: ggrieco-tob Date: Thu, 9 May 2019 15:21:47 -0300 Subject: [PATCH 29/55] fixed formating --- utils/similarity/encode.py | 5 +---- utils/similarity/plot.py | 5 ++--- utils/similarity/test.py | 7 +++++-- 3 files changed, 8 insertions(+), 9 deletions(-) diff --git a/utils/similarity/encode.py b/utils/similarity/encode.py index 2e3cbd4a9..604390802 100644 --- a/utils/similarity/encode.py +++ b/utils/similarity/encode.py @@ -53,10 +53,8 @@ def ntype(_type): else: _type = "user_defined_array" elif isinstance(_type, Structure): - print(_type) _type = str(_type) elif isinstance(_type, Enum): - print(_type) _type = str(_type) elif isinstance(_type, MappingType): _type = str(_type) @@ -86,7 +84,6 @@ def encode_ir(ir): if isinstance(ir, Assignment): return '({}):=({})'.format(encode_ir(ir.lvalue), encode_ir(ir.rvalue)) if isinstance(ir, Index): - #print(type(ir._type)) return 'index({})'.format(ntype(ir._type)) if isinstance(ir, Member): return 'member' #.format(ntype(ir._type)) @@ -163,7 +160,7 @@ def encode_ir(ir): # default else: - print(type(ir),"is missing encoding!") + logger.error(type(ir),"is missing encoding!") return '' def encode_contract(filename, **kwargs): diff --git a/utils/similarity/plot.py b/utils/similarity/plot.py index 83809faa3..12ae322e4 100644 --- a/utils/similarity/plot.py +++ b/utils/similarity/plot.py @@ -20,8 +20,8 @@ logger = logging.getLogger("Slither-simil") def plot(args): if decomposition is None or plt is None: - print("ERROR: In order to use plot mode in slither-simil, you need to install sklearn and matplotlib:") - print("$ pip3 install sklearn matplotlib --user") + logger.error("ERROR: In order to use plot mode in slither-simil, you need to install sklearn and matplotlib:") + logger.error("$ pip3 install sklearn matplotlib --user") sys.exit(-1) try: @@ -42,7 +42,6 @@ def plot(args): logger.info('Loading data..') cache = load_and_encode(infile, model, ext=ext, solc=solc, nsamples=nsamples) - #cache = load_cache(infile, model, ext=ext, solc=solc) data = list() fs = list() diff --git a/utils/similarity/test.py b/utils/similarity/test.py index 7fd7c7f56..67685a3e8 100755 --- a/utils/similarity/test.py +++ b/utils/similarity/test.py @@ -44,9 +44,12 @@ def test(args): r[x] = similarity(fvector, y) r = sorted(r.items(), key=operator.itemgetter(1), reverse=True) - logger.info("Reviewed %d functions, listing the %d most similar ones:", len(r), ntop) + logger.info("Reviewed %d functions, listing the %d most similar ones:", len(r), ntop) + format_table = "{: <65} {: <20} {: <20} {: <10}" + logger.info(format_table.format(*["filename", "contract", "function", "score"])) for x,score in r[:ntop]: - print(x,score) + score = str(round(score, 3)) + logger.info(format_table.format(*(list(x)+[score]))) except Exception: logger.error('Error in %s' % args.filename) From ee706bf5a9b3806eebe97a1a6d75ed9f562229a7 Mon Sep 17 00:00:00 2001 From: ggrieco-tob Date: Thu, 9 May 2019 17:51:09 -0300 Subject: [PATCH 30/55] fixes and improvements in slither-simil --- utils/similarity/__main__.py | 15 +++++---------- utils/similarity/encode.py | 34 ++++++++++++++++++++++++---------- utils/similarity/info.py | 12 ++++++------ utils/similarity/plot.py | 14 +++++++------- utils/similarity/test.py | 13 +++++-------- utils/similarity/train.py | 6 ++---- 6 files changed, 49 insertions(+), 45 deletions(-) diff --git a/utils/similarity/__main__.py b/utils/similarity/__main__.py index f7eca662e..8c5d5a142 100755 --- a/utils/similarity/__main__.py +++ b/utils/similarity/__main__.py @@ -34,21 +34,16 @@ def parse_args(): dest='filename', help='contract.sol') - parser.add_argument('--contract', + parser.add_argument('--fname', action='store', - dest='contract', - help='Contract') + dest='fname', + help='Target function') - parser.add_argument('--filter', + parser.add_argument('--ext', action='store', - dest='filter', + dest='ext', help='Extension to filter contracts') - parser.add_argument('--fname', - action='store', - dest='fname', - help='Function name') - parser.add_argument('--nsamples', action='store', type=int, diff --git a/utils/similarity/encode.py b/utils/similarity/encode.py index 604390802..13438a137 100644 --- a/utils/similarity/encode.py +++ b/utils/similarity/encode.py @@ -13,10 +13,24 @@ from slither.solc_parsing.variables.local_variable import * from slither.solc_parsing.variables.local_variable_init_from_tuple import * from .cache import load_cache +from crytic_compile.platform.solc import InvalidCompilation + +simil_logger = logging.getLogger("Slither-simil") +compiler_logger = logging.getLogger("CryticCompile") +compiler_logger.setLevel(logging.CRITICAL) +slither_logger = logging.getLogger("Slither") +slither_logger.setLevel(logging.CRITICAL) + +def parse_target(target): + parts = target.split('.') + if len(parts) == 1: + return None, parts[0] + elif len(parts) == 2: + return parts + else: + simil_logger.error("Invalid target. It should be 'function' or 'Contract.function'") -logger = logging.getLogger("Slither-simil") - -def load_and_encode(infile, model, ext=None, nsamples=None, **kwargs): +def load_and_encode(infile, model, filter=None, nsamples=None, **kwargs): r = dict() if infile.endswith(".npz"): r = load_cache(infile, nsamples=nsamples) @@ -30,7 +44,7 @@ def load_and_encode(infile, model, ext=None, nsamples=None, **kwargs): return r -def load_contracts(dirname, ext=None, nsamples=None): +def load_contracts(dirname, ext=None, nsamples=None, **kwargs): r = [] walk = list(os.walk(dirname)) for x, y, files in walk: @@ -160,17 +174,17 @@ def encode_ir(ir): # default else: - logger.error(type(ir),"is missing encoding!") + simil_logger.error(type(ir),"is missing encoding!") return '' -def encode_contract(filename, **kwargs): +def encode_contract(cfilename, **kwargs): r = dict() # Init slither - try: - slither = Slither(filename, **kwargs) + try: + slither = Slither(cfilename, **kwargs) except: - logger.error("Compilation failed") + simil_logger.error("Compilation failed for %s using %s", cfilename, kwargs['solc']) return r # Iterate over all the contracts @@ -185,7 +199,7 @@ def encode_contract(filename, **kwargs): if function.nodes == []: continue - x = (filename,contract.name,function.name) + x = (cfilename,contract.name,function.name) r[x] = [] diff --git a/utils/similarity/info.py b/utils/similarity/info.py index 76da37d99..7cfa0fb67 100644 --- a/utils/similarity/info.py +++ b/utils/similarity/info.py @@ -4,7 +4,7 @@ import os.path import traceback from fastText import load_model -from .encode import encode_contract +from .encode import parse_target, encode_contract logging.basicConfig() logger = logging.getLogger("Slither-simil") @@ -20,20 +20,20 @@ def info(args): model = None filename = args.filename - contract = args.contract + contract, fname = parse_target(args.fname) solc = args.solc - fname = args.fname + if filename is None and contract is None and fname is None: - print(args.model,"uses the following words:") + logger.info("%s uses the following words:",args.model) for word in model.get_words(): - print(word) + logger.info(word) sys.exit(0) if filename is None or contract is None or fname is None: logger.error('The encode mode requires filename, contract and fname parameters.') sys.exit(-1) - irs = encode_contract(filename, solc=solc) + irs = encode_contract(filename, **vars(args)) if len(irs) == 0: sys.exit(-1) diff --git a/utils/similarity/plot.py b/utils/similarity/plot.py index 12ae322e4..69d359f35 100644 --- a/utils/similarity/plot.py +++ b/utils/similarity/plot.py @@ -13,7 +13,7 @@ except ImportError: plt = None from fastText import load_model -from .encode import load_and_encode +from .encode import load_and_encode, parse_target logger = logging.getLogger("Slither-simil") @@ -29,19 +29,19 @@ def plot(args): model = args.model model = load_model(model) filename = args.filename - contract = args.contract - fname = args.fname - solc = args.solc + #contract = args.contract + contract, fname = parse_target(args.fname) + #solc = args.solc infile = args.input - ext = args.filter - nsamples = args.nsamples + #ext = args.filter + #nsamples = args.nsamples if fname is None or infile is None: logger.error('The plot mode requieres fname and input parameters.') sys.exit(-1) logger.info('Loading data..') - cache = load_and_encode(infile, model, ext=ext, solc=solc, nsamples=nsamples) + cache = load_and_encode(infile, **vars(args)) data = list() fs = list() diff --git a/utils/similarity/test.py b/utils/similarity/test.py index 67685a3e8..f821b6448 100755 --- a/utils/similarity/test.py +++ b/utils/similarity/test.py @@ -6,8 +6,8 @@ import operator import numpy as np from fastText import load_model -from .encode import encode_contract, load_and_encode -from .cache import load_cache, save_cache +from .encode import encode_contract, load_and_encode, parse_target +from .cache import save_cache from .similarity import similarity logger = logging.getLogger("Slither-simil") @@ -18,25 +18,22 @@ def test(args): model = args.model model = load_model(model) filename = args.filename - contract = args.contract - fname = args.fname - solc = args.solc + contract, fname = parse_target(args.fname) infile = args.input - ext = args.filter ntop = args.ntop if filename is None or contract is None or fname is None or infile is None: logger.error('The test mode requires filename, contract, fname and input parameters.') sys.exit(-1) - irs = encode_contract(filename,solc=solc) + irs = encode_contract(filename, **vars(args)) if len(irs) == 0: sys.exit(-1) y = " ".join(irs[(filename,contract,fname)]) fvector = model.get_sentence_vector(y) - cache = load_and_encode(infile, model, ext=ext, solc=solc) + cache = load_and_encode(infile, **vars(args)) #save_cache("cache.npz", cache) r = dict() diff --git a/utils/similarity/train.py b/utils/similarity/train.py index 679f8b7df..d3039be38 100755 --- a/utils/similarity/train.py +++ b/utils/similarity/train.py @@ -16,22 +16,20 @@ def train(args): try: last_data_train_filename = "last_data_train.txt" model_filename = args.model - solc = args.solc dirname = args.input - ext = args.filter nsamples = args.nsamples if dirname is None: logger.error('The train mode requires the input parameter.') sys.exit(-1) - contracts = load_contracts(dirname, ext=ext, nsamples=nsamples) + contracts = load_contracts(dirname, **vars(args)) logger.info('Saving extracted data into %s', last_data_train_filename) cache = [] with open(last_data_train_filename, 'w') as f: for filename in contracts: #cache[filename] = dict() - for (filename, contract, function), ir in encode_contract(filename,solc).items(): + for (filename, contract, function), ir in encode_contract(filename, **vars(args)).items(): if ir != []: x = " ".join(ir) f.write(x+"\n") From e302598705ca785e4502ffac3bd9c2597b5a3d12 Mon Sep 17 00:00:00 2001 From: rajeevgopalakrishna Date: Fri, 10 May 2019 15:49:00 +0530 Subject: [PATCH 31/55] Isolating slither core/parsing changes required for slither-format. --- slither/core/cfg/node.py | 8 ++++++++ slither/core/declarations/function.py | 13 ++++++++++++- slither/solc_parsing/cfg/node.py | 2 ++ slither/solc_parsing/declarations/function.py | 4 ++++ .../solc_parsing/expressions/expression_parsing.py | 6 +++++- 5 files changed, 31 insertions(+), 2 deletions(-) diff --git a/slither/core/cfg/node.py b/slither/core/cfg/node.py index fe7d90b4a..6d2da977b 100644 --- a/slither/core/cfg/node.py +++ b/slither/core/cfg/node.py @@ -155,6 +155,7 @@ class Node(SourceMapping, ChildFunction): self._library_calls = [] self._low_level_calls = [] self._external_calls_as_expressions = [] + self._internal_calls_as_expressions = [] self._irs = [] self._irs_ssa = [] @@ -368,6 +369,13 @@ class Node(SourceMapping, ChildFunction): """ return self._external_calls_as_expressions + @property + def internal_calls_as_expressions(self): + """ + list(CallExpression): List of internal calls (that dont create a transaction) + """ + return self._internal_calls_as_expressions + @property def calls_as_expression(self): return list(self._expression_calls) diff --git a/slither/core/declarations/function.py b/slither/core/declarations/function.py index 1a99f90e3..fdee9f3aa 100644 --- a/slither/core/declarations/function.py +++ b/slither/core/declarations/function.py @@ -39,8 +39,10 @@ class Function(ChildContract, SourceMapping): self._slithir_variables = set() # slithir Temporary and references variables (but not SSA) self._parameters = [] self._parameters_ssa = [] + self._parameters_src = None self._returns = [] self._returns_ssa = [] + self._returns_src = None self._return_values = None self._return_values_ssa = None self._vars_read = [] @@ -391,6 +393,15 @@ class Function(ChildContract, SourceMapping): return list(self._slithir_variables) + def get_source_var_declaration(self, var): + """ Return the source mapping where the variable is declared + Args: + var (str): variable name + Returns: + (dict): sourceMapping + """ + return next((x.source_mapping for x in self.variables if x.name == var)) + # endregion ################################################################################### ################################################################################### @@ -1071,4 +1082,4 @@ class Function(ChildContract, SourceMapping): def __str__(self): return self._name - # endregion \ No newline at end of file + # endregion diff --git a/slither/solc_parsing/cfg/node.py b/slither/solc_parsing/cfg/node.py index 56e73e32c..1775084f6 100644 --- a/slither/solc_parsing/cfg/node.py +++ b/slither/solc_parsing/cfg/node.py @@ -62,4 +62,6 @@ class NodeSolc(Node): pp = FindCalls(expression) self._expression_calls = pp.result() self._external_calls_as_expressions = [c for c in self.calls_as_expression if not isinstance(c.called, Identifier)] + self._internal_calls_as_expressions = [c for c in self.calls_as_expression if isinstance(c.called, Identifier)] + diff --git a/slither/solc_parsing/declarations/function.py b/slither/solc_parsing/declarations/function.py index d862352ad..0e020b1da 100644 --- a/slither/solc_parsing/declarations/function.py +++ b/slither/solc_parsing/declarations/function.py @@ -835,6 +835,8 @@ class FunctionSolc(Function): def _parse_params(self, params): assert params[self.get_key()] == 'ParameterList' + self.parameters_src = params['src'] + if self.is_compact_ast: params = params['parameters'] else: @@ -860,6 +862,8 @@ class FunctionSolc(Function): assert returns[self.get_key()] == 'ParameterList' + self.returns_src = returns['src'] + if self.is_compact_ast: returns = returns['parameters'] else: diff --git a/slither/solc_parsing/expressions/expression_parsing.py b/slither/solc_parsing/expressions/expression_parsing.py index 2d037ebdb..b9e19a5af 100644 --- a/slither/solc_parsing/expressions/expression_parsing.py +++ b/slither/solc_parsing/expressions/expression_parsing.py @@ -294,7 +294,9 @@ def parse_call(expression, caller_context): if isinstance(called, SuperCallExpression): return SuperCallExpression(called, arguments, type_return) - return CallExpression(called, arguments, type_return) + call_expression = CallExpression(called, arguments, type_return) + call_expression.set_offset(expression['src'], caller_context.slither) + return call_expression def parse_super_name(expression, is_compact_ast): if is_compact_ast: @@ -539,6 +541,7 @@ def parse_expression(expression, caller_context): var = find_variable(value, caller_context, referenced_declaration) identifier = Identifier(var) + identifier.set_offset(expression['src'], caller_context.slither) return identifier elif name == 'IndexAccess': @@ -667,6 +670,7 @@ def parse_expression(expression, caller_context): arguments = [parse_expression(a, caller_context) for a in children[1::]] call = CallExpression(called, arguments, 'Modifier') + call.set_offset(expression['src'], caller_context.slither) return call raise ParsingError('Expression not parsed %s'%name) From d981e9a0a7a57fcd69a51bf31e3d5d5ea7966b01 Mon Sep 17 00:00:00 2001 From: Josselin Date: Fri, 10 May 2019 12:18:03 +0100 Subject: [PATCH 32/55] Improve source_mapping parsing for old solcs --- slither/core/source_mapping/source_mapping.py | 11 +---------- slither/solc_parsing/slitherSolc.py | 8 ++++++++ 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/slither/core/source_mapping/source_mapping.py b/slither/core/source_mapping/source_mapping.py index f63d0278e..22dabca31 100644 --- a/slither/core/source_mapping/source_mapping.py +++ b/slither/core/source_mapping/source_mapping.py @@ -125,16 +125,7 @@ class SourceMapping(Context): @property def source_mapping_str(self): -# def relative_path(path): -# # Remove absolute path for printing -# # Truffle returns absolutePath -# splited_path = path.split(os.sep) -# if 'contracts' in splited_path: -# idx = splited_path.index('contracts') -# return os.sep.join(splited_path[idx-1:]) -# return path - - lines = self.source_mapping['lines'] + lines = self.source_mapping.get('lines', None) if not lines: lines = '' elif len(lines) == 1: diff --git a/slither/solc_parsing/slitherSolc.py b/slither/solc_parsing/slitherSolc.py index 1b3651f6d..eebb99935 100644 --- a/slither/solc_parsing/slitherSolc.py +++ b/slither/solc_parsing/slitherSolc.py @@ -148,6 +148,14 @@ class SlitherSolc(Slither): sourceUnit = re.findall('[0-9]*:[0-9]*:([0-9]*)', data['src']) if len(sourceUnit) == 1: sourceUnit = int(sourceUnit[0]) + if sourceUnit == -1: + # if source unit is not found + # We can still deduce it, by assigning to the last source_code added + # This works only for crytic compile. + # which used --combined-json ast, rather than --ast-json + # As a result -1 is not used as index + if not self.crytic_compile is None: + sourceUnit = len(self.source_code) self._source_units[sourceUnit] = name if os.path.isfile(name) and not name in self.source_code: From 802ab4edb258998d4ec2242c4ce2ab8496b9aa72 Mon Sep 17 00:00:00 2001 From: ggrieco-tob Date: Fri, 10 May 2019 09:24:03 -0300 Subject: [PATCH 33/55] fixes --- utils/similarity/encode.py | 3 +++ utils/similarity/info.py | 6 +++--- utils/similarity/plot.py | 2 +- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/utils/similarity/encode.py b/utils/similarity/encode.py index 13438a137..6c9f4700a 100644 --- a/utils/similarity/encode.py +++ b/utils/similarity/encode.py @@ -22,6 +22,9 @@ slither_logger = logging.getLogger("Slither") slither_logger.setLevel(logging.CRITICAL) def parse_target(target): + if target is None: + return None, None + parts = target.split('.') if len(parts) == 1: return None, parts[0] diff --git a/utils/similarity/info.py b/utils/similarity/info.py index 7cfa0fb67..431852571 100644 --- a/utils/similarity/info.py +++ b/utils/similarity/info.py @@ -40,11 +40,11 @@ def info(args): x = (filename,contract,fname) y = " ".join(irs[x]) - print("Function {} in contract {} is encoded as:".format(fname, contract)) - print(y) + logger.info("Function {} in contract {} is encoded as:".format(fname, contract)) + logger.info(y) if model is not None: fvector = model.get_sentence_vector(y) - print(fvector) + logger.info(fvector) except Exception: logger.error('Error in %s' % args.filename) diff --git a/utils/similarity/plot.py b/utils/similarity/plot.py index 69d359f35..1b4d07e02 100644 --- a/utils/similarity/plot.py +++ b/utils/similarity/plot.py @@ -61,7 +61,7 @@ def plot(args): tdata = pca.fit_transform(data) logger.info('Plotting data..') - plt.figure() + plt.figure(figsize=(20,10)) assert(len(tdata) == len(fs)) for ([x,y],l) in zip(tdata, fs): x = random.gauss(0, 0.01) + x From 42d6e974bff5e6329a92f7b68c8a67c36cf0fd4e Mon Sep 17 00:00:00 2001 From: Josselin Date: Fri, 10 May 2019 13:53:24 +0100 Subject: [PATCH 34/55] Temporary fix for POP function --- slither/slithir/convert.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/slither/slithir/convert.py b/slither/slithir/convert.py index b24bfab68..31b141a57 100644 --- a/slither/slithir/convert.py +++ b/slither/slithir/convert.py @@ -874,6 +874,9 @@ def convert_constant_types(irs): if isinstance(func, StateVariable): types = export_nested_types_from_variable(func) else: + if func is None: + # TODO: add POP instruction + break types = [p.type for p in func.parameters] for idx, arg in enumerate(ir.arguments): t = types[idx] From 089cb4a9e7bd51ddf2fd247858ed363c8c2ca9a5 Mon Sep 17 00:00:00 2001 From: ggrieco-tob Date: Fri, 10 May 2019 11:57:23 -0300 Subject: [PATCH 35/55] fixed test --- scripts/travis_test_simil.sh | 2 +- tests/simil/test_1.txt | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/travis_test_simil.sh b/scripts/travis_test_simil.sh index d520ea748..ccf332800 100755 --- a/scripts/travis_test_simil.sh +++ b/scripts/travis_test_simil.sh @@ -8,7 +8,7 @@ pip3.6 install https://github.com/facebookresearch/fastText/archive/0.2.0.zip ### Test slither-simil DIR_TESTS="tests/simil" -slither-simil info "" --filename $DIR_TESTS/../complex_func.sol --contract Complex --fname complexExternalWrites --solc solc-0.4.25 > test_1.txt 2>&1 +slither-simil info "" --filename $DIR_TESTS/../complex_func.sol --fname Complex.complexExternalWrites --solc solc-0.4.25 > test_1.txt 2>&1 DIFF=$(diff test_1.txt "$DIR_TESTS/test_1.txt") if [ "$DIFF" != "" ] then diff --git a/tests/simil/test_1.txt b/tests/simil/test_1.txt index f722b9880..1c6a7bb7e 100644 --- a/tests/simil/test_1.txt +++ b/tests/simil/test_1.txt @@ -1,2 +1,2 @@ -Function complexExternalWrites in contract Complex is encoded as: -new_contract (local_solc_variable(default)):=(temporary_variable) high_level_call high_level_call high_level_call high_level_call high_level_call new_contract (local_solc_variable(default)):=(temporary_variable) high_level_call new_contract (local_solc_variable(default)):=(temporary_variable) solidity_call(keccak256()) type_conversion(bytes4) low_level_call new_contract (local_solc_variable(default)):=(temporary_variable) solidity_call(keccak256()) type_conversion(bytes4) low_level_call +INFO:Slither-simil:Function complexExternalWrites in contract Complex is encoded as: +INFO:Slither-simil:new_contract (local_solc_variable(default)):=(temporary_variable) high_level_call high_level_call high_level_call high_level_call high_level_call new_contract (local_solc_variable(default)):=(temporary_variable) high_level_call new_contract (local_solc_variable(default)):=(temporary_variable) solidity_call(keccak256()) type_conversion(bytes4) low_level_call new_contract (local_solc_variable(default)):=(temporary_variable) solidity_call(keccak256()) type_conversion(bytes4) low_level_call From 06d70856bd60a539e29ae2e5a2e409a9b18d456f Mon Sep 17 00:00:00 2001 From: ggrieco-tob Date: Fri, 10 May 2019 12:00:22 -0300 Subject: [PATCH 36/55] fix --- utils/similarity/__init__.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/utils/similarity/__init__.py b/utils/similarity/__init__.py index 5a1473b46..e8ce679e9 100644 --- a/utils/similarity/__init__.py +++ b/utils/similarity/__init__.py @@ -4,9 +4,6 @@ import sys try: import fastText except ImportError: - fastText = None - -if fastText is None: print("ERROR: in order to use slither-simil, you need to install fastText 0.2.0:") print("$ pip3 install https://github.com/facebookresearch/fastText/archive/0.2.0.zip --user\n") sys.exit(-1) From 7f39c7721995c66811b7ebb90a86fbba740140ef Mon Sep 17 00:00:00 2001 From: ggrieco-tob Date: Fri, 10 May 2019 12:23:51 -0300 Subject: [PATCH 37/55] improved module loading --- utils/similarity/__init__.py | 10 +--------- utils/similarity/info.py | 2 +- utils/similarity/model.py | 11 +++++++++++ utils/similarity/plot.py | 6 +++--- utils/similarity/test.py | 6 +++--- utils/similarity/train.py | 2 +- 6 files changed, 20 insertions(+), 17 deletions(-) create mode 100644 utils/similarity/model.py diff --git a/utils/similarity/__init__.py b/utils/similarity/__init__.py index e8ce679e9..b31b92c60 100644 --- a/utils/similarity/__init__.py +++ b/utils/similarity/__init__.py @@ -1,9 +1 @@ -# from https://stackoverflow.com/questions/563022/whats-python-good-practice-for-importing-and-offering-optional-features -import sys - -try: - import fastText -except ImportError: - print("ERROR: in order to use slither-simil, you need to install fastText 0.2.0:") - print("$ pip3 install https://github.com/facebookresearch/fastText/archive/0.2.0.zip --user\n") - sys.exit(-1) +from .model import load_model diff --git a/utils/similarity/info.py b/utils/similarity/info.py index 431852571..e250aa991 100644 --- a/utils/similarity/info.py +++ b/utils/similarity/info.py @@ -3,7 +3,7 @@ import sys import os.path import traceback -from fastText import load_model +from .model import load_model from .encode import parse_target, encode_contract logging.basicConfig() diff --git a/utils/similarity/model.py b/utils/similarity/model.py new file mode 100644 index 000000000..5e1549058 --- /dev/null +++ b/utils/similarity/model.py @@ -0,0 +1,11 @@ +import sys + +try: + from fastText import load_model + from fastText import train_unsupervised +except ImportError: + print("ERROR: in order to use slither-simil, you need to install fastText 0.2.0:") + print("$ pip3 install https://github.com/facebookresearch/fastText/archive/0.2.0.zip --user\n") + sys.exit(-1) + + diff --git a/utils/similarity/plot.py b/utils/similarity/plot.py index 1b4d07e02..05d8bf921 100644 --- a/utils/similarity/plot.py +++ b/utils/similarity/plot.py @@ -5,15 +5,15 @@ import operator import numpy as np import random +from .model import load_model +from .encode import load_and_encode, parse_target + try: from sklearn import decomposition import matplotlib.pyplot as plt except ImportError: decomposition = None plt = None - -from fastText import load_model -from .encode import load_and_encode, parse_target logger = logging.getLogger("Slither-simil") diff --git a/utils/similarity/test.py b/utils/similarity/test.py index f821b6448..08542dd0d 100755 --- a/utils/similarity/test.py +++ b/utils/similarity/test.py @@ -5,9 +5,9 @@ import traceback import operator import numpy as np -from fastText import load_model -from .encode import encode_contract, load_and_encode, parse_target -from .cache import save_cache +from .model import load_model +from .encode import encode_contract, load_and_encode, parse_target +from .cache import save_cache from .similarity import similarity logger = logging.getLogger("Slither-simil") diff --git a/utils/similarity/train.py b/utils/similarity/train.py index d3039be38..e810450a6 100755 --- a/utils/similarity/train.py +++ b/utils/similarity/train.py @@ -5,7 +5,7 @@ import traceback import operator import os -from fastText import train_unsupervised +from .model import train_unsupervised from .encode import encode_contract, load_contracts from .cache import save_cache From d3f981699960a90f92b197b78004ce6a6c4105c6 Mon Sep 17 00:00:00 2001 From: ggrieco-tob Date: Fri, 10 May 2019 12:55:43 -0300 Subject: [PATCH 38/55] more fixes --- utils/similarity/__main__.py | 34 +++++++++++++--------------------- utils/similarity/cache.py | 9 ++++++++- utils/similarity/model.py | 2 -- 3 files changed, 21 insertions(+), 24 deletions(-) diff --git a/utils/similarity/__main__.py b/utils/similarity/__main__.py index 8c5d5a142..dc4d9da6a 100755 --- a/utils/similarity/__main__.py +++ b/utils/similarity/__main__.py @@ -16,12 +16,10 @@ from .plot import plot logging.basicConfig() logger = logging.getLogger("Slither-simil") -slither_simil_usage = "USAGE" # TODO modes = ["info", "test", "train", "plot"] def parse_args(): - parser = argparse.ArgumentParser(description='Code similarity detection tool', - usage=slither_simil_usage) + parser = argparse.ArgumentParser(description='Code similarity detection tool') parser.add_argument('mode', help="|".join(modes)) @@ -89,24 +87,18 @@ def main(): default_log = logging.INFO logger.setLevel(default_log) - try: - mode = args.mode - - if mode == "info": - info(args) - elif mode == "train": - train(args) - elif mode == "test": - test(args) - elif mode == "plot": - plot(args) - else: - logger.error('Invalid mode!. It should be one of these: %s' % ", ".join(modes)) - sys.exit(-1) - - except Exception: - logger.error('Error in %s' % args.filename) - logger.error(traceback.format_exc()) + mode = args.mode + + if mode == "info": + info(args) + elif mode == "train": + train(args) + elif mode == "test": + test(args) + elif mode == "plot": + plot(args) + else: + logger.error('Invalid mode!. It should be one of these: %s' % ", ".join(modes)) sys.exit(-1) if __name__ == '__main__': diff --git a/utils/similarity/cache.py b/utils/similarity/cache.py index f5973b4b3..efb748c99 100644 --- a/utils/similarity/cache.py +++ b/utils/similarity/cache.py @@ -1,4 +1,11 @@ -import numpy as np +import sys + +try: + import numpy as np +except ImportError: + print("ERROR: in order to use slither-simil, you need to install numpy") + print("$ pip3 install numpy --user\n") + sys.exit(-1) def load_cache(infile, nsamples=None): cache = dict() diff --git a/utils/similarity/model.py b/utils/similarity/model.py index 5e1549058..4f3412113 100644 --- a/utils/similarity/model.py +++ b/utils/similarity/model.py @@ -7,5 +7,3 @@ except ImportError: print("ERROR: in order to use slither-simil, you need to install fastText 0.2.0:") print("$ pip3 install https://github.com/facebookresearch/fastText/archive/0.2.0.zip --user\n") sys.exit(-1) - - From 6e2194bea4065839218e8e7712f7da0c33db556d Mon Sep 17 00:00:00 2001 From: Josselin Date: Fri, 10 May 2019 17:31:06 +0100 Subject: [PATCH 39/55] Json modifications: - results: -> results/detectors: - Add type_specific_fields dictionary to hold all the type specific items (parent/signature/...) --- slither/__main__.py | 20 +- slither/detectors/abstract_detector.py | 116 +- .../arbitrary_send-0.5.1.arbitrary-send.json | 634 +-- .../arbitrary_send.arbitrary-send.json | 634 +-- tests/expected_json/backdoor.backdoor.json | 87 +- tests/expected_json/backdoor.suicidal.json | 87 +- ...onst_state_variables.constable-states.json | 594 +-- .../constant-0.5.1.constant-function.json | 111 +- .../constant.constant-function.json | 567 +-- ..._delegatecall.controlled-delegatecall.json | 508 +- ...deprecated_calls.deprecated-standards.json | 1164 ++--- .../erc20_indexed.erc20-indexed.json | 378 +- .../external_function.external-function.json | 408 +- ...external_function_2.external-function.json | 2 +- ...incorrect_equality.incorrect-equality.json | 4252 +++++++++-------- ...rrect_erc20_interface.erc20-interface.json | 504 +- ...ect_erc721_interface.erc721-interface.json | 880 ++-- ...line_assembly_contract-0.5.1.assembly.json | 248 +- .../inline_assembly_contract.assembly.json | 248 +- ...nline_assembly_library-0.5.1.assembly.json | 710 +-- .../inline_assembly_library.assembly.json | 710 +-- .../locked_ether-0.5.1.locked-ether.json | 119 +- .../locked_ether.locked-ether.json | 119 +- .../low_level_calls.low-level-calls.json | 180 +- .../multiple_calls_in_loop.calls-loop.json | 143 +- .../naming_convention.naming-convention.json | 1767 +++---- .../old_solc.sol.json.solc-version.json | 64 +- .../old_solc.sol.json.solc-version.txt | 1 + tests/expected_json/pragma.0.4.24.pragma.json | 116 +- .../reentrancy-0.5.1.reentrancy-eth.json | 1184 ++--- .../reentrancy.reentrancy-eth.json | 1384 +++--- .../right_to_left_override.rtlo.json | 20 +- ...shadowing_abstract.shadowing-abstract.json | 138 +- ...ing_builtin_symbols.shadowing-builtin.json | 1212 ++--- ...dowing_local_variable.shadowing-local.json | 1056 ++-- ...dowing_state_variable.shadowing-state.json | 162 +- .../solc_version_incorrect.solc-version.json | 140 +- tests/expected_json/timestamp.timestamp.json | 690 +-- .../too_many_digits.too-many-digits.json | 1060 ++-- .../tx_origin-0.5.1.tx-origin.json | 312 +- tests/expected_json/tx_origin.tx-origin.json | 312 +- ...ked_lowlevel-0.5.1.unchecked-lowlevel.json | 204 +- ...unchecked_lowlevel.unchecked-lowlevel.json | 200 +- .../unchecked_send-0.5.1.unchecked-send.json | 232 +- ...initialized-0.5.1.uninitialized-state.json | 702 +-- .../uninitialized.uninitialized-state.json | 702 +-- ...ed_local_variable.uninitialized-local.json | 200 +- ...storage_pointer.uninitialized-storage.json | 222 +- .../unused_return.unused-return.json | 490 +- .../unused_state.unused-state.json | 470 +- 50 files changed, 13659 insertions(+), 12804 deletions(-) diff --git a/slither/__main__.py b/slither/__main__.py index d96d92a60..5a0563fa3 100644 --- a/slither/__main__.py +++ b/slither/__main__.py @@ -100,16 +100,26 @@ def process_files(filenames, args, detector_classes, printer_classes): ################################################################################### -def wrap_json_stdout(success, error_message, results=None): +def wrap_json_detectors_results(success, error_message, results=None): + """ + Wrap the detector results. + :param success: + :param error_message: + :param results: + :return: + """ + results_json = {} + if results: + results_json['detectors'] = results return { "success": success, "error": error_message, - "results": results + "results": results_json } def output_json(results, filename): - json_result = wrap_json_stdout(True, None, results) + json_result = wrap_json_detectors_results(True, None, results) if filename is None: # Write json to console print(json.dumps(json_result)) @@ -594,7 +604,7 @@ def main_impl(all_detector_classes, all_printer_classes): except SlitherException as se: # Output our error accordingly, via JSON or logging. if stdout_json: - print(json.dumps(wrap_json_stdout(False, str(se), []))) + print(json.dumps(wrap_json_detectors_results(False, str(se), []))) else: logging.error(red('Error:')) logging.error(red(se)) @@ -604,7 +614,7 @@ def main_impl(all_detector_classes, all_printer_classes): except Exception: # Output our error accordingly, via JSON or logging. if stdout_json: - print(json.dumps(wrap_json_stdout(False, traceback.format_exc(), []))) + print(json.dumps(wrap_json_detectors_results(False, traceback.format_exc(), []))) else: logging.error('Error in %s' % args.filename) logging.error(traceback.format_exc()) diff --git a/slither/detectors/abstract_detector.py b/slither/detectors/abstract_detector.py index 28620c396..df50a0e4d 100644 --- a/slither/detectors/abstract_detector.py +++ b/slither/detectors/abstract_detector.py @@ -146,27 +146,42 @@ class AbstractDetector(metaclass=abc.ABCMeta): return d @staticmethod - def _create_base_element(type, name, source_mapping, additional_fields={}): + def _create_base_element(type, name, source_mapping, type_specific_fields={}, additional_fields={}): element = {'type': type, 'name': name, 'source_mapping': source_mapping} + if type_specific_fields: + element['type_specific_fields'] = type_specific_fields if additional_fields: element['additional_fields'] = additional_fields return element + @staticmethod + def _create_parent_element(element): + from slither.core.children.child_contract import ChildContract + from slither.core.children.child_function import ChildFunction + if isinstance(element, ChildContract): + if element.contract: + contract = {'elements': []} + AbstractDetector.add_contract_to_json(element.contract, contract) + return contract['elements'][0] + elif isinstance(element, ChildFunction): + if element.function: + function = {'elements': []} + AbstractDetector.add_function_to_json(element.function, function) + return function['elements'][0] + return None + @staticmethod def add_variable_to_json(variable, d, additional_fields={}): - from slither.core.variables.state_variable import StateVariable - from slither.core.variables.local_variable import LocalVariable - element = AbstractDetector._create_base_element('variable', variable.name, variable.source_mapping, additional_fields) - if isinstance(variable, StateVariable): - contract = {'elements': []} - AbstractDetector.add_contract_to_json(variable.contract, contract) - element['contract'] = contract['elements'][0] - elif isinstance(variable, LocalVariable): - function = {'elements': []} - AbstractDetector.add_function_to_json(variable.function, function) - element['function'] = function['elements'][0] + type_specific_fields = { + 'parent': AbstractDetector._create_parent_element(variable) + } + element = AbstractDetector._create_base_element('variable', + variable.name, + variable.source_mapping, + type_specific_fields, + additional_fields) d['elements'].append(element) @staticmethod @@ -176,15 +191,24 @@ class AbstractDetector(metaclass=abc.ABCMeta): @staticmethod def add_contract_to_json(contract, d, additional_fields={}): - element = AbstractDetector._create_base_element('contract', contract.name, contract.source_mapping, additional_fields) + element = AbstractDetector._create_base_element('contract', + contract.name, + contract.source_mapping, + {}, + additional_fields) d['elements'].append(element) @staticmethod def add_function_to_json(function, d, additional_fields={}): - element = AbstractDetector._create_base_element('function', function.name, function.source_mapping, additional_fields) - contract = {'elements':[]} - AbstractDetector.add_contract_to_json(function.contract, contract) - element['contract'] = contract['elements'][0] + type_specific_fields = { + 'parent': AbstractDetector._create_parent_element(function), + 'signature': function.full_name + } + element = AbstractDetector._create_base_element('function', + function.name, + function.source_mapping, + type_specific_fields, + additional_fields) d['elements'].append(element) @staticmethod @@ -194,36 +218,53 @@ class AbstractDetector(metaclass=abc.ABCMeta): @staticmethod def add_enum_to_json(enum, d, additional_fields={}): - element = AbstractDetector._create_base_element('enum', enum.name, enum.source_mapping, additional_fields) - contract = {'elements': []} - AbstractDetector.add_contract_to_json(enum.contract, contract) - element['contract'] = contract['elements'][0] + type_specific_fields = { + 'parent': AbstractDetector._create_parent_element(enum) + } + element = AbstractDetector._create_base_element('enum', + enum.name, + enum.source_mapping, + type_specific_fields, + additional_fields) d['elements'].append(element) @staticmethod def add_struct_to_json(struct, d, additional_fields={}): - element = AbstractDetector._create_base_element('struct', struct.name, struct.source_mapping, additional_fields) - contract = {'elements': []} - AbstractDetector.add_contract_to_json(struct.contract, contract) - element['contract'] = contract['elements'][0] + type_specific_fields = { + 'parent': AbstractDetector._create_parent_element(struct) + } + element = AbstractDetector._create_base_element('struct', + struct.name, + struct.source_mapping, + type_specific_fields, + additional_fields) d['elements'].append(element) @staticmethod def add_event_to_json(event, d, additional_fields={}): - element = AbstractDetector._create_base_element('event', event.name, event.source_mapping, additional_fields) - contract = {'elements':[]} - AbstractDetector.add_contract_to_json(event.contract, contract) - element['contract'] = contract['elements'][0] + type_specific_fields = { + 'parent': AbstractDetector._create_parent_element(event), + 'signature': event.full_name + } + element = AbstractDetector._create_base_element('event', + event.name, + event.source_mapping, + type_specific_fields, + additional_fields) + d['elements'].append(element) @staticmethod def add_node_to_json(node, d, additional_fields={}): + type_specific_fields = { + 'parent': AbstractDetector._create_parent_element(node), + } node_name = str(node.expression) if node.expression else "" - element = AbstractDetector._create_base_element('node', node_name, node.source_mapping, additional_fields) - if node.function: - function = {'elements': []} - AbstractDetector.add_function_to_json(node.function, function) - element['function'] = function['elements'][0] + element = AbstractDetector._create_base_element('node', + node_name, + node.source_mapping, + type_specific_fields, + additional_fields) d['elements'].append(element) @staticmethod @@ -233,10 +274,13 @@ class AbstractDetector(metaclass=abc.ABCMeta): @staticmethod def add_pragma_to_json(pragma, d, additional_fields={}): - + type_specific_fields = { + 'directive': pragma.directive + } element = AbstractDetector._create_base_element('pragma', pragma.version, pragma.source_mapping, + type_specific_fields, additional_fields) - element['directive'] = pragma.directive + d['elements'].append(element) diff --git a/tests/expected_json/arbitrary_send-0.5.1.arbitrary-send.json b/tests/expected_json/arbitrary_send-0.5.1.arbitrary-send.json index 83acbb837..28aee86f5 100644 --- a/tests/expected_json/arbitrary_send-0.5.1.arbitrary-send.json +++ b/tests/expected_json/arbitrary_send-0.5.1.arbitrary-send.json @@ -1,106 +1,15 @@ { "success": true, "error": null, - "results": [ - { - "check": "arbitrary-send", - "impact": "High", - "confidence": "Medium", - "description": "Test.direct (tests/arbitrary_send-0.5.1.sol#11-13) sends eth to arbitrary user\n\tDangerous calls:\n\t- msg.sender.send(address(this).balance) (tests/arbitrary_send-0.5.1.sol#12)\n", - "elements": [ - { - "type": "function", - "name": "direct", - "source_mapping": { - "start": 162, - "length": 79, - "filename_used": "/home/travis/build/crytic/slither/tests/arbitrary_send-0.5.1.sol", - "filename_relative": "tests/arbitrary_send-0.5.1.sol", - "filename_absolute": "/home/travis/build/crytic/slither/tests/arbitrary_send-0.5.1.sol", - "filename_short": "tests/arbitrary_send-0.5.1.sol", - "lines": [ - 11, - 12, - 13 - ], - "starting_column": 5, - "ending_column": 6 - }, - "contract": { - "type": "contract", - "name": "Test", - "source_mapping": { - "start": 0, - "length": 884, - "filename_used": "/home/travis/build/crytic/slither/tests/arbitrary_send-0.5.1.sol", - "filename_relative": "tests/arbitrary_send-0.5.1.sol", - "filename_absolute": "/home/travis/build/crytic/slither/tests/arbitrary_send-0.5.1.sol", - "filename_short": "tests/arbitrary_send-0.5.1.sol", - "lines": [ - 1, - 2, - 3, - 4, - 5, - 6, - 7, - 8, - 9, - 10, - 11, - 12, - 13, - 14, - 15, - 16, - 17, - 18, - 19, - 20, - 21, - 22, - 23, - 24, - 25, - 26, - 27, - 28, - 29, - 30, - 31, - 32, - 33, - 34, - 35, - 36, - 37, - 38, - 39, - 40, - 41 - ], - "starting_column": 1, - "ending_column": 2 - } - } - }, - { - "type": "node", - "name": "msg.sender.send(address(this).balance)", - "source_mapping": { - "start": 196, - "length": 38, - "filename_used": "/home/travis/build/crytic/slither/tests/arbitrary_send-0.5.1.sol", - "filename_relative": "tests/arbitrary_send-0.5.1.sol", - "filename_absolute": "/home/travis/build/crytic/slither/tests/arbitrary_send-0.5.1.sol", - "filename_short": "tests/arbitrary_send-0.5.1.sol", - "lines": [ - 12 - ], - "starting_column": 9, - "ending_column": 47 - }, - "function": { + "results": { + "detectors": [ + { + "check": "arbitrary-send", + "impact": "High", + "confidence": "Medium", + "description": "Test.direct (tests/arbitrary_send-0.5.1.sol#11-13) sends eth to arbitrary user\n\tDangerous calls:\n\t- msg.sender.send(address(this).balance) (tests/arbitrary_send-0.5.1.sol#12)\n", + "elements": [ + { "type": "function", "name": "direct", "source_mapping": { @@ -118,166 +27,174 @@ "starting_column": 5, "ending_column": 6 }, - "contract": { - "type": "contract", - "name": "Test", - "source_mapping": { - "start": 0, - "length": 884, - "filename_used": "/home/travis/build/crytic/slither/tests/arbitrary_send-0.5.1.sol", - "filename_relative": "tests/arbitrary_send-0.5.1.sol", - "filename_absolute": "/home/travis/build/crytic/slither/tests/arbitrary_send-0.5.1.sol", - "filename_short": "tests/arbitrary_send-0.5.1.sol", - "lines": [ - 1, - 2, - 3, - 4, - 5, - 6, - 7, - 8, - 9, - 10, - 11, - 12, - 13, - 14, - 15, - 16, - 17, - 18, - 19, - 20, - 21, - 22, - 23, - 24, - 25, - 26, - 27, - 28, - 29, - 30, - 31, - 32, - 33, - 34, - 35, - 36, - 37, - 38, - 39, - 40, - 41 - ], - "starting_column": 1, - "ending_column": 2 - } + "type_specific_fields": { + "parent": { + "type": "contract", + "name": "Test", + "source_mapping": { + "start": 0, + "length": 884, + "filename_used": "/home/travis/build/crytic/slither/tests/arbitrary_send-0.5.1.sol", + "filename_relative": "tests/arbitrary_send-0.5.1.sol", + "filename_absolute": "/home/travis/build/crytic/slither/tests/arbitrary_send-0.5.1.sol", + "filename_short": "tests/arbitrary_send-0.5.1.sol", + "lines": [ + 1, + 2, + 3, + 4, + 5, + 6, + 7, + 8, + 9, + 10, + 11, + 12, + 13, + 14, + 15, + 16, + 17, + 18, + 19, + 20, + 21, + 22, + 23, + 24, + 25, + 26, + 27, + 28, + 29, + 30, + 31, + 32, + 33, + 34, + 35, + 36, + 37, + 38, + 39, + 40, + 41 + ], + "starting_column": 1, + "ending_column": 2 + } + }, + "signature": "direct()" } - } - } - ] - }, - { - "check": "arbitrary-send", - "impact": "High", - "confidence": "Medium", - "description": "Test.indirect (tests/arbitrary_send-0.5.1.sol#19-21) sends eth to arbitrary user\n\tDangerous calls:\n\t- destination.send(address(this).balance) (tests/arbitrary_send-0.5.1.sol#20)\n", - "elements": [ - { - "type": "function", - "name": "indirect", - "source_mapping": { - "start": 316, - "length": 82, - "filename_used": "/home/travis/build/crytic/slither/tests/arbitrary_send-0.5.1.sol", - "filename_relative": "tests/arbitrary_send-0.5.1.sol", - "filename_absolute": "/home/travis/build/crytic/slither/tests/arbitrary_send-0.5.1.sol", - "filename_short": "tests/arbitrary_send-0.5.1.sol", - "lines": [ - 19, - 20, - 21 - ], - "starting_column": 5, - "ending_column": 6 }, - "contract": { - "type": "contract", - "name": "Test", + { + "type": "node", + "name": "msg.sender.send(address(this).balance)", "source_mapping": { - "start": 0, - "length": 884, + "start": 196, + "length": 38, "filename_used": "/home/travis/build/crytic/slither/tests/arbitrary_send-0.5.1.sol", "filename_relative": "tests/arbitrary_send-0.5.1.sol", "filename_absolute": "/home/travis/build/crytic/slither/tests/arbitrary_send-0.5.1.sol", "filename_short": "tests/arbitrary_send-0.5.1.sol", "lines": [ - 1, - 2, - 3, - 4, - 5, - 6, - 7, - 8, - 9, - 10, - 11, - 12, - 13, - 14, - 15, - 16, - 17, - 18, - 19, - 20, - 21, - 22, - 23, - 24, - 25, - 26, - 27, - 28, - 29, - 30, - 31, - 32, - 33, - 34, - 35, - 36, - 37, - 38, - 39, - 40, - 41 + 12 ], - "starting_column": 1, - "ending_column": 2 + "starting_column": 9, + "ending_column": 47 + }, + "type_specific_fields": { + "parent": { + "type": "function", + "name": "direct", + "source_mapping": { + "start": 162, + "length": 79, + "filename_used": "/home/travis/build/crytic/slither/tests/arbitrary_send-0.5.1.sol", + "filename_relative": "tests/arbitrary_send-0.5.1.sol", + "filename_absolute": "/home/travis/build/crytic/slither/tests/arbitrary_send-0.5.1.sol", + "filename_short": "tests/arbitrary_send-0.5.1.sol", + "lines": [ + 11, + 12, + 13 + ], + "starting_column": 5, + "ending_column": 6 + }, + "type_specific_fields": { + "parent": { + "type": "contract", + "name": "Test", + "source_mapping": { + "start": 0, + "length": 884, + "filename_used": "/home/travis/build/crytic/slither/tests/arbitrary_send-0.5.1.sol", + "filename_relative": "tests/arbitrary_send-0.5.1.sol", + "filename_absolute": "/home/travis/build/crytic/slither/tests/arbitrary_send-0.5.1.sol", + "filename_short": "tests/arbitrary_send-0.5.1.sol", + "lines": [ + 1, + 2, + 3, + 4, + 5, + 6, + 7, + 8, + 9, + 10, + 11, + 12, + 13, + 14, + 15, + 16, + 17, + 18, + 19, + 20, + 21, + 22, + 23, + 24, + 25, + 26, + 27, + 28, + 29, + 30, + 31, + 32, + 33, + 34, + 35, + 36, + 37, + 38, + 39, + 40, + 41 + ], + "starting_column": 1, + "ending_column": 2 + } + }, + "signature": "direct()" + } + } } } - }, - { - "type": "node", - "name": "destination.send(address(this).balance)", - "source_mapping": { - "start": 352, - "length": 39, - "filename_used": "/home/travis/build/crytic/slither/tests/arbitrary_send-0.5.1.sol", - "filename_relative": "tests/arbitrary_send-0.5.1.sol", - "filename_absolute": "/home/travis/build/crytic/slither/tests/arbitrary_send-0.5.1.sol", - "filename_short": "tests/arbitrary_send-0.5.1.sol", - "lines": [ - 20 - ], - "starting_column": 9, - "ending_column": 48 - }, - "function": { + ] + }, + { + "check": "arbitrary-send", + "impact": "High", + "confidence": "Medium", + "description": "Test.indirect (tests/arbitrary_send-0.5.1.sol#19-21) sends eth to arbitrary user\n\tDangerous calls:\n\t- destination.send(address(this).balance) (tests/arbitrary_send-0.5.1.sol#20)\n", + "elements": [ + { "type": "function", "name": "indirect", "source_mapping": { @@ -295,66 +212,167 @@ "starting_column": 5, "ending_column": 6 }, - "contract": { - "type": "contract", - "name": "Test", - "source_mapping": { - "start": 0, - "length": 884, - "filename_used": "/home/travis/build/crytic/slither/tests/arbitrary_send-0.5.1.sol", - "filename_relative": "tests/arbitrary_send-0.5.1.sol", - "filename_absolute": "/home/travis/build/crytic/slither/tests/arbitrary_send-0.5.1.sol", - "filename_short": "tests/arbitrary_send-0.5.1.sol", - "lines": [ - 1, - 2, - 3, - 4, - 5, - 6, - 7, - 8, - 9, - 10, - 11, - 12, - 13, - 14, - 15, - 16, - 17, - 18, - 19, - 20, - 21, - 22, - 23, - 24, - 25, - 26, - 27, - 28, - 29, - 30, - 31, - 32, - 33, - 34, - 35, - 36, - 37, - 38, - 39, - 40, - 41 - ], - "starting_column": 1, - "ending_column": 2 + "type_specific_fields": { + "parent": { + "type": "contract", + "name": "Test", + "source_mapping": { + "start": 0, + "length": 884, + "filename_used": "/home/travis/build/crytic/slither/tests/arbitrary_send-0.5.1.sol", + "filename_relative": "tests/arbitrary_send-0.5.1.sol", + "filename_absolute": "/home/travis/build/crytic/slither/tests/arbitrary_send-0.5.1.sol", + "filename_short": "tests/arbitrary_send-0.5.1.sol", + "lines": [ + 1, + 2, + 3, + 4, + 5, + 6, + 7, + 8, + 9, + 10, + 11, + 12, + 13, + 14, + 15, + 16, + 17, + 18, + 19, + 20, + 21, + 22, + 23, + 24, + 25, + 26, + 27, + 28, + 29, + 30, + 31, + 32, + 33, + 34, + 35, + 36, + 37, + 38, + 39, + 40, + 41 + ], + "starting_column": 1, + "ending_column": 2 + } + }, + "signature": "indirect()" + } + }, + { + "type": "node", + "name": "destination.send(address(this).balance)", + "source_mapping": { + "start": 352, + "length": 39, + "filename_used": "/home/travis/build/crytic/slither/tests/arbitrary_send-0.5.1.sol", + "filename_relative": "tests/arbitrary_send-0.5.1.sol", + "filename_absolute": "/home/travis/build/crytic/slither/tests/arbitrary_send-0.5.1.sol", + "filename_short": "tests/arbitrary_send-0.5.1.sol", + "lines": [ + 20 + ], + "starting_column": 9, + "ending_column": 48 + }, + "type_specific_fields": { + "parent": { + "type": "function", + "name": "indirect", + "source_mapping": { + "start": 316, + "length": 82, + "filename_used": "/home/travis/build/crytic/slither/tests/arbitrary_send-0.5.1.sol", + "filename_relative": "tests/arbitrary_send-0.5.1.sol", + "filename_absolute": "/home/travis/build/crytic/slither/tests/arbitrary_send-0.5.1.sol", + "filename_short": "tests/arbitrary_send-0.5.1.sol", + "lines": [ + 19, + 20, + 21 + ], + "starting_column": 5, + "ending_column": 6 + }, + "type_specific_fields": { + "parent": { + "type": "contract", + "name": "Test", + "source_mapping": { + "start": 0, + "length": 884, + "filename_used": "/home/travis/build/crytic/slither/tests/arbitrary_send-0.5.1.sol", + "filename_relative": "tests/arbitrary_send-0.5.1.sol", + "filename_absolute": "/home/travis/build/crytic/slither/tests/arbitrary_send-0.5.1.sol", + "filename_short": "tests/arbitrary_send-0.5.1.sol", + "lines": [ + 1, + 2, + 3, + 4, + 5, + 6, + 7, + 8, + 9, + 10, + 11, + 12, + 13, + 14, + 15, + 16, + 17, + 18, + 19, + 20, + 21, + 22, + 23, + 24, + 25, + 26, + 27, + 28, + 29, + 30, + 31, + 32, + 33, + 34, + 35, + 36, + 37, + 38, + 39, + 40, + 41 + ], + "starting_column": 1, + "ending_column": 2 + } + }, + "signature": "indirect()" + } } } } - } - ] - } - ] + ] + } + ] + } } \ No newline at end of file diff --git a/tests/expected_json/arbitrary_send.arbitrary-send.json b/tests/expected_json/arbitrary_send.arbitrary-send.json index 6deaa7f8f..30f75bec4 100644 --- a/tests/expected_json/arbitrary_send.arbitrary-send.json +++ b/tests/expected_json/arbitrary_send.arbitrary-send.json @@ -1,106 +1,15 @@ { "success": true, "error": null, - "results": [ - { - "check": "arbitrary-send", - "impact": "High", - "confidence": "Medium", - "description": "Test.direct (tests/arbitrary_send.sol#11-13) sends eth to arbitrary user\n\tDangerous calls:\n\t- msg.sender.send(address(this).balance) (tests/arbitrary_send.sol#12)\n", - "elements": [ - { - "type": "function", - "name": "direct", - "source_mapping": { - "start": 147, - "length": 79, - "filename_used": "/home/travis/build/crytic/slither/tests/arbitrary_send.sol", - "filename_relative": "tests/arbitrary_send.sol", - "filename_absolute": "/home/travis/build/crytic/slither/tests/arbitrary_send.sol", - "filename_short": "tests/arbitrary_send.sol", - "lines": [ - 11, - 12, - 13 - ], - "starting_column": 5, - "ending_column": 6 - }, - "contract": { - "type": "contract", - "name": "Test", - "source_mapping": { - "start": 0, - "length": 869, - "filename_used": "/home/travis/build/crytic/slither/tests/arbitrary_send.sol", - "filename_relative": "tests/arbitrary_send.sol", - "filename_absolute": "/home/travis/build/crytic/slither/tests/arbitrary_send.sol", - "filename_short": "tests/arbitrary_send.sol", - "lines": [ - 1, - 2, - 3, - 4, - 5, - 6, - 7, - 8, - 9, - 10, - 11, - 12, - 13, - 14, - 15, - 16, - 17, - 18, - 19, - 20, - 21, - 22, - 23, - 24, - 25, - 26, - 27, - 28, - 29, - 30, - 31, - 32, - 33, - 34, - 35, - 36, - 37, - 38, - 39, - 40, - 41 - ], - "starting_column": 1, - "ending_column": 2 - } - } - }, - { - "type": "node", - "name": "msg.sender.send(address(this).balance)", - "source_mapping": { - "start": 181, - "length": 38, - "filename_used": "/home/travis/build/crytic/slither/tests/arbitrary_send.sol", - "filename_relative": "tests/arbitrary_send.sol", - "filename_absolute": "/home/travis/build/crytic/slither/tests/arbitrary_send.sol", - "filename_short": "tests/arbitrary_send.sol", - "lines": [ - 12 - ], - "starting_column": 9, - "ending_column": 47 - }, - "function": { + "results": { + "detectors": [ + { + "check": "arbitrary-send", + "impact": "High", + "confidence": "Medium", + "description": "Test.direct (tests/arbitrary_send.sol#11-13) sends eth to arbitrary user\n\tDangerous calls:\n\t- msg.sender.send(address(this).balance) (tests/arbitrary_send.sol#12)\n", + "elements": [ + { "type": "function", "name": "direct", "source_mapping": { @@ -118,166 +27,174 @@ "starting_column": 5, "ending_column": 6 }, - "contract": { - "type": "contract", - "name": "Test", - "source_mapping": { - "start": 0, - "length": 869, - "filename_used": "/home/travis/build/crytic/slither/tests/arbitrary_send.sol", - "filename_relative": "tests/arbitrary_send.sol", - "filename_absolute": "/home/travis/build/crytic/slither/tests/arbitrary_send.sol", - "filename_short": "tests/arbitrary_send.sol", - "lines": [ - 1, - 2, - 3, - 4, - 5, - 6, - 7, - 8, - 9, - 10, - 11, - 12, - 13, - 14, - 15, - 16, - 17, - 18, - 19, - 20, - 21, - 22, - 23, - 24, - 25, - 26, - 27, - 28, - 29, - 30, - 31, - 32, - 33, - 34, - 35, - 36, - 37, - 38, - 39, - 40, - 41 - ], - "starting_column": 1, - "ending_column": 2 - } + "type_specific_fields": { + "parent": { + "type": "contract", + "name": "Test", + "source_mapping": { + "start": 0, + "length": 869, + "filename_used": "/home/travis/build/crytic/slither/tests/arbitrary_send.sol", + "filename_relative": "tests/arbitrary_send.sol", + "filename_absolute": "/home/travis/build/crytic/slither/tests/arbitrary_send.sol", + "filename_short": "tests/arbitrary_send.sol", + "lines": [ + 1, + 2, + 3, + 4, + 5, + 6, + 7, + 8, + 9, + 10, + 11, + 12, + 13, + 14, + 15, + 16, + 17, + 18, + 19, + 20, + 21, + 22, + 23, + 24, + 25, + 26, + 27, + 28, + 29, + 30, + 31, + 32, + 33, + 34, + 35, + 36, + 37, + 38, + 39, + 40, + 41 + ], + "starting_column": 1, + "ending_column": 2 + } + }, + "signature": "direct()" } - } - } - ] - }, - { - "check": "arbitrary-send", - "impact": "High", - "confidence": "Medium", - "description": "Test.indirect (tests/arbitrary_send.sol#19-21) sends eth to arbitrary user\n\tDangerous calls:\n\t- destination.send(address(this).balance) (tests/arbitrary_send.sol#20)\n", - "elements": [ - { - "type": "function", - "name": "indirect", - "source_mapping": { - "start": 301, - "length": 82, - "filename_used": "/home/travis/build/crytic/slither/tests/arbitrary_send.sol", - "filename_relative": "tests/arbitrary_send.sol", - "filename_absolute": "/home/travis/build/crytic/slither/tests/arbitrary_send.sol", - "filename_short": "tests/arbitrary_send.sol", - "lines": [ - 19, - 20, - 21 - ], - "starting_column": 5, - "ending_column": 6 }, - "contract": { - "type": "contract", - "name": "Test", + { + "type": "node", + "name": "msg.sender.send(address(this).balance)", "source_mapping": { - "start": 0, - "length": 869, + "start": 181, + "length": 38, "filename_used": "/home/travis/build/crytic/slither/tests/arbitrary_send.sol", "filename_relative": "tests/arbitrary_send.sol", "filename_absolute": "/home/travis/build/crytic/slither/tests/arbitrary_send.sol", "filename_short": "tests/arbitrary_send.sol", "lines": [ - 1, - 2, - 3, - 4, - 5, - 6, - 7, - 8, - 9, - 10, - 11, - 12, - 13, - 14, - 15, - 16, - 17, - 18, - 19, - 20, - 21, - 22, - 23, - 24, - 25, - 26, - 27, - 28, - 29, - 30, - 31, - 32, - 33, - 34, - 35, - 36, - 37, - 38, - 39, - 40, - 41 + 12 ], - "starting_column": 1, - "ending_column": 2 + "starting_column": 9, + "ending_column": 47 + }, + "type_specific_fields": { + "parent": { + "type": "function", + "name": "direct", + "source_mapping": { + "start": 147, + "length": 79, + "filename_used": "/home/travis/build/crytic/slither/tests/arbitrary_send.sol", + "filename_relative": "tests/arbitrary_send.sol", + "filename_absolute": "/home/travis/build/crytic/slither/tests/arbitrary_send.sol", + "filename_short": "tests/arbitrary_send.sol", + "lines": [ + 11, + 12, + 13 + ], + "starting_column": 5, + "ending_column": 6 + }, + "type_specific_fields": { + "parent": { + "type": "contract", + "name": "Test", + "source_mapping": { + "start": 0, + "length": 869, + "filename_used": "/home/travis/build/crytic/slither/tests/arbitrary_send.sol", + "filename_relative": "tests/arbitrary_send.sol", + "filename_absolute": "/home/travis/build/crytic/slither/tests/arbitrary_send.sol", + "filename_short": "tests/arbitrary_send.sol", + "lines": [ + 1, + 2, + 3, + 4, + 5, + 6, + 7, + 8, + 9, + 10, + 11, + 12, + 13, + 14, + 15, + 16, + 17, + 18, + 19, + 20, + 21, + 22, + 23, + 24, + 25, + 26, + 27, + 28, + 29, + 30, + 31, + 32, + 33, + 34, + 35, + 36, + 37, + 38, + 39, + 40, + 41 + ], + "starting_column": 1, + "ending_column": 2 + } + }, + "signature": "direct()" + } + } } } - }, - { - "type": "node", - "name": "destination.send(address(this).balance)", - "source_mapping": { - "start": 337, - "length": 39, - "filename_used": "/home/travis/build/crytic/slither/tests/arbitrary_send.sol", - "filename_relative": "tests/arbitrary_send.sol", - "filename_absolute": "/home/travis/build/crytic/slither/tests/arbitrary_send.sol", - "filename_short": "tests/arbitrary_send.sol", - "lines": [ - 20 - ], - "starting_column": 9, - "ending_column": 48 - }, - "function": { + ] + }, + { + "check": "arbitrary-send", + "impact": "High", + "confidence": "Medium", + "description": "Test.indirect (tests/arbitrary_send.sol#19-21) sends eth to arbitrary user\n\tDangerous calls:\n\t- destination.send(address(this).balance) (tests/arbitrary_send.sol#20)\n", + "elements": [ + { "type": "function", "name": "indirect", "source_mapping": { @@ -295,66 +212,167 @@ "starting_column": 5, "ending_column": 6 }, - "contract": { - "type": "contract", - "name": "Test", - "source_mapping": { - "start": 0, - "length": 869, - "filename_used": "/home/travis/build/crytic/slither/tests/arbitrary_send.sol", - "filename_relative": "tests/arbitrary_send.sol", - "filename_absolute": "/home/travis/build/crytic/slither/tests/arbitrary_send.sol", - "filename_short": "tests/arbitrary_send.sol", - "lines": [ - 1, - 2, - 3, - 4, - 5, - 6, - 7, - 8, - 9, - 10, - 11, - 12, - 13, - 14, - 15, - 16, - 17, - 18, - 19, - 20, - 21, - 22, - 23, - 24, - 25, - 26, - 27, - 28, - 29, - 30, - 31, - 32, - 33, - 34, - 35, - 36, - 37, - 38, - 39, - 40, - 41 - ], - "starting_column": 1, - "ending_column": 2 + "type_specific_fields": { + "parent": { + "type": "contract", + "name": "Test", + "source_mapping": { + "start": 0, + "length": 869, + "filename_used": "/home/travis/build/crytic/slither/tests/arbitrary_send.sol", + "filename_relative": "tests/arbitrary_send.sol", + "filename_absolute": "/home/travis/build/crytic/slither/tests/arbitrary_send.sol", + "filename_short": "tests/arbitrary_send.sol", + "lines": [ + 1, + 2, + 3, + 4, + 5, + 6, + 7, + 8, + 9, + 10, + 11, + 12, + 13, + 14, + 15, + 16, + 17, + 18, + 19, + 20, + 21, + 22, + 23, + 24, + 25, + 26, + 27, + 28, + 29, + 30, + 31, + 32, + 33, + 34, + 35, + 36, + 37, + 38, + 39, + 40, + 41 + ], + "starting_column": 1, + "ending_column": 2 + } + }, + "signature": "indirect()" + } + }, + { + "type": "node", + "name": "destination.send(address(this).balance)", + "source_mapping": { + "start": 337, + "length": 39, + "filename_used": "/home/travis/build/crytic/slither/tests/arbitrary_send.sol", + "filename_relative": "tests/arbitrary_send.sol", + "filename_absolute": "/home/travis/build/crytic/slither/tests/arbitrary_send.sol", + "filename_short": "tests/arbitrary_send.sol", + "lines": [ + 20 + ], + "starting_column": 9, + "ending_column": 48 + }, + "type_specific_fields": { + "parent": { + "type": "function", + "name": "indirect", + "source_mapping": { + "start": 301, + "length": 82, + "filename_used": "/home/travis/build/crytic/slither/tests/arbitrary_send.sol", + "filename_relative": "tests/arbitrary_send.sol", + "filename_absolute": "/home/travis/build/crytic/slither/tests/arbitrary_send.sol", + "filename_short": "tests/arbitrary_send.sol", + "lines": [ + 19, + 20, + 21 + ], + "starting_column": 5, + "ending_column": 6 + }, + "type_specific_fields": { + "parent": { + "type": "contract", + "name": "Test", + "source_mapping": { + "start": 0, + "length": 869, + "filename_used": "/home/travis/build/crytic/slither/tests/arbitrary_send.sol", + "filename_relative": "tests/arbitrary_send.sol", + "filename_absolute": "/home/travis/build/crytic/slither/tests/arbitrary_send.sol", + "filename_short": "tests/arbitrary_send.sol", + "lines": [ + 1, + 2, + 3, + 4, + 5, + 6, + 7, + 8, + 9, + 10, + 11, + 12, + 13, + 14, + 15, + 16, + 17, + 18, + 19, + 20, + 21, + 22, + 23, + 24, + 25, + 26, + 27, + 28, + 29, + 30, + 31, + 32, + 33, + 34, + 35, + 36, + 37, + 38, + 39, + 40, + 41 + ], + "starting_column": 1, + "ending_column": 2 + } + }, + "signature": "indirect()" + } } } } - } - ] - } - ] + ] + } + ] + } } \ No newline at end of file diff --git a/tests/expected_json/backdoor.backdoor.json b/tests/expected_json/backdoor.backdoor.json index 3a6ddd579..477f5fe32 100644 --- a/tests/expected_json/backdoor.backdoor.json +++ b/tests/expected_json/backdoor.backdoor.json @@ -1,56 +1,61 @@ { "success": true, "error": null, - "results": [ - { - "check": "backdoor", - "impact": "High", - "confidence": "High", - "description": "Backdoor function found in C.i_am_a_backdoor (tests/backdoor.sol#4-6)\n", - "elements": [ - { - "type": "function", - "name": "i_am_a_backdoor", - "source_mapping": { - "start": 18, - "length": 74, - "filename_used": "/home/travis/build/crytic/slither/tests/backdoor.sol", - "filename_relative": "tests/backdoor.sol", - "filename_absolute": "/home/travis/build/crytic/slither/tests/backdoor.sol", - "filename_short": "tests/backdoor.sol", - "lines": [ - 4, - 5, - 6 - ], - "starting_column": 5, - "ending_column": 6 - }, - "contract": { - "type": "contract", - "name": "C", + "results": { + "detectors": [ + { + "check": "backdoor", + "impact": "High", + "confidence": "High", + "description": "Backdoor function found in C.i_am_a_backdoor (tests/backdoor.sol#4-6)\n", + "elements": [ + { + "type": "function", + "name": "i_am_a_backdoor", "source_mapping": { - "start": 1, - "length": 94, + "start": 18, + "length": 74, "filename_used": "/home/travis/build/crytic/slither/tests/backdoor.sol", "filename_relative": "tests/backdoor.sol", "filename_absolute": "/home/travis/build/crytic/slither/tests/backdoor.sol", "filename_short": "tests/backdoor.sol", "lines": [ - 2, - 3, 4, 5, - 6, - 7, - 8 + 6 ], - "starting_column": 1, - "ending_column": 2 + "starting_column": 5, + "ending_column": 6 + }, + "type_specific_fields": { + "parent": { + "type": "contract", + "name": "C", + "source_mapping": { + "start": 1, + "length": 94, + "filename_used": "/home/travis/build/crytic/slither/tests/backdoor.sol", + "filename_relative": "tests/backdoor.sol", + "filename_absolute": "/home/travis/build/crytic/slither/tests/backdoor.sol", + "filename_short": "tests/backdoor.sol", + "lines": [ + 2, + 3, + 4, + 5, + 6, + 7, + 8 + ], + "starting_column": 1, + "ending_column": 2 + } + }, + "signature": "i_am_a_backdoor()" } } - } - ] - } - ] + ] + } + ] + } } \ No newline at end of file diff --git a/tests/expected_json/backdoor.suicidal.json b/tests/expected_json/backdoor.suicidal.json index f194f3116..b2614f59c 100644 --- a/tests/expected_json/backdoor.suicidal.json +++ b/tests/expected_json/backdoor.suicidal.json @@ -1,56 +1,61 @@ { "success": true, "error": null, - "results": [ - { - "check": "suicidal", - "impact": "High", - "confidence": "High", - "description": "C.i_am_a_backdoor (tests/backdoor.sol#4-6) allows anyone to destruct the contract\n", - "elements": [ - { - "type": "function", - "name": "i_am_a_backdoor", - "source_mapping": { - "start": 18, - "length": 74, - "filename_used": "/home/travis/build/crytic/slither/tests/backdoor.sol", - "filename_relative": "tests/backdoor.sol", - "filename_absolute": "/home/travis/build/crytic/slither/tests/backdoor.sol", - "filename_short": "tests/backdoor.sol", - "lines": [ - 4, - 5, - 6 - ], - "starting_column": 5, - "ending_column": 6 - }, - "contract": { - "type": "contract", - "name": "C", + "results": { + "detectors": [ + { + "check": "suicidal", + "impact": "High", + "confidence": "High", + "description": "C.i_am_a_backdoor (tests/backdoor.sol#4-6) allows anyone to destruct the contract\n", + "elements": [ + { + "type": "function", + "name": "i_am_a_backdoor", "source_mapping": { - "start": 1, - "length": 94, + "start": 18, + "length": 74, "filename_used": "/home/travis/build/crytic/slither/tests/backdoor.sol", "filename_relative": "tests/backdoor.sol", "filename_absolute": "/home/travis/build/crytic/slither/tests/backdoor.sol", "filename_short": "tests/backdoor.sol", "lines": [ - 2, - 3, 4, 5, - 6, - 7, - 8 + 6 ], - "starting_column": 1, - "ending_column": 2 + "starting_column": 5, + "ending_column": 6 + }, + "type_specific_fields": { + "parent": { + "type": "contract", + "name": "C", + "source_mapping": { + "start": 1, + "length": 94, + "filename_used": "/home/travis/build/crytic/slither/tests/backdoor.sol", + "filename_relative": "tests/backdoor.sol", + "filename_absolute": "/home/travis/build/crytic/slither/tests/backdoor.sol", + "filename_short": "tests/backdoor.sol", + "lines": [ + 2, + 3, + 4, + 5, + 6, + 7, + 8 + ], + "starting_column": 1, + "ending_column": 2 + } + }, + "signature": "i_am_a_backdoor()" } } - } - ] - } - ] + ] + } + ] + } } \ No newline at end of file diff --git a/tests/expected_json/const_state_variables.constable-states.json b/tests/expected_json/const_state_variables.constable-states.json index 373a8a01f..55cb25ee9 100644 --- a/tests/expected_json/const_state_variables.constable-states.json +++ b/tests/expected_json/const_state_variables.constable-states.json @@ -1,348 +1,362 @@ { "success": true, "error": null, - "results": [ - { - "check": "constable-states", - "impact": "Informational", - "confidence": "High", - "description": "A.myFriendsAddress should be constant (tests/const_state_variables.sol#7)\n", - "elements": [ - { - "type": "variable", - "name": "myFriendsAddress", - "source_mapping": { - "start": 132, - "length": 76, - "filename_used": "/home/travis/build/crytic/slither/tests/const_state_variables.sol", - "filename_relative": "tests/const_state_variables.sol", - "filename_absolute": "/home/travis/build/crytic/slither/tests/const_state_variables.sol", - "filename_short": "tests/const_state_variables.sol", - "lines": [ - 7 - ], - "starting_column": 5, - "ending_column": 81 - }, - "contract": { - "type": "contract", - "name": "A", + "results": { + "detectors": [ + { + "check": "constable-states", + "impact": "Informational", + "confidence": "High", + "description": "A.myFriendsAddress should be constant (tests/const_state_variables.sol#7)\n", + "elements": [ + { + "type": "variable", + "name": "myFriendsAddress", "source_mapping": { - "start": 29, - "length": 441, + "start": 132, + "length": 76, "filename_used": "/home/travis/build/crytic/slither/tests/const_state_variables.sol", "filename_relative": "tests/const_state_variables.sol", "filename_absolute": "/home/travis/build/crytic/slither/tests/const_state_variables.sol", "filename_short": "tests/const_state_variables.sol", "lines": [ - 4, - 5, - 6, - 7, - 8, - 9, - 10, - 11, - 12, - 13, - 14, - 15, - 16, - 17, - 18, - 19, - 20, - 21 + 7 ], - "starting_column": 1, - "ending_column": 2 + "starting_column": 5, + "ending_column": 81 + }, + "type_specific_fields": { + "parent": { + "type": "contract", + "name": "A", + "source_mapping": { + "start": 29, + "length": 441, + "filename_used": "/home/travis/build/crytic/slither/tests/const_state_variables.sol", + "filename_relative": "tests/const_state_variables.sol", + "filename_absolute": "/home/travis/build/crytic/slither/tests/const_state_variables.sol", + "filename_short": "tests/const_state_variables.sol", + "lines": [ + 4, + 5, + 6, + 7, + 8, + 9, + 10, + 11, + 12, + 13, + 14, + 15, + 16, + 17, + 18, + 19, + 20, + 21 + ], + "starting_column": 1, + "ending_column": 2 + } + } } } - } - ] - }, - { - "check": "constable-states", - "impact": "Informational", - "confidence": "High", - "description": "A.test should be constant (tests/const_state_variables.sol#10)\n", - "elements": [ - { - "type": "variable", - "name": "test", - "source_mapping": { - "start": 237, - "length": 20, - "filename_used": "/home/travis/build/crytic/slither/tests/const_state_variables.sol", - "filename_relative": "tests/const_state_variables.sol", - "filename_absolute": "/home/travis/build/crytic/slither/tests/const_state_variables.sol", - "filename_short": "tests/const_state_variables.sol", - "lines": [ - 10 - ], - "starting_column": 5, - "ending_column": 25 - }, - "contract": { - "type": "contract", - "name": "A", + ] + }, + { + "check": "constable-states", + "impact": "Informational", + "confidence": "High", + "description": "A.test should be constant (tests/const_state_variables.sol#10)\n", + "elements": [ + { + "type": "variable", + "name": "test", "source_mapping": { - "start": 29, - "length": 441, + "start": 237, + "length": 20, "filename_used": "/home/travis/build/crytic/slither/tests/const_state_variables.sol", "filename_relative": "tests/const_state_variables.sol", "filename_absolute": "/home/travis/build/crytic/slither/tests/const_state_variables.sol", "filename_short": "tests/const_state_variables.sol", "lines": [ - 4, - 5, - 6, - 7, - 8, - 9, - 10, - 11, - 12, - 13, - 14, - 15, - 16, - 17, - 18, - 19, - 20, - 21 + 10 ], - "starting_column": 1, - "ending_column": 2 + "starting_column": 5, + "ending_column": 25 + }, + "type_specific_fields": { + "parent": { + "type": "contract", + "name": "A", + "source_mapping": { + "start": 29, + "length": 441, + "filename_used": "/home/travis/build/crytic/slither/tests/const_state_variables.sol", + "filename_relative": "tests/const_state_variables.sol", + "filename_absolute": "/home/travis/build/crytic/slither/tests/const_state_variables.sol", + "filename_short": "tests/const_state_variables.sol", + "lines": [ + 4, + 5, + 6, + 7, + 8, + 9, + 10, + 11, + 12, + 13, + 14, + 15, + 16, + 17, + 18, + 19, + 20, + 21 + ], + "starting_column": 1, + "ending_column": 2 + } + } } } - } - ] - }, - { - "check": "constable-states", - "impact": "Informational", - "confidence": "High", - "description": "A.text2 should be constant (tests/const_state_variables.sol#14)\n", - "elements": [ - { - "type": "variable", - "name": "text2", - "source_mapping": { - "start": 333, - "length": 20, - "filename_used": "/home/travis/build/crytic/slither/tests/const_state_variables.sol", - "filename_relative": "tests/const_state_variables.sol", - "filename_absolute": "/home/travis/build/crytic/slither/tests/const_state_variables.sol", - "filename_short": "tests/const_state_variables.sol", - "lines": [ - 14 - ], - "starting_column": 5, - "ending_column": 25 - }, - "contract": { - "type": "contract", - "name": "A", + ] + }, + { + "check": "constable-states", + "impact": "Informational", + "confidence": "High", + "description": "A.text2 should be constant (tests/const_state_variables.sol#14)\n", + "elements": [ + { + "type": "variable", + "name": "text2", "source_mapping": { - "start": 29, - "length": 441, + "start": 333, + "length": 20, "filename_used": "/home/travis/build/crytic/slither/tests/const_state_variables.sol", "filename_relative": "tests/const_state_variables.sol", "filename_absolute": "/home/travis/build/crytic/slither/tests/const_state_variables.sol", "filename_short": "tests/const_state_variables.sol", "lines": [ - 4, - 5, - 6, - 7, - 8, - 9, - 10, - 11, - 12, - 13, - 14, - 15, - 16, - 17, - 18, - 19, - 20, - 21 + 14 ], - "starting_column": 1, - "ending_column": 2 + "starting_column": 5, + "ending_column": 25 + }, + "type_specific_fields": { + "parent": { + "type": "contract", + "name": "A", + "source_mapping": { + "start": 29, + "length": 441, + "filename_used": "/home/travis/build/crytic/slither/tests/const_state_variables.sol", + "filename_relative": "tests/const_state_variables.sol", + "filename_absolute": "/home/travis/build/crytic/slither/tests/const_state_variables.sol", + "filename_short": "tests/const_state_variables.sol", + "lines": [ + 4, + 5, + 6, + 7, + 8, + 9, + 10, + 11, + 12, + 13, + 14, + 15, + 16, + 17, + 18, + 19, + 20, + 21 + ], + "starting_column": 1, + "ending_column": 2 + } + } } } - } - ] - }, - { - "check": "constable-states", - "impact": "Informational", - "confidence": "High", - "description": "B.mySistersAddress should be constant (tests/const_state_variables.sol#26)\n", - "elements": [ - { - "type": "variable", - "name": "mySistersAddress", - "source_mapping": { - "start": 496, - "length": 76, - "filename_used": "/home/travis/build/crytic/slither/tests/const_state_variables.sol", - "filename_relative": "tests/const_state_variables.sol", - "filename_absolute": "/home/travis/build/crytic/slither/tests/const_state_variables.sol", - "filename_short": "tests/const_state_variables.sol", - "lines": [ - 26 - ], - "starting_column": 5, - "ending_column": 81 - }, - "contract": { - "type": "contract", - "name": "B", + ] + }, + { + "check": "constable-states", + "impact": "Informational", + "confidence": "High", + "description": "B.mySistersAddress should be constant (tests/const_state_variables.sol#26)\n", + "elements": [ + { + "type": "variable", + "name": "mySistersAddress", "source_mapping": { - "start": 473, - "length": 271, + "start": 496, + "length": 76, "filename_used": "/home/travis/build/crytic/slither/tests/const_state_variables.sol", "filename_relative": "tests/const_state_variables.sol", "filename_absolute": "/home/travis/build/crytic/slither/tests/const_state_variables.sol", "filename_short": "tests/const_state_variables.sol", "lines": [ - 24, - 25, - 26, - 27, - 28, - 29, - 30, - 31, - 32, - 33, - 34, - 35, - 36, - 37 + 26 ], - "starting_column": 1, - "ending_column": 2 + "starting_column": 5, + "ending_column": 81 + }, + "type_specific_fields": { + "parent": { + "type": "contract", + "name": "B", + "source_mapping": { + "start": 473, + "length": 271, + "filename_used": "/home/travis/build/crytic/slither/tests/const_state_variables.sol", + "filename_relative": "tests/const_state_variables.sol", + "filename_absolute": "/home/travis/build/crytic/slither/tests/const_state_variables.sol", + "filename_short": "tests/const_state_variables.sol", + "lines": [ + 24, + 25, + 26, + 27, + 28, + 29, + 30, + 31, + 32, + 33, + 34, + 35, + 36, + 37 + ], + "starting_column": 1, + "ending_column": 2 + } + } } } - } - ] - }, - { - "check": "constable-states", - "impact": "Informational", - "confidence": "High", - "description": "MyConc.should_be_constant should be constant (tests/const_state_variables.sol#42)\n", - "elements": [ - { - "type": "variable", - "name": "should_be_constant", - "source_mapping": { - "start": 793, - "length": 42, - "filename_used": "/home/travis/build/crytic/slither/tests/const_state_variables.sol", - "filename_relative": "tests/const_state_variables.sol", - "filename_absolute": "/home/travis/build/crytic/slither/tests/const_state_variables.sol", - "filename_short": "tests/const_state_variables.sol", - "lines": [ - 42 - ], - "starting_column": 5, - "ending_column": 47 - }, - "contract": { - "type": "contract", - "name": "MyConc", + ] + }, + { + "check": "constable-states", + "impact": "Informational", + "confidence": "High", + "description": "MyConc.should_be_constant should be constant (tests/const_state_variables.sol#42)\n", + "elements": [ + { + "type": "variable", + "name": "should_be_constant", "source_mapping": { - "start": 746, - "length": 342, + "start": 793, + "length": 42, "filename_used": "/home/travis/build/crytic/slither/tests/const_state_variables.sol", "filename_relative": "tests/const_state_variables.sol", "filename_absolute": "/home/travis/build/crytic/slither/tests/const_state_variables.sol", "filename_short": "tests/const_state_variables.sol", "lines": [ - 39, - 40, - 41, - 42, - 43, - 44, - 45, - 46, - 47, - 48, - 49, - 50, - 51, - 52 + 42 ], - "starting_column": 1, - "ending_column": 2 + "starting_column": 5, + "ending_column": 47 + }, + "type_specific_fields": { + "parent": { + "type": "contract", + "name": "MyConc", + "source_mapping": { + "start": 746, + "length": 342, + "filename_used": "/home/travis/build/crytic/slither/tests/const_state_variables.sol", + "filename_relative": "tests/const_state_variables.sol", + "filename_absolute": "/home/travis/build/crytic/slither/tests/const_state_variables.sol", + "filename_short": "tests/const_state_variables.sol", + "lines": [ + 39, + 40, + 41, + 42, + 43, + 44, + 45, + 46, + 47, + 48, + 49, + 50, + 51, + 52 + ], + "starting_column": 1, + "ending_column": 2 + } + } } } - } - ] - }, - { - "check": "constable-states", - "impact": "Informational", - "confidence": "High", - "description": "MyConc.should_be_constant_2 should be constant (tests/const_state_variables.sol#43)\n", - "elements": [ - { - "type": "variable", - "name": "should_be_constant_2", - "source_mapping": { - "start": 841, - "length": 33, - "filename_used": "/home/travis/build/crytic/slither/tests/const_state_variables.sol", - "filename_relative": "tests/const_state_variables.sol", - "filename_absolute": "/home/travis/build/crytic/slither/tests/const_state_variables.sol", - "filename_short": "tests/const_state_variables.sol", - "lines": [ - 43 - ], - "starting_column": 5, - "ending_column": 38 - }, - "contract": { - "type": "contract", - "name": "MyConc", + ] + }, + { + "check": "constable-states", + "impact": "Informational", + "confidence": "High", + "description": "MyConc.should_be_constant_2 should be constant (tests/const_state_variables.sol#43)\n", + "elements": [ + { + "type": "variable", + "name": "should_be_constant_2", "source_mapping": { - "start": 746, - "length": 342, + "start": 841, + "length": 33, "filename_used": "/home/travis/build/crytic/slither/tests/const_state_variables.sol", "filename_relative": "tests/const_state_variables.sol", "filename_absolute": "/home/travis/build/crytic/slither/tests/const_state_variables.sol", "filename_short": "tests/const_state_variables.sol", "lines": [ - 39, - 40, - 41, - 42, - 43, - 44, - 45, - 46, - 47, - 48, - 49, - 50, - 51, - 52 + 43 ], - "starting_column": 1, - "ending_column": 2 + "starting_column": 5, + "ending_column": 38 + }, + "type_specific_fields": { + "parent": { + "type": "contract", + "name": "MyConc", + "source_mapping": { + "start": 746, + "length": 342, + "filename_used": "/home/travis/build/crytic/slither/tests/const_state_variables.sol", + "filename_relative": "tests/const_state_variables.sol", + "filename_absolute": "/home/travis/build/crytic/slither/tests/const_state_variables.sol", + "filename_short": "tests/const_state_variables.sol", + "lines": [ + 39, + 40, + 41, + 42, + 43, + 44, + 45, + 46, + 47, + 48, + 49, + 50, + 51, + 52 + ], + "starting_column": 1, + "ending_column": 2 + } + } } } - } - ] - } - ] + ] + } + ] + } } \ No newline at end of file diff --git a/tests/expected_json/constant-0.5.1.constant-function.json b/tests/expected_json/constant-0.5.1.constant-function.json index edee473aa..51813e3e5 100644 --- a/tests/expected_json/constant-0.5.1.constant-function.json +++ b/tests/expected_json/constant-0.5.1.constant-function.json @@ -1,70 +1,75 @@ { "success": true, "error": null, - "results": [ - { - "check": "constant-function", - "impact": "Medium", - "confidence": "Medium", - "description": "Constant.test_assembly_bug (tests/constant-0.5.1.sol#15-17) is declared view but contains assembly code\n", - "elements": [ - { - "type": "function", - "name": "test_assembly_bug", - "source_mapping": { - "start": 185, - "length": 66, - "filename_used": "/home/travis/build/crytic/slither/tests/constant-0.5.1.sol", - "filename_relative": "tests/constant-0.5.1.sol", - "filename_absolute": "/home/travis/build/crytic/slither/tests/constant-0.5.1.sol", - "filename_short": "tests/constant-0.5.1.sol", - "lines": [ - 15, - 16, - 17 - ], - "starting_column": 5, - "ending_column": 6 - }, - "contract": { - "type": "contract", - "name": "Constant", + "results": { + "detectors": [ + { + "check": "constant-function", + "impact": "Medium", + "confidence": "Medium", + "description": "Constant.test_assembly_bug (tests/constant-0.5.1.sol#15-17) is declared view but contains assembly code\n", + "elements": [ + { + "type": "function", + "name": "test_assembly_bug", "source_mapping": { - "start": 0, - "length": 253, + "start": 185, + "length": 66, "filename_used": "/home/travis/build/crytic/slither/tests/constant-0.5.1.sol", "filename_relative": "tests/constant-0.5.1.sol", "filename_absolute": "/home/travis/build/crytic/slither/tests/constant-0.5.1.sol", "filename_short": "tests/constant-0.5.1.sol", "lines": [ - 1, - 2, - 3, - 4, - 5, - 6, - 7, - 8, - 9, - 10, - 11, - 12, - 13, - 14, 15, 16, - 17, - 18 + 17 ], - "starting_column": 1, - "ending_column": 2 + "starting_column": 5, + "ending_column": 6 + }, + "type_specific_fields": { + "parent": { + "type": "contract", + "name": "Constant", + "source_mapping": { + "start": 0, + "length": 253, + "filename_used": "/home/travis/build/crytic/slither/tests/constant-0.5.1.sol", + "filename_relative": "tests/constant-0.5.1.sol", + "filename_absolute": "/home/travis/build/crytic/slither/tests/constant-0.5.1.sol", + "filename_short": "tests/constant-0.5.1.sol", + "lines": [ + 1, + 2, + 3, + 4, + 5, + 6, + 7, + 8, + 9, + 10, + 11, + 12, + 13, + 14, + 15, + 16, + 17, + 18 + ], + "starting_column": 1, + "ending_column": 2 + } + }, + "signature": "test_assembly_bug()" } } + ], + "additional_fields": { + "contains_assembly": true } - ], - "additional_fields": { - "contains_assembly": true } - } - ] + ] + } } \ No newline at end of file diff --git a/tests/expected_json/constant.constant-function.json b/tests/expected_json/constant.constant-function.json index f678fe4ae..db339ba60 100644 --- a/tests/expected_json/constant.constant-function.json +++ b/tests/expected_json/constant.constant-function.json @@ -1,335 +1,350 @@ { "success": true, "error": null, - "results": [ - { - "check": "constant-function", - "impact": "Medium", - "confidence": "Medium", - "description": "Constant.test_view_bug (tests/constant.sol#5-7) is declared view but changes state variables:\n\t- Constant.a\n", - "elements": [ - { - "type": "function", - "name": "test_view_bug", - "source_mapping": { - "start": 45, - "length": 58, - "filename_used": "/home/travis/build/crytic/slither/tests/constant.sol", - "filename_relative": "tests/constant.sol", - "filename_absolute": "/home/travis/build/crytic/slither/tests/constant.sol", - "filename_short": "tests/constant.sol", - "lines": [ - 5, - 6, - 7 - ], - "starting_column": 5, - "ending_column": 6 - }, - "contract": { - "type": "contract", - "name": "Constant", + "results": { + "detectors": [ + { + "check": "constant-function", + "impact": "Medium", + "confidence": "Medium", + "description": "Constant.test_view_bug (tests/constant.sol#5-7) is declared view but changes state variables:\n\t- Constant.a\n", + "elements": [ + { + "type": "function", + "name": "test_view_bug", "source_mapping": { - "start": 0, - "length": 392, + "start": 45, + "length": 58, "filename_used": "/home/travis/build/crytic/slither/tests/constant.sol", "filename_relative": "tests/constant.sol", "filename_absolute": "/home/travis/build/crytic/slither/tests/constant.sol", "filename_short": "tests/constant.sol", "lines": [ - 1, - 2, - 3, - 4, 5, 6, - 7, - 8, - 9, - 10, - 11, - 12, - 13, - 14, - 15, - 16, - 17, - 18, - 19, - 20, - 21, - 22, - 23, - 24, - 25 + 7 ], - "starting_column": 1, - "ending_column": 2 + "starting_column": 5, + "ending_column": 6 + }, + "type_specific_fields": { + "parent": { + "type": "contract", + "name": "Constant", + "source_mapping": { + "start": 0, + "length": 392, + "filename_used": "/home/travis/build/crytic/slither/tests/constant.sol", + "filename_relative": "tests/constant.sol", + "filename_absolute": "/home/travis/build/crytic/slither/tests/constant.sol", + "filename_short": "tests/constant.sol", + "lines": [ + 1, + 2, + 3, + 4, + 5, + 6, + 7, + 8, + 9, + 10, + 11, + 12, + 13, + 14, + 15, + 16, + 17, + 18, + 19, + 20, + 21, + 22, + 23, + 24, + 25 + ], + "starting_column": 1, + "ending_column": 2 + } + }, + "signature": "test_view_bug()" } - } - }, - { - "type": "variable", - "name": "a", - "source_mapping": { - "start": 28, - "length": 6, - "filename_used": "/home/travis/build/crytic/slither/tests/constant.sol", - "filename_relative": "tests/constant.sol", - "filename_absolute": "/home/travis/build/crytic/slither/tests/constant.sol", - "filename_short": "tests/constant.sol", - "lines": [ - 3 - ], - "starting_column": 5, - "ending_column": 11 }, - "contract": { - "type": "contract", - "name": "Constant", + { + "type": "variable", + "name": "a", "source_mapping": { - "start": 0, - "length": 392, + "start": 28, + "length": 6, "filename_used": "/home/travis/build/crytic/slither/tests/constant.sol", "filename_relative": "tests/constant.sol", "filename_absolute": "/home/travis/build/crytic/slither/tests/constant.sol", "filename_short": "tests/constant.sol", "lines": [ - 1, - 2, - 3, - 4, - 5, - 6, - 7, - 8, - 9, - 10, - 11, - 12, - 13, - 14, - 15, - 16, - 17, - 18, - 19, - 20, - 21, - 22, - 23, - 24, - 25 + 3 ], - "starting_column": 1, - "ending_column": 2 + "starting_column": 5, + "ending_column": 11 + }, + "type_specific_fields": { + "parent": { + "type": "contract", + "name": "Constant", + "source_mapping": { + "start": 0, + "length": 392, + "filename_used": "/home/travis/build/crytic/slither/tests/constant.sol", + "filename_relative": "tests/constant.sol", + "filename_absolute": "/home/travis/build/crytic/slither/tests/constant.sol", + "filename_short": "tests/constant.sol", + "lines": [ + 1, + 2, + 3, + 4, + 5, + 6, + 7, + 8, + 9, + 10, + 11, + 12, + 13, + 14, + 15, + 16, + 17, + 18, + 19, + 20, + 21, + 22, + 23, + 24, + 25 + ], + "starting_column": 1, + "ending_column": 2 + } + } } } + ], + "additional_fields": { + "contains_assembly": false } - ], - "additional_fields": { - "contains_assembly": false - } - }, - { - "check": "constant-function", - "impact": "Medium", - "confidence": "Medium", - "description": "Constant.test_constant_bug (tests/constant.sol#9-11) is declared view but changes state variables:\n\t- Constant.a\n", - "elements": [ - { - "type": "function", - "name": "test_constant_bug", - "source_mapping": { - "start": 113, - "length": 66, - "filename_used": "/home/travis/build/crytic/slither/tests/constant.sol", - "filename_relative": "tests/constant.sol", - "filename_absolute": "/home/travis/build/crytic/slither/tests/constant.sol", - "filename_short": "tests/constant.sol", - "lines": [ - 9, - 10, - 11 - ], - "starting_column": 5, - "ending_column": 6 - }, - "contract": { - "type": "contract", - "name": "Constant", + }, + { + "check": "constant-function", + "impact": "Medium", + "confidence": "Medium", + "description": "Constant.test_constant_bug (tests/constant.sol#9-11) is declared view but changes state variables:\n\t- Constant.a\n", + "elements": [ + { + "type": "function", + "name": "test_constant_bug", "source_mapping": { - "start": 0, - "length": 392, + "start": 113, + "length": 66, "filename_used": "/home/travis/build/crytic/slither/tests/constant.sol", "filename_relative": "tests/constant.sol", "filename_absolute": "/home/travis/build/crytic/slither/tests/constant.sol", "filename_short": "tests/constant.sol", "lines": [ - 1, - 2, - 3, - 4, - 5, - 6, - 7, - 8, 9, 10, - 11, - 12, - 13, - 14, - 15, - 16, - 17, - 18, - 19, - 20, - 21, - 22, - 23, - 24, - 25 + 11 ], - "starting_column": 1, - "ending_column": 2 + "starting_column": 5, + "ending_column": 6 + }, + "type_specific_fields": { + "parent": { + "type": "contract", + "name": "Constant", + "source_mapping": { + "start": 0, + "length": 392, + "filename_used": "/home/travis/build/crytic/slither/tests/constant.sol", + "filename_relative": "tests/constant.sol", + "filename_absolute": "/home/travis/build/crytic/slither/tests/constant.sol", + "filename_short": "tests/constant.sol", + "lines": [ + 1, + 2, + 3, + 4, + 5, + 6, + 7, + 8, + 9, + 10, + 11, + 12, + 13, + 14, + 15, + 16, + 17, + 18, + 19, + 20, + 21, + 22, + 23, + 24, + 25 + ], + "starting_column": 1, + "ending_column": 2 + } + }, + "signature": "test_constant_bug()" } - } - }, - { - "type": "variable", - "name": "a", - "source_mapping": { - "start": 28, - "length": 6, - "filename_used": "/home/travis/build/crytic/slither/tests/constant.sol", - "filename_relative": "tests/constant.sol", - "filename_absolute": "/home/travis/build/crytic/slither/tests/constant.sol", - "filename_short": "tests/constant.sol", - "lines": [ - 3 - ], - "starting_column": 5, - "ending_column": 11 }, - "contract": { - "type": "contract", - "name": "Constant", + { + "type": "variable", + "name": "a", "source_mapping": { - "start": 0, - "length": 392, + "start": 28, + "length": 6, "filename_used": "/home/travis/build/crytic/slither/tests/constant.sol", "filename_relative": "tests/constant.sol", "filename_absolute": "/home/travis/build/crytic/slither/tests/constant.sol", "filename_short": "tests/constant.sol", "lines": [ - 1, - 2, - 3, - 4, - 5, - 6, - 7, - 8, - 9, - 10, - 11, - 12, - 13, - 14, - 15, - 16, - 17, - 18, - 19, - 20, - 21, - 22, - 23, - 24, - 25 + 3 ], - "starting_column": 1, - "ending_column": 2 + "starting_column": 5, + "ending_column": 11 + }, + "type_specific_fields": { + "parent": { + "type": "contract", + "name": "Constant", + "source_mapping": { + "start": 0, + "length": 392, + "filename_used": "/home/travis/build/crytic/slither/tests/constant.sol", + "filename_relative": "tests/constant.sol", + "filename_absolute": "/home/travis/build/crytic/slither/tests/constant.sol", + "filename_short": "tests/constant.sol", + "lines": [ + 1, + 2, + 3, + 4, + 5, + 6, + 7, + 8, + 9, + 10, + 11, + 12, + 13, + 14, + 15, + 16, + 17, + 18, + 19, + 20, + 21, + 22, + 23, + 24, + 25 + ], + "starting_column": 1, + "ending_column": 2 + } + } } } + ], + "additional_fields": { + "contains_assembly": false } - ], - "additional_fields": { - "contains_assembly": false - } - }, - { - "check": "constant-function", - "impact": "Medium", - "confidence": "Medium", - "description": "Constant.test_assembly_bug (tests/constant.sol#22-24) is declared view but contains assembly code\n", - "elements": [ - { - "type": "function", - "name": "test_assembly_bug", - "source_mapping": { - "start": 324, - "length": 66, - "filename_used": "/home/travis/build/crytic/slither/tests/constant.sol", - "filename_relative": "tests/constant.sol", - "filename_absolute": "/home/travis/build/crytic/slither/tests/constant.sol", - "filename_short": "tests/constant.sol", - "lines": [ - 22, - 23, - 24 - ], - "starting_column": 5, - "ending_column": 6 - }, - "contract": { - "type": "contract", - "name": "Constant", + }, + { + "check": "constant-function", + "impact": "Medium", + "confidence": "Medium", + "description": "Constant.test_assembly_bug (tests/constant.sol#22-24) is declared view but contains assembly code\n", + "elements": [ + { + "type": "function", + "name": "test_assembly_bug", "source_mapping": { - "start": 0, - "length": 392, + "start": 324, + "length": 66, "filename_used": "/home/travis/build/crytic/slither/tests/constant.sol", "filename_relative": "tests/constant.sol", "filename_absolute": "/home/travis/build/crytic/slither/tests/constant.sol", "filename_short": "tests/constant.sol", "lines": [ - 1, - 2, - 3, - 4, - 5, - 6, - 7, - 8, - 9, - 10, - 11, - 12, - 13, - 14, - 15, - 16, - 17, - 18, - 19, - 20, - 21, 22, 23, - 24, - 25 + 24 ], - "starting_column": 1, - "ending_column": 2 + "starting_column": 5, + "ending_column": 6 + }, + "type_specific_fields": { + "parent": { + "type": "contract", + "name": "Constant", + "source_mapping": { + "start": 0, + "length": 392, + "filename_used": "/home/travis/build/crytic/slither/tests/constant.sol", + "filename_relative": "tests/constant.sol", + "filename_absolute": "/home/travis/build/crytic/slither/tests/constant.sol", + "filename_short": "tests/constant.sol", + "lines": [ + 1, + 2, + 3, + 4, + 5, + 6, + 7, + 8, + 9, + 10, + 11, + 12, + 13, + 14, + 15, + 16, + 17, + 18, + 19, + 20, + 21, + 22, + 23, + 24, + 25 + ], + "starting_column": 1, + "ending_column": 2 + } + }, + "signature": "test_assembly_bug()" } } + ], + "additional_fields": { + "contains_assembly": true } - ], - "additional_fields": { - "contains_assembly": true } - } - ] + ] + } } \ No newline at end of file diff --git a/tests/expected_json/controlled_delegatecall.controlled-delegatecall.json b/tests/expected_json/controlled_delegatecall.controlled-delegatecall.json index a5e900455..931add794 100644 --- a/tests/expected_json/controlled_delegatecall.controlled-delegatecall.json +++ b/tests/expected_json/controlled_delegatecall.controlled-delegatecall.json @@ -1,30 +1,98 @@ { "success": true, "error": null, - "results": [ - { - "check": "controlled-delegatecall", - "impact": "High", - "confidence": "Medium", - "description": "C.bad_delegate_call (tests/controlled_delegatecall.sol#8-11) uses delegatecall to a input-controlled function id\n\t- addr_bad.delegatecall(data) (tests/controlled_delegatecall.sol#10)\n", - "elements": [ - { - "type": "node", - "name": "addr_bad.delegatecall(data)", - "source_mapping": { - "start": 201, - "length": 27, - "filename_used": "/home/travis/build/crytic/slither/tests/controlled_delegatecall.sol", - "filename_relative": "tests/controlled_delegatecall.sol", - "filename_absolute": "/home/travis/build/crytic/slither/tests/controlled_delegatecall.sol", - "filename_short": "tests/controlled_delegatecall.sol", - "lines": [ - 10 - ], - "starting_column": 9, - "ending_column": 36 + "results": { + "detectors": [ + { + "check": "controlled-delegatecall", + "impact": "High", + "confidence": "Medium", + "description": "C.bad_delegate_call (tests/controlled_delegatecall.sol#8-11) uses delegatecall to a input-controlled function id\n\t- addr_bad.delegatecall(data) (tests/controlled_delegatecall.sol#10)\n", + "elements": [ + { + "type": "node", + "name": "addr_bad.delegatecall(data)", + "source_mapping": { + "start": 201, + "length": 27, + "filename_used": "/home/travis/build/crytic/slither/tests/controlled_delegatecall.sol", + "filename_relative": "tests/controlled_delegatecall.sol", + "filename_absolute": "/home/travis/build/crytic/slither/tests/controlled_delegatecall.sol", + "filename_short": "tests/controlled_delegatecall.sol", + "lines": [ + 10 + ], + "starting_column": 9, + "ending_column": 36 + }, + "type_specific_fields": { + "parent": { + "type": "function", + "name": "bad_delegate_call", + "source_mapping": { + "start": 101, + "length": 134, + "filename_used": "/home/travis/build/crytic/slither/tests/controlled_delegatecall.sol", + "filename_relative": "tests/controlled_delegatecall.sol", + "filename_absolute": "/home/travis/build/crytic/slither/tests/controlled_delegatecall.sol", + "filename_short": "tests/controlled_delegatecall.sol", + "lines": [ + 8, + 9, + 10, + 11 + ], + "starting_column": 5, + "ending_column": 6 + }, + "type_specific_fields": { + "parent": { + "type": "contract", + "name": "C", + "source_mapping": { + "start": 0, + "length": 585, + "filename_used": "/home/travis/build/crytic/slither/tests/controlled_delegatecall.sol", + "filename_relative": "tests/controlled_delegatecall.sol", + "filename_absolute": "/home/travis/build/crytic/slither/tests/controlled_delegatecall.sol", + "filename_short": "tests/controlled_delegatecall.sol", + "lines": [ + 1, + 2, + 3, + 4, + 5, + 6, + 7, + 8, + 9, + 10, + 11, + 12, + 13, + 14, + 15, + 16, + 17, + 18, + 19, + 20, + 21, + 22, + 23, + 24, + 25 + ], + "starting_column": 1, + "ending_column": 2 + } + }, + "signature": "bad_delegate_call(bytes)" + } + } + } }, - "function": { + { "type": "function", "name": "bad_delegate_call", "source_mapping": { @@ -43,135 +111,142 @@ "starting_column": 5, "ending_column": 6 }, - "contract": { - "type": "contract", - "name": "C", - "source_mapping": { - "start": 0, - "length": 585, - "filename_used": "/home/travis/build/crytic/slither/tests/controlled_delegatecall.sol", - "filename_relative": "tests/controlled_delegatecall.sol", - "filename_absolute": "/home/travis/build/crytic/slither/tests/controlled_delegatecall.sol", - "filename_short": "tests/controlled_delegatecall.sol", - "lines": [ - 1, - 2, - 3, - 4, - 5, - 6, - 7, - 8, - 9, - 10, - 11, - 12, - 13, - 14, - 15, - 16, - 17, - 18, - 19, - 20, - 21, - 22, - 23, - 24, - 25 - ], - "starting_column": 1, - "ending_column": 2 - } + "type_specific_fields": { + "parent": { + "type": "contract", + "name": "C", + "source_mapping": { + "start": 0, + "length": 585, + "filename_used": "/home/travis/build/crytic/slither/tests/controlled_delegatecall.sol", + "filename_relative": "tests/controlled_delegatecall.sol", + "filename_absolute": "/home/travis/build/crytic/slither/tests/controlled_delegatecall.sol", + "filename_short": "tests/controlled_delegatecall.sol", + "lines": [ + 1, + 2, + 3, + 4, + 5, + 6, + 7, + 8, + 9, + 10, + 11, + 12, + 13, + 14, + 15, + 16, + 17, + 18, + 19, + 20, + 21, + 22, + 23, + 24, + 25 + ], + "starting_column": 1, + "ending_column": 2 + } + }, + "signature": "bad_delegate_call(bytes)" } } - }, - { - "type": "function", - "name": "bad_delegate_call", - "source_mapping": { - "start": 101, - "length": 134, - "filename_used": "/home/travis/build/crytic/slither/tests/controlled_delegatecall.sol", - "filename_relative": "tests/controlled_delegatecall.sol", - "filename_absolute": "/home/travis/build/crytic/slither/tests/controlled_delegatecall.sol", - "filename_short": "tests/controlled_delegatecall.sol", - "lines": [ - 8, - 9, - 10, - 11 - ], - "starting_column": 5, - "ending_column": 6 - }, - "contract": { - "type": "contract", - "name": "C", + ] + }, + { + "check": "controlled-delegatecall", + "impact": "High", + "confidence": "Medium", + "description": "C.bad_delegate_call2 (tests/controlled_delegatecall.sol#18-20) uses delegatecall to a input-controlled function id\n\t- addr_bad.delegatecall(abi.encode(func_id,data)) (tests/controlled_delegatecall.sol#19)\n", + "elements": [ + { + "type": "node", + "name": "addr_bad.delegatecall(abi.encode(func_id,data))", "source_mapping": { - "start": 0, - "length": 585, + "start": 400, + "length": 48, "filename_used": "/home/travis/build/crytic/slither/tests/controlled_delegatecall.sol", "filename_relative": "tests/controlled_delegatecall.sol", "filename_absolute": "/home/travis/build/crytic/slither/tests/controlled_delegatecall.sol", "filename_short": "tests/controlled_delegatecall.sol", "lines": [ - 1, - 2, - 3, - 4, - 5, - 6, - 7, - 8, - 9, - 10, - 11, - 12, - 13, - 14, - 15, - 16, - 17, - 18, - 19, - 20, - 21, - 22, - 23, - 24, - 25 + 19 ], - "starting_column": 1, - "ending_column": 2 + "starting_column": 9, + "ending_column": 57 + }, + "type_specific_fields": { + "parent": { + "type": "function", + "name": "bad_delegate_call2", + "source_mapping": { + "start": 337, + "length": 118, + "filename_used": "/home/travis/build/crytic/slither/tests/controlled_delegatecall.sol", + "filename_relative": "tests/controlled_delegatecall.sol", + "filename_absolute": "/home/travis/build/crytic/slither/tests/controlled_delegatecall.sol", + "filename_short": "tests/controlled_delegatecall.sol", + "lines": [ + 18, + 19, + 20 + ], + "starting_column": 5, + "ending_column": 6 + }, + "type_specific_fields": { + "parent": { + "type": "contract", + "name": "C", + "source_mapping": { + "start": 0, + "length": 585, + "filename_used": "/home/travis/build/crytic/slither/tests/controlled_delegatecall.sol", + "filename_relative": "tests/controlled_delegatecall.sol", + "filename_absolute": "/home/travis/build/crytic/slither/tests/controlled_delegatecall.sol", + "filename_short": "tests/controlled_delegatecall.sol", + "lines": [ + 1, + 2, + 3, + 4, + 5, + 6, + 7, + 8, + 9, + 10, + 11, + 12, + 13, + 14, + 15, + 16, + 17, + 18, + 19, + 20, + 21, + 22, + 23, + 24, + 25 + ], + "starting_column": 1, + "ending_column": 2 + } + }, + "signature": "bad_delegate_call2(bytes)" + } + } } - } - } - ] - }, - { - "check": "controlled-delegatecall", - "impact": "High", - "confidence": "Medium", - "description": "C.bad_delegate_call2 (tests/controlled_delegatecall.sol#18-20) uses delegatecall to a input-controlled function id\n\t- addr_bad.delegatecall(abi.encode(func_id,data)) (tests/controlled_delegatecall.sol#19)\n", - "elements": [ - { - "type": "node", - "name": "addr_bad.delegatecall(abi.encode(func_id,data))", - "source_mapping": { - "start": 400, - "length": 48, - "filename_used": "/home/travis/build/crytic/slither/tests/controlled_delegatecall.sol", - "filename_relative": "tests/controlled_delegatecall.sol", - "filename_absolute": "/home/travis/build/crytic/slither/tests/controlled_delegatecall.sol", - "filename_short": "tests/controlled_delegatecall.sol", - "lines": [ - 19 - ], - "starting_column": 9, - "ending_column": 57 }, - "function": { + { "type": "function", "name": "bad_delegate_call2", "source_mapping": { @@ -189,110 +264,53 @@ "starting_column": 5, "ending_column": 6 }, - "contract": { - "type": "contract", - "name": "C", - "source_mapping": { - "start": 0, - "length": 585, - "filename_used": "/home/travis/build/crytic/slither/tests/controlled_delegatecall.sol", - "filename_relative": "tests/controlled_delegatecall.sol", - "filename_absolute": "/home/travis/build/crytic/slither/tests/controlled_delegatecall.sol", - "filename_short": "tests/controlled_delegatecall.sol", - "lines": [ - 1, - 2, - 3, - 4, - 5, - 6, - 7, - 8, - 9, - 10, - 11, - 12, - 13, - 14, - 15, - 16, - 17, - 18, - 19, - 20, - 21, - 22, - 23, - 24, - 25 - ], - "starting_column": 1, - "ending_column": 2 - } - } - } - }, - { - "type": "function", - "name": "bad_delegate_call2", - "source_mapping": { - "start": 337, - "length": 118, - "filename_used": "/home/travis/build/crytic/slither/tests/controlled_delegatecall.sol", - "filename_relative": "tests/controlled_delegatecall.sol", - "filename_absolute": "/home/travis/build/crytic/slither/tests/controlled_delegatecall.sol", - "filename_short": "tests/controlled_delegatecall.sol", - "lines": [ - 18, - 19, - 20 - ], - "starting_column": 5, - "ending_column": 6 - }, - "contract": { - "type": "contract", - "name": "C", - "source_mapping": { - "start": 0, - "length": 585, - "filename_used": "/home/travis/build/crytic/slither/tests/controlled_delegatecall.sol", - "filename_relative": "tests/controlled_delegatecall.sol", - "filename_absolute": "/home/travis/build/crytic/slither/tests/controlled_delegatecall.sol", - "filename_short": "tests/controlled_delegatecall.sol", - "lines": [ - 1, - 2, - 3, - 4, - 5, - 6, - 7, - 8, - 9, - 10, - 11, - 12, - 13, - 14, - 15, - 16, - 17, - 18, - 19, - 20, - 21, - 22, - 23, - 24, - 25 - ], - "starting_column": 1, - "ending_column": 2 + "type_specific_fields": { + "parent": { + "type": "contract", + "name": "C", + "source_mapping": { + "start": 0, + "length": 585, + "filename_used": "/home/travis/build/crytic/slither/tests/controlled_delegatecall.sol", + "filename_relative": "tests/controlled_delegatecall.sol", + "filename_absolute": "/home/travis/build/crytic/slither/tests/controlled_delegatecall.sol", + "filename_short": "tests/controlled_delegatecall.sol", + "lines": [ + 1, + 2, + 3, + 4, + 5, + 6, + 7, + 8, + 9, + 10, + 11, + 12, + 13, + 14, + 15, + 16, + 17, + 18, + 19, + 20, + 21, + 22, + 23, + 24, + 25 + ], + "starting_column": 1, + "ending_column": 2 + } + }, + "signature": "bad_delegate_call2(bytes)" } } - } - ] - } - ] + ] + } + ] + } } \ No newline at end of file diff --git a/tests/expected_json/deprecated_calls.deprecated-standards.json b/tests/expected_json/deprecated_calls.deprecated-standards.json index ff2d8bf7d..49736378d 100644 --- a/tests/expected_json/deprecated_calls.deprecated-standards.json +++ b/tests/expected_json/deprecated_calls.deprecated-standards.json @@ -1,647 +1,681 @@ { "success": true, "error": null, - "results": [ - { - "check": "deprecated-standards", - "impact": "Informational", - "confidence": "High", - "description": "Deprecated standard detected @ tests/deprecated_calls.sol#2:\n\t- Usage of \"block.blockhash()\" should be replaced with \"blockhash()\"\n", - "elements": [ - { - "type": "variable", - "name": "globalBlockHash", - "source_mapping": { - "start": 48, - "length": 44, - "filename_used": "/home/travis/build/crytic/slither/tests/deprecated_calls.sol", - "filename_relative": "tests/deprecated_calls.sol", - "filename_absolute": "/home/travis/build/crytic/slither/tests/deprecated_calls.sol", - "filename_short": "tests/deprecated_calls.sol", - "lines": [ - 2 - ], - "starting_column": 5, - "ending_column": 49 - }, - "contract": { - "type": "contract", - "name": "ContractWithDeprecatedReferences", + "results": { + "detectors": [ + { + "check": "deprecated-standards", + "impact": "Informational", + "confidence": "High", + "description": "Deprecated standard detected @ tests/deprecated_calls.sol#2:\n\t- Usage of \"block.blockhash()\" should be replaced with \"blockhash()\"\n", + "elements": [ + { + "type": "variable", + "name": "globalBlockHash", "source_mapping": { - "start": 0, - "length": 906, + "start": 48, + "length": 44, "filename_used": "/home/travis/build/crytic/slither/tests/deprecated_calls.sol", "filename_relative": "tests/deprecated_calls.sol", "filename_absolute": "/home/travis/build/crytic/slither/tests/deprecated_calls.sol", "filename_short": "tests/deprecated_calls.sol", "lines": [ - 1, - 2, - 3, - 4, - 5, - 6, - 7, - 8, - 9, - 10, - 11, - 12, - 13, - 14, - 15, - 16, - 17, - 18, - 19, - 20, - 21, - 22, - 23, - 24, - 25, - 26, - 27 + 2 ], - "starting_column": 1, - "ending_column": null + "starting_column": 5, + "ending_column": 49 + }, + "type_specific_fields": { + "parent": { + "type": "contract", + "name": "ContractWithDeprecatedReferences", + "source_mapping": { + "start": 0, + "length": 906, + "filename_used": "/home/travis/build/crytic/slither/tests/deprecated_calls.sol", + "filename_relative": "tests/deprecated_calls.sol", + "filename_absolute": "/home/travis/build/crytic/slither/tests/deprecated_calls.sol", + "filename_short": "tests/deprecated_calls.sol", + "lines": [ + 1, + 2, + 3, + 4, + 5, + 6, + 7, + 8, + 9, + 10, + 11, + 12, + 13, + 14, + 15, + 16, + 17, + 18, + 19, + 20, + 21, + 22, + 23, + 24, + 25, + 26, + 27 + ], + "starting_column": 1, + "ending_column": null + } + } } } - } - ] - }, - { - "check": "deprecated-standards", - "impact": "Informational", - "confidence": "High", - "description": "Deprecated standard detected @ tests/deprecated_calls.sol#7-10:\n\t- Usage of \"msg.gas\" should be replaced with \"gasleft()\"\n", - "elements": [ - { - "type": "node", - "name": "msg.gas == msg.value", - "source_mapping": { - "start": 258, - "length": 107, - "filename_used": "/home/travis/build/crytic/slither/tests/deprecated_calls.sol", - "filename_relative": "tests/deprecated_calls.sol", - "filename_absolute": "/home/travis/build/crytic/slither/tests/deprecated_calls.sol", - "filename_short": "tests/deprecated_calls.sol", - "lines": [ - 7, - 8, - 9, - 10 - ], - "starting_column": 9, - "ending_column": 10 - }, - "function": { - "type": "function", - "name": "functionWithDeprecatedThrow", + ] + }, + { + "check": "deprecated-standards", + "impact": "Informational", + "confidence": "High", + "description": "Deprecated standard detected @ tests/deprecated_calls.sol#7-10:\n\t- Usage of \"msg.gas\" should be replaced with \"gasleft()\"\n", + "elements": [ + { + "type": "node", + "name": "msg.gas == msg.value", "source_mapping": { - "start": 142, - "length": 229, + "start": 258, + "length": 107, "filename_used": "/home/travis/build/crytic/slither/tests/deprecated_calls.sol", "filename_relative": "tests/deprecated_calls.sol", "filename_absolute": "/home/travis/build/crytic/slither/tests/deprecated_calls.sol", "filename_short": "tests/deprecated_calls.sol", "lines": [ - 5, - 6, 7, 8, 9, - 10, - 11 + 10 ], - "starting_column": 5, - "ending_column": 6 + "starting_column": 9, + "ending_column": 10 }, - "contract": { - "type": "contract", - "name": "ContractWithDeprecatedReferences", - "source_mapping": { - "start": 0, - "length": 906, - "filename_used": "/home/travis/build/crytic/slither/tests/deprecated_calls.sol", - "filename_relative": "tests/deprecated_calls.sol", - "filename_absolute": "/home/travis/build/crytic/slither/tests/deprecated_calls.sol", - "filename_short": "tests/deprecated_calls.sol", - "lines": [ - 1, - 2, - 3, - 4, - 5, - 6, - 7, - 8, - 9, - 10, - 11, - 12, - 13, - 14, - 15, - 16, - 17, - 18, - 19, - 20, - 21, - 22, - 23, - 24, - 25, - 26, - 27 - ], - "starting_column": 1, - "ending_column": null + "type_specific_fields": { + "parent": { + "type": "function", + "name": "functionWithDeprecatedThrow", + "source_mapping": { + "start": 142, + "length": 229, + "filename_used": "/home/travis/build/crytic/slither/tests/deprecated_calls.sol", + "filename_relative": "tests/deprecated_calls.sol", + "filename_absolute": "/home/travis/build/crytic/slither/tests/deprecated_calls.sol", + "filename_short": "tests/deprecated_calls.sol", + "lines": [ + 5, + 6, + 7, + 8, + 9, + 10, + 11 + ], + "starting_column": 5, + "ending_column": 6 + }, + "type_specific_fields": { + "parent": { + "type": "contract", + "name": "ContractWithDeprecatedReferences", + "source_mapping": { + "start": 0, + "length": 906, + "filename_used": "/home/travis/build/crytic/slither/tests/deprecated_calls.sol", + "filename_relative": "tests/deprecated_calls.sol", + "filename_absolute": "/home/travis/build/crytic/slither/tests/deprecated_calls.sol", + "filename_short": "tests/deprecated_calls.sol", + "lines": [ + 1, + 2, + 3, + 4, + 5, + 6, + 7, + 8, + 9, + 10, + 11, + 12, + 13, + 14, + 15, + 16, + 17, + 18, + 19, + 20, + 21, + 22, + 23, + 24, + 25, + 26, + 27 + ], + "starting_column": 1, + "ending_column": null + } + }, + "signature": "functionWithDeprecatedThrow()" + } } } } - } - ] - }, - { - "check": "deprecated-standards", - "impact": "Informational", - "confidence": "High", - "description": "Deprecated standard detected @ tests/deprecated_calls.sol#9:\n\t- Usage of \"throw\" should be replaced with \"revert()\"\n", - "elements": [ - { - "type": "node", - "name": "", - "source_mapping": { - "start": 349, - "length": 5, - "filename_used": "/home/travis/build/crytic/slither/tests/deprecated_calls.sol", - "filename_relative": "tests/deprecated_calls.sol", - "filename_absolute": "/home/travis/build/crytic/slither/tests/deprecated_calls.sol", - "filename_short": "tests/deprecated_calls.sol", - "lines": [ - 9 - ], - "starting_column": 13, - "ending_column": 18 - }, - "function": { - "type": "function", - "name": "functionWithDeprecatedThrow", + ] + }, + { + "check": "deprecated-standards", + "impact": "Informational", + "confidence": "High", + "description": "Deprecated standard detected @ tests/deprecated_calls.sol#9:\n\t- Usage of \"throw\" should be replaced with \"revert()\"\n", + "elements": [ + { + "type": "node", + "name": "", "source_mapping": { - "start": 142, - "length": 229, + "start": 349, + "length": 5, "filename_used": "/home/travis/build/crytic/slither/tests/deprecated_calls.sol", "filename_relative": "tests/deprecated_calls.sol", "filename_absolute": "/home/travis/build/crytic/slither/tests/deprecated_calls.sol", "filename_short": "tests/deprecated_calls.sol", "lines": [ - 5, - 6, - 7, - 8, - 9, - 10, - 11 + 9 ], - "starting_column": 5, - "ending_column": 6 + "starting_column": 13, + "ending_column": 18 }, - "contract": { - "type": "contract", - "name": "ContractWithDeprecatedReferences", - "source_mapping": { - "start": 0, - "length": 906, - "filename_used": "/home/travis/build/crytic/slither/tests/deprecated_calls.sol", - "filename_relative": "tests/deprecated_calls.sol", - "filename_absolute": "/home/travis/build/crytic/slither/tests/deprecated_calls.sol", - "filename_short": "tests/deprecated_calls.sol", - "lines": [ - 1, - 2, - 3, - 4, - 5, - 6, - 7, - 8, - 9, - 10, - 11, - 12, - 13, - 14, - 15, - 16, - 17, - 18, - 19, - 20, - 21, - 22, - 23, - 24, - 25, - 26, - 27 - ], - "starting_column": 1, - "ending_column": null + "type_specific_fields": { + "parent": { + "type": "function", + "name": "functionWithDeprecatedThrow", + "source_mapping": { + "start": 142, + "length": 229, + "filename_used": "/home/travis/build/crytic/slither/tests/deprecated_calls.sol", + "filename_relative": "tests/deprecated_calls.sol", + "filename_absolute": "/home/travis/build/crytic/slither/tests/deprecated_calls.sol", + "filename_short": "tests/deprecated_calls.sol", + "lines": [ + 5, + 6, + 7, + 8, + 9, + 10, + 11 + ], + "starting_column": 5, + "ending_column": 6 + }, + "type_specific_fields": { + "parent": { + "type": "contract", + "name": "ContractWithDeprecatedReferences", + "source_mapping": { + "start": 0, + "length": 906, + "filename_used": "/home/travis/build/crytic/slither/tests/deprecated_calls.sol", + "filename_relative": "tests/deprecated_calls.sol", + "filename_absolute": "/home/travis/build/crytic/slither/tests/deprecated_calls.sol", + "filename_short": "tests/deprecated_calls.sol", + "lines": [ + 1, + 2, + 3, + 4, + 5, + 6, + 7, + 8, + 9, + 10, + 11, + 12, + 13, + 14, + 15, + 16, + 17, + 18, + 19, + 20, + 21, + 22, + 23, + 24, + 25, + 26, + 27 + ], + "starting_column": 1, + "ending_column": null + } + }, + "signature": "functionWithDeprecatedThrow()" + } } } } - } - ] - }, - { - "check": "deprecated-standards", - "impact": "Informational", - "confidence": "High", - "description": "Deprecated standard detected @ tests/deprecated_calls.sol#16:\n\t- Usage of \"sha3()\" should be replaced with \"keccak256()\"\n", - "elements": [ - { - "type": "node", - "name": "sha3Result = sha3()(test deprecated sha3 usage)", - "source_mapping": { - "start": 542, - "length": 55, - "filename_used": "/home/travis/build/crytic/slither/tests/deprecated_calls.sol", - "filename_relative": "tests/deprecated_calls.sol", - "filename_absolute": "/home/travis/build/crytic/slither/tests/deprecated_calls.sol", - "filename_short": "tests/deprecated_calls.sol", - "lines": [ - 16 - ], - "starting_column": 9, - "ending_column": 64 - }, - "function": { - "type": "function", - "name": "functionWithDeprecatedReferences", + ] + }, + { + "check": "deprecated-standards", + "impact": "Informational", + "confidence": "High", + "description": "Deprecated standard detected @ tests/deprecated_calls.sol#16:\n\t- Usage of \"sha3()\" should be replaced with \"keccak256()\"\n", + "elements": [ + { + "type": "node", + "name": "sha3Result = sha3()(test deprecated sha3 usage)", "source_mapping": { - "start": 420, - "length": 484, + "start": 542, + "length": 55, "filename_used": "/home/travis/build/crytic/slither/tests/deprecated_calls.sol", "filename_relative": "tests/deprecated_calls.sol", "filename_absolute": "/home/travis/build/crytic/slither/tests/deprecated_calls.sol", "filename_short": "tests/deprecated_calls.sol", "lines": [ - 14, - 15, - 16, - 17, - 18, - 19, - 20, - 21, - 22, - 23, - 24, - 25, - 26 + 16 ], - "starting_column": 5, - "ending_column": 6 + "starting_column": 9, + "ending_column": 64 }, - "contract": { - "type": "contract", - "name": "ContractWithDeprecatedReferences", - "source_mapping": { - "start": 0, - "length": 906, - "filename_used": "/home/travis/build/crytic/slither/tests/deprecated_calls.sol", - "filename_relative": "tests/deprecated_calls.sol", - "filename_absolute": "/home/travis/build/crytic/slither/tests/deprecated_calls.sol", - "filename_short": "tests/deprecated_calls.sol", - "lines": [ - 1, - 2, - 3, - 4, - 5, - 6, - 7, - 8, - 9, - 10, - 11, - 12, - 13, - 14, - 15, - 16, - 17, - 18, - 19, - 20, - 21, - 22, - 23, - 24, - 25, - 26, - 27 - ], - "starting_column": 1, - "ending_column": null + "type_specific_fields": { + "parent": { + "type": "function", + "name": "functionWithDeprecatedReferences", + "source_mapping": { + "start": 420, + "length": 484, + "filename_used": "/home/travis/build/crytic/slither/tests/deprecated_calls.sol", + "filename_relative": "tests/deprecated_calls.sol", + "filename_absolute": "/home/travis/build/crytic/slither/tests/deprecated_calls.sol", + "filename_short": "tests/deprecated_calls.sol", + "lines": [ + 14, + 15, + 16, + 17, + 18, + 19, + 20, + 21, + 22, + 23, + 24, + 25, + 26 + ], + "starting_column": 5, + "ending_column": 6 + }, + "type_specific_fields": { + "parent": { + "type": "contract", + "name": "ContractWithDeprecatedReferences", + "source_mapping": { + "start": 0, + "length": 906, + "filename_used": "/home/travis/build/crytic/slither/tests/deprecated_calls.sol", + "filename_relative": "tests/deprecated_calls.sol", + "filename_absolute": "/home/travis/build/crytic/slither/tests/deprecated_calls.sol", + "filename_short": "tests/deprecated_calls.sol", + "lines": [ + 1, + 2, + 3, + 4, + 5, + 6, + 7, + 8, + 9, + 10, + 11, + 12, + 13, + 14, + 15, + 16, + 17, + 18, + 19, + 20, + 21, + 22, + 23, + 24, + 25, + 26, + 27 + ], + "starting_column": 1, + "ending_column": null + } + }, + "signature": "functionWithDeprecatedReferences()" + } } } } - } - ] - }, - { - "check": "deprecated-standards", - "impact": "Informational", - "confidence": "High", - "description": "Deprecated standard detected @ tests/deprecated_calls.sol#19:\n\t- Usage of \"block.blockhash()\" should be replaced with \"blockhash()\"\n", - "elements": [ - { - "type": "node", - "name": "blockHashResult = block.blockhash(0)", - "source_mapping": { - "start": 671, - "length": 44, - "filename_used": "/home/travis/build/crytic/slither/tests/deprecated_calls.sol", - "filename_relative": "tests/deprecated_calls.sol", - "filename_absolute": "/home/travis/build/crytic/slither/tests/deprecated_calls.sol", - "filename_short": "tests/deprecated_calls.sol", - "lines": [ - 19 - ], - "starting_column": 9, - "ending_column": 53 - }, - "function": { - "type": "function", - "name": "functionWithDeprecatedReferences", + ] + }, + { + "check": "deprecated-standards", + "impact": "Informational", + "confidence": "High", + "description": "Deprecated standard detected @ tests/deprecated_calls.sol#19:\n\t- Usage of \"block.blockhash()\" should be replaced with \"blockhash()\"\n", + "elements": [ + { + "type": "node", + "name": "blockHashResult = block.blockhash(0)", "source_mapping": { - "start": 420, - "length": 484, + "start": 671, + "length": 44, "filename_used": "/home/travis/build/crytic/slither/tests/deprecated_calls.sol", "filename_relative": "tests/deprecated_calls.sol", "filename_absolute": "/home/travis/build/crytic/slither/tests/deprecated_calls.sol", "filename_short": "tests/deprecated_calls.sol", "lines": [ - 14, - 15, - 16, - 17, - 18, - 19, - 20, - 21, - 22, - 23, - 24, - 25, - 26 + 19 ], - "starting_column": 5, - "ending_column": 6 + "starting_column": 9, + "ending_column": 53 }, - "contract": { - "type": "contract", - "name": "ContractWithDeprecatedReferences", - "source_mapping": { - "start": 0, - "length": 906, - "filename_used": "/home/travis/build/crytic/slither/tests/deprecated_calls.sol", - "filename_relative": "tests/deprecated_calls.sol", - "filename_absolute": "/home/travis/build/crytic/slither/tests/deprecated_calls.sol", - "filename_short": "tests/deprecated_calls.sol", - "lines": [ - 1, - 2, - 3, - 4, - 5, - 6, - 7, - 8, - 9, - 10, - 11, - 12, - 13, - 14, - 15, - 16, - 17, - 18, - 19, - 20, - 21, - 22, - 23, - 24, - 25, - 26, - 27 - ], - "starting_column": 1, - "ending_column": null + "type_specific_fields": { + "parent": { + "type": "function", + "name": "functionWithDeprecatedReferences", + "source_mapping": { + "start": 420, + "length": 484, + "filename_used": "/home/travis/build/crytic/slither/tests/deprecated_calls.sol", + "filename_relative": "tests/deprecated_calls.sol", + "filename_absolute": "/home/travis/build/crytic/slither/tests/deprecated_calls.sol", + "filename_short": "tests/deprecated_calls.sol", + "lines": [ + 14, + 15, + 16, + 17, + 18, + 19, + 20, + 21, + 22, + 23, + 24, + 25, + 26 + ], + "starting_column": 5, + "ending_column": 6 + }, + "type_specific_fields": { + "parent": { + "type": "contract", + "name": "ContractWithDeprecatedReferences", + "source_mapping": { + "start": 0, + "length": 906, + "filename_used": "/home/travis/build/crytic/slither/tests/deprecated_calls.sol", + "filename_relative": "tests/deprecated_calls.sol", + "filename_absolute": "/home/travis/build/crytic/slither/tests/deprecated_calls.sol", + "filename_short": "tests/deprecated_calls.sol", + "lines": [ + 1, + 2, + 3, + 4, + 5, + 6, + 7, + 8, + 9, + 10, + 11, + 12, + 13, + 14, + 15, + 16, + 17, + 18, + 19, + 20, + 21, + 22, + 23, + 24, + 25, + 26, + 27 + ], + "starting_column": 1, + "ending_column": null + } + }, + "signature": "functionWithDeprecatedReferences()" + } } } } - } - ] - }, - { - "check": "deprecated-standards", - "impact": "Informational", - "confidence": "High", - "description": "Deprecated standard detected @ tests/deprecated_calls.sol#22:\n\t- Usage of \"callcode\" should be replaced with \"delegatecall\"\n", - "elements": [ - { - "type": "node", - "name": "address(this).callcode()", - "source_mapping": { - "start": 785, - "length": 24, - "filename_used": "/home/travis/build/crytic/slither/tests/deprecated_calls.sol", - "filename_relative": "tests/deprecated_calls.sol", - "filename_absolute": "/home/travis/build/crytic/slither/tests/deprecated_calls.sol", - "filename_short": "tests/deprecated_calls.sol", - "lines": [ - 22 - ], - "starting_column": 9, - "ending_column": 33 - }, - "function": { - "type": "function", - "name": "functionWithDeprecatedReferences", + ] + }, + { + "check": "deprecated-standards", + "impact": "Informational", + "confidence": "High", + "description": "Deprecated standard detected @ tests/deprecated_calls.sol#22:\n\t- Usage of \"callcode\" should be replaced with \"delegatecall\"\n", + "elements": [ + { + "type": "node", + "name": "address(this).callcode()", "source_mapping": { - "start": 420, - "length": 484, + "start": 785, + "length": 24, "filename_used": "/home/travis/build/crytic/slither/tests/deprecated_calls.sol", "filename_relative": "tests/deprecated_calls.sol", "filename_absolute": "/home/travis/build/crytic/slither/tests/deprecated_calls.sol", "filename_short": "tests/deprecated_calls.sol", "lines": [ - 14, - 15, - 16, - 17, - 18, - 19, - 20, - 21, - 22, - 23, - 24, - 25, - 26 + 22 ], - "starting_column": 5, - "ending_column": 6 + "starting_column": 9, + "ending_column": 33 }, - "contract": { - "type": "contract", - "name": "ContractWithDeprecatedReferences", - "source_mapping": { - "start": 0, - "length": 906, - "filename_used": "/home/travis/build/crytic/slither/tests/deprecated_calls.sol", - "filename_relative": "tests/deprecated_calls.sol", - "filename_absolute": "/home/travis/build/crytic/slither/tests/deprecated_calls.sol", - "filename_short": "tests/deprecated_calls.sol", - "lines": [ - 1, - 2, - 3, - 4, - 5, - 6, - 7, - 8, - 9, - 10, - 11, - 12, - 13, - 14, - 15, - 16, - 17, - 18, - 19, - 20, - 21, - 22, - 23, - 24, - 25, - 26, - 27 - ], - "starting_column": 1, - "ending_column": null + "type_specific_fields": { + "parent": { + "type": "function", + "name": "functionWithDeprecatedReferences", + "source_mapping": { + "start": 420, + "length": 484, + "filename_used": "/home/travis/build/crytic/slither/tests/deprecated_calls.sol", + "filename_relative": "tests/deprecated_calls.sol", + "filename_absolute": "/home/travis/build/crytic/slither/tests/deprecated_calls.sol", + "filename_short": "tests/deprecated_calls.sol", + "lines": [ + 14, + 15, + 16, + 17, + 18, + 19, + 20, + 21, + 22, + 23, + 24, + 25, + 26 + ], + "starting_column": 5, + "ending_column": 6 + }, + "type_specific_fields": { + "parent": { + "type": "contract", + "name": "ContractWithDeprecatedReferences", + "source_mapping": { + "start": 0, + "length": 906, + "filename_used": "/home/travis/build/crytic/slither/tests/deprecated_calls.sol", + "filename_relative": "tests/deprecated_calls.sol", + "filename_absolute": "/home/travis/build/crytic/slither/tests/deprecated_calls.sol", + "filename_short": "tests/deprecated_calls.sol", + "lines": [ + 1, + 2, + 3, + 4, + 5, + 6, + 7, + 8, + 9, + 10, + 11, + 12, + 13, + 14, + 15, + 16, + 17, + 18, + 19, + 20, + 21, + 22, + 23, + 24, + 25, + 26, + 27 + ], + "starting_column": 1, + "ending_column": null + } + }, + "signature": "functionWithDeprecatedReferences()" + } } } } - } - ] - }, - { - "check": "deprecated-standards", - "impact": "Informational", - "confidence": "High", - "description": "Deprecated standard detected @ tests/deprecated_calls.sol#25:\n\t- Usage of \"suicide()\" should be replaced with \"selfdestruct()\"\n", - "elements": [ - { - "type": "node", - "name": "suicide(address)(address(0))", - "source_mapping": { - "start": 878, - "length": 19, - "filename_used": "/home/travis/build/crytic/slither/tests/deprecated_calls.sol", - "filename_relative": "tests/deprecated_calls.sol", - "filename_absolute": "/home/travis/build/crytic/slither/tests/deprecated_calls.sol", - "filename_short": "tests/deprecated_calls.sol", - "lines": [ - 25 - ], - "starting_column": 9, - "ending_column": 28 - }, - "function": { - "type": "function", - "name": "functionWithDeprecatedReferences", + ] + }, + { + "check": "deprecated-standards", + "impact": "Informational", + "confidence": "High", + "description": "Deprecated standard detected @ tests/deprecated_calls.sol#25:\n\t- Usage of \"suicide()\" should be replaced with \"selfdestruct()\"\n", + "elements": [ + { + "type": "node", + "name": "suicide(address)(address(0))", "source_mapping": { - "start": 420, - "length": 484, + "start": 878, + "length": 19, "filename_used": "/home/travis/build/crytic/slither/tests/deprecated_calls.sol", "filename_relative": "tests/deprecated_calls.sol", "filename_absolute": "/home/travis/build/crytic/slither/tests/deprecated_calls.sol", "filename_short": "tests/deprecated_calls.sol", "lines": [ - 14, - 15, - 16, - 17, - 18, - 19, - 20, - 21, - 22, - 23, - 24, - 25, - 26 + 25 ], - "starting_column": 5, - "ending_column": 6 + "starting_column": 9, + "ending_column": 28 }, - "contract": { - "type": "contract", - "name": "ContractWithDeprecatedReferences", - "source_mapping": { - "start": 0, - "length": 906, - "filename_used": "/home/travis/build/crytic/slither/tests/deprecated_calls.sol", - "filename_relative": "tests/deprecated_calls.sol", - "filename_absolute": "/home/travis/build/crytic/slither/tests/deprecated_calls.sol", - "filename_short": "tests/deprecated_calls.sol", - "lines": [ - 1, - 2, - 3, - 4, - 5, - 6, - 7, - 8, - 9, - 10, - 11, - 12, - 13, - 14, - 15, - 16, - 17, - 18, - 19, - 20, - 21, - 22, - 23, - 24, - 25, - 26, - 27 - ], - "starting_column": 1, - "ending_column": null + "type_specific_fields": { + "parent": { + "type": "function", + "name": "functionWithDeprecatedReferences", + "source_mapping": { + "start": 420, + "length": 484, + "filename_used": "/home/travis/build/crytic/slither/tests/deprecated_calls.sol", + "filename_relative": "tests/deprecated_calls.sol", + "filename_absolute": "/home/travis/build/crytic/slither/tests/deprecated_calls.sol", + "filename_short": "tests/deprecated_calls.sol", + "lines": [ + 14, + 15, + 16, + 17, + 18, + 19, + 20, + 21, + 22, + 23, + 24, + 25, + 26 + ], + "starting_column": 5, + "ending_column": 6 + }, + "type_specific_fields": { + "parent": { + "type": "contract", + "name": "ContractWithDeprecatedReferences", + "source_mapping": { + "start": 0, + "length": 906, + "filename_used": "/home/travis/build/crytic/slither/tests/deprecated_calls.sol", + "filename_relative": "tests/deprecated_calls.sol", + "filename_absolute": "/home/travis/build/crytic/slither/tests/deprecated_calls.sol", + "filename_short": "tests/deprecated_calls.sol", + "lines": [ + 1, + 2, + 3, + 4, + 5, + 6, + 7, + 8, + 9, + 10, + 11, + 12, + 13, + 14, + 15, + 16, + 17, + 18, + 19, + 20, + 21, + 22, + 23, + 24, + 25, + 26, + 27 + ], + "starting_column": 1, + "ending_column": null + } + }, + "signature": "functionWithDeprecatedReferences()" + } } } } - } - ] - } - ] + ] + } + ] + } } \ No newline at end of file diff --git a/tests/expected_json/erc20_indexed.erc20-indexed.json b/tests/expected_json/erc20_indexed.erc20-indexed.json index 0fea4fe19..1a8456227 100644 --- a/tests/expected_json/erc20_indexed.erc20-indexed.json +++ b/tests/expected_json/erc20_indexed.erc20-indexed.json @@ -1,222 +1,236 @@ { "success": true, "error": null, - "results": [ - { - "check": "erc20-indexed", - "impact": "Informational", - "confidence": "High", - "description": "ERC20 event IERC20Bad.Transfer (tests/erc20_indexed.sol#19) does not index parameter 'from'\n", - "elements": [ - { - "type": "event", - "name": "Transfer", - "source_mapping": { - "start": 1090, - "length": 53, - "filename_used": "/home/travis/build/crytic/slither/tests/erc20_indexed.sol", - "filename_relative": "tests/erc20_indexed.sol", - "filename_absolute": "/home/travis/build/crytic/slither/tests/erc20_indexed.sol", - "filename_short": "tests/erc20_indexed.sol", - "lines": [ - 19 - ], - "starting_column": 5, - "ending_column": 58 - }, - "additional_fields": { - "parameter_name": "from" - }, - "contract": { - "type": "contract", - "name": "IERC20Bad", + "results": { + "detectors": [ + { + "check": "erc20-indexed", + "impact": "Informational", + "confidence": "High", + "description": "ERC20 event IERC20Bad.Transfer (tests/erc20_indexed.sol#19) does not index parameter 'from'\n", + "elements": [ + { + "type": "event", + "name": "Transfer", "source_mapping": { - "start": 622, - "length": 587, + "start": 1090, + "length": 53, "filename_used": "/home/travis/build/crytic/slither/tests/erc20_indexed.sol", "filename_relative": "tests/erc20_indexed.sol", "filename_absolute": "/home/travis/build/crytic/slither/tests/erc20_indexed.sol", "filename_short": "tests/erc20_indexed.sol", "lines": [ - 12, - 13, - 14, - 15, - 16, - 17, - 18, - 19, - 20, - 21 + 19 ], - "starting_column": 1, - "ending_column": 2 + "starting_column": 5, + "ending_column": 58 + }, + "type_specific_fields": { + "parent": { + "type": "contract", + "name": "IERC20Bad", + "source_mapping": { + "start": 622, + "length": 587, + "filename_used": "/home/travis/build/crytic/slither/tests/erc20_indexed.sol", + "filename_relative": "tests/erc20_indexed.sol", + "filename_absolute": "/home/travis/build/crytic/slither/tests/erc20_indexed.sol", + "filename_short": "tests/erc20_indexed.sol", + "lines": [ + 12, + 13, + 14, + 15, + 16, + 17, + 18, + 19, + 20, + 21 + ], + "starting_column": 1, + "ending_column": 2 + } + }, + "signature": "Transfer(address,address,uint256)" + }, + "additional_fields": { + "parameter_name": "from" } } - } - ] - }, - { - "check": "erc20-indexed", - "impact": "Informational", - "confidence": "High", - "description": "ERC20 event IERC20Bad.Transfer (tests/erc20_indexed.sol#19) does not index parameter 'to'\n", - "elements": [ - { - "type": "event", - "name": "Transfer", - "source_mapping": { - "start": 1090, - "length": 53, - "filename_used": "/home/travis/build/crytic/slither/tests/erc20_indexed.sol", - "filename_relative": "tests/erc20_indexed.sol", - "filename_absolute": "/home/travis/build/crytic/slither/tests/erc20_indexed.sol", - "filename_short": "tests/erc20_indexed.sol", - "lines": [ - 19 - ], - "starting_column": 5, - "ending_column": 58 - }, - "additional_fields": { - "parameter_name": "to" - }, - "contract": { - "type": "contract", - "name": "IERC20Bad", + ] + }, + { + "check": "erc20-indexed", + "impact": "Informational", + "confidence": "High", + "description": "ERC20 event IERC20Bad.Transfer (tests/erc20_indexed.sol#19) does not index parameter 'to'\n", + "elements": [ + { + "type": "event", + "name": "Transfer", "source_mapping": { - "start": 622, - "length": 587, + "start": 1090, + "length": 53, "filename_used": "/home/travis/build/crytic/slither/tests/erc20_indexed.sol", "filename_relative": "tests/erc20_indexed.sol", "filename_absolute": "/home/travis/build/crytic/slither/tests/erc20_indexed.sol", "filename_short": "tests/erc20_indexed.sol", "lines": [ - 12, - 13, - 14, - 15, - 16, - 17, - 18, - 19, - 20, - 21 + 19 ], - "starting_column": 1, - "ending_column": 2 + "starting_column": 5, + "ending_column": 58 + }, + "type_specific_fields": { + "parent": { + "type": "contract", + "name": "IERC20Bad", + "source_mapping": { + "start": 622, + "length": 587, + "filename_used": "/home/travis/build/crytic/slither/tests/erc20_indexed.sol", + "filename_relative": "tests/erc20_indexed.sol", + "filename_absolute": "/home/travis/build/crytic/slither/tests/erc20_indexed.sol", + "filename_short": "tests/erc20_indexed.sol", + "lines": [ + 12, + 13, + 14, + 15, + 16, + 17, + 18, + 19, + 20, + 21 + ], + "starting_column": 1, + "ending_column": 2 + } + }, + "signature": "Transfer(address,address,uint256)" + }, + "additional_fields": { + "parameter_name": "to" } } - } - ] - }, - { - "check": "erc20-indexed", - "impact": "Informational", - "confidence": "High", - "description": "ERC20 event IERC20Bad.Approval (tests/erc20_indexed.sol#20) does not index parameter 'owner'\n", - "elements": [ - { - "type": "event", - "name": "Approval", - "source_mapping": { - "start": 1148, - "length": 59, - "filename_used": "/home/travis/build/crytic/slither/tests/erc20_indexed.sol", - "filename_relative": "tests/erc20_indexed.sol", - "filename_absolute": "/home/travis/build/crytic/slither/tests/erc20_indexed.sol", - "filename_short": "tests/erc20_indexed.sol", - "lines": [ - 20 - ], - "starting_column": 5, - "ending_column": 64 - }, - "additional_fields": { - "parameter_name": "owner" - }, - "contract": { - "type": "contract", - "name": "IERC20Bad", + ] + }, + { + "check": "erc20-indexed", + "impact": "Informational", + "confidence": "High", + "description": "ERC20 event IERC20Bad.Approval (tests/erc20_indexed.sol#20) does not index parameter 'owner'\n", + "elements": [ + { + "type": "event", + "name": "Approval", "source_mapping": { - "start": 622, - "length": 587, + "start": 1148, + "length": 59, "filename_used": "/home/travis/build/crytic/slither/tests/erc20_indexed.sol", "filename_relative": "tests/erc20_indexed.sol", "filename_absolute": "/home/travis/build/crytic/slither/tests/erc20_indexed.sol", "filename_short": "tests/erc20_indexed.sol", "lines": [ - 12, - 13, - 14, - 15, - 16, - 17, - 18, - 19, - 20, - 21 + 20 ], - "starting_column": 1, - "ending_column": 2 + "starting_column": 5, + "ending_column": 64 + }, + "type_specific_fields": { + "parent": { + "type": "contract", + "name": "IERC20Bad", + "source_mapping": { + "start": 622, + "length": 587, + "filename_used": "/home/travis/build/crytic/slither/tests/erc20_indexed.sol", + "filename_relative": "tests/erc20_indexed.sol", + "filename_absolute": "/home/travis/build/crytic/slither/tests/erc20_indexed.sol", + "filename_short": "tests/erc20_indexed.sol", + "lines": [ + 12, + 13, + 14, + 15, + 16, + 17, + 18, + 19, + 20, + 21 + ], + "starting_column": 1, + "ending_column": 2 + } + }, + "signature": "Approval(address,address,uint256)" + }, + "additional_fields": { + "parameter_name": "owner" } } - } - ] - }, - { - "check": "erc20-indexed", - "impact": "Informational", - "confidence": "High", - "description": "ERC20 event IERC20Bad.Approval (tests/erc20_indexed.sol#20) does not index parameter 'spender'\n", - "elements": [ - { - "type": "event", - "name": "Approval", - "source_mapping": { - "start": 1148, - "length": 59, - "filename_used": "/home/travis/build/crytic/slither/tests/erc20_indexed.sol", - "filename_relative": "tests/erc20_indexed.sol", - "filename_absolute": "/home/travis/build/crytic/slither/tests/erc20_indexed.sol", - "filename_short": "tests/erc20_indexed.sol", - "lines": [ - 20 - ], - "starting_column": 5, - "ending_column": 64 - }, - "additional_fields": { - "parameter_name": "spender" - }, - "contract": { - "type": "contract", - "name": "IERC20Bad", + ] + }, + { + "check": "erc20-indexed", + "impact": "Informational", + "confidence": "High", + "description": "ERC20 event IERC20Bad.Approval (tests/erc20_indexed.sol#20) does not index parameter 'spender'\n", + "elements": [ + { + "type": "event", + "name": "Approval", "source_mapping": { - "start": 622, - "length": 587, + "start": 1148, + "length": 59, "filename_used": "/home/travis/build/crytic/slither/tests/erc20_indexed.sol", "filename_relative": "tests/erc20_indexed.sol", "filename_absolute": "/home/travis/build/crytic/slither/tests/erc20_indexed.sol", "filename_short": "tests/erc20_indexed.sol", "lines": [ - 12, - 13, - 14, - 15, - 16, - 17, - 18, - 19, - 20, - 21 + 20 ], - "starting_column": 1, - "ending_column": 2 + "starting_column": 5, + "ending_column": 64 + }, + "type_specific_fields": { + "parent": { + "type": "contract", + "name": "IERC20Bad", + "source_mapping": { + "start": 622, + "length": 587, + "filename_used": "/home/travis/build/crytic/slither/tests/erc20_indexed.sol", + "filename_relative": "tests/erc20_indexed.sol", + "filename_absolute": "/home/travis/build/crytic/slither/tests/erc20_indexed.sol", + "filename_short": "tests/erc20_indexed.sol", + "lines": [ + 12, + 13, + 14, + 15, + 16, + 17, + 18, + 19, + 20, + 21 + ], + "starting_column": 1, + "ending_column": 2 + } + }, + "signature": "Approval(address,address,uint256)" + }, + "additional_fields": { + "parameter_name": "spender" } } - } - ] - } - ] + ] + } + ] + } } \ No newline at end of file diff --git a/tests/expected_json/external_function.external-function.json b/tests/expected_json/external_function.external-function.json index 4457e9a64..3c8369a91 100644 --- a/tests/expected_json/external_function.external-function.json +++ b/tests/expected_json/external_function.external-function.json @@ -1,234 +1,220 @@ { "success": true, "error": null, - "results": [ - { - "check": "external-function", - "impact": "Informational", - "confidence": "High", - "description": "ContractWithFunctionNotCalled.funcNotCalled3 (tests/external_function.sol#13-15) should be declared external\n", - "elements": [ - { - "type": "function", - "name": "funcNotCalled3", - "source_mapping": { - "start": 259, - "length": 41, - "filename_used": "/home/travis/build/crytic/slither/tests/external_function.sol", - "filename_relative": "tests/external_function.sol", - "filename_absolute": "/home/travis/build/crytic/slither/tests/external_function.sol", - "filename_short": "tests/external_function.sol", - "lines": [ - 13, - 14, - 15 - ], - "starting_column": 5, - "ending_column": 6 - }, - "contract": { - "type": "contract", - "name": "ContractWithFunctionNotCalled", + "results": { + "detectors": [ + { + "check": "external-function", + "impact": "Informational", + "confidence": "High", + "description": "ContractWithFunctionNotCalled.funcNotCalled3 (tests/external_function.sol#13-15) should be declared external\n", + "elements": [ + { + "type": "function", + "name": "funcNotCalled3", "source_mapping": { - "start": 213, - "length": 258, + "start": 259, + "length": 41, "filename_used": "/home/travis/build/crytic/slither/tests/external_function.sol", "filename_relative": "tests/external_function.sol", "filename_absolute": "/home/travis/build/crytic/slither/tests/external_function.sol", "filename_short": "tests/external_function.sol", "lines": [ - 11, - 12, 13, 14, - 15, - 16, - 17, - 18, - 19, - 20, - 21, - 22, - 23, - 24, - 25, - 26, - 27, - 28, - 29 + 15 ], - "starting_column": 1, - "ending_column": 2 + "starting_column": 5, + "ending_column": 6 + }, + "type_specific_fields": { + "parent": { + "type": "contract", + "name": "ContractWithFunctionNotCalled", + "source_mapping": { + "start": 213, + "length": 258, + "filename_used": "/home/travis/build/crytic/slither/tests/external_function.sol", + "filename_relative": "tests/external_function.sol", + "filename_absolute": "/home/travis/build/crytic/slither/tests/external_function.sol", + "filename_short": "tests/external_function.sol", + "lines": [ + 11, + 12, + 13, + 14, + 15, + 16, + 17, + 18, + 19, + 20, + 21, + 22, + 23, + 24, + 25, + 26, + 27, + 28, + 29 + ], + "starting_column": 1, + "ending_column": 2 + } + }, + "signature": "funcNotCalled3()" } } - } - ] - }, - { - "check": "external-function", - "impact": "Informational", - "confidence": "High", - "description": "ContractWithFunctionNotCalled.funcNotCalled2 (tests/external_function.sol#17-19) should be declared external\n", - "elements": [ - { - "type": "function", - "name": "funcNotCalled2", - "source_mapping": { - "start": 306, - "length": 41, - "filename_used": "/home/travis/build/crytic/slither/tests/external_function.sol", - "filename_relative": "tests/external_function.sol", - "filename_absolute": "/home/travis/build/crytic/slither/tests/external_function.sol", - "filename_short": "tests/external_function.sol", - "lines": [ - 17, - 18, - 19 - ], - "starting_column": 5, - "ending_column": 6 - }, - "contract": { - "type": "contract", - "name": "ContractWithFunctionNotCalled", + ] + }, + { + "check": "external-function", + "impact": "Informational", + "confidence": "High", + "description": "ContractWithFunctionNotCalled.funcNotCalled2 (tests/external_function.sol#17-19) should be declared external\n", + "elements": [ + { + "type": "function", + "name": "funcNotCalled2", "source_mapping": { - "start": 213, - "length": 258, + "start": 306, + "length": 41, "filename_used": "/home/travis/build/crytic/slither/tests/external_function.sol", "filename_relative": "tests/external_function.sol", "filename_absolute": "/home/travis/build/crytic/slither/tests/external_function.sol", "filename_short": "tests/external_function.sol", "lines": [ - 11, - 12, - 13, - 14, - 15, - 16, 17, 18, - 19, - 20, - 21, - 22, - 23, - 24, - 25, - 26, - 27, - 28, - 29 + 19 ], - "starting_column": 1, - "ending_column": 2 + "starting_column": 5, + "ending_column": 6 + }, + "type_specific_fields": { + "parent": { + "type": "contract", + "name": "ContractWithFunctionNotCalled", + "source_mapping": { + "start": 213, + "length": 258, + "filename_used": "/home/travis/build/crytic/slither/tests/external_function.sol", + "filename_relative": "tests/external_function.sol", + "filename_absolute": "/home/travis/build/crytic/slither/tests/external_function.sol", + "filename_short": "tests/external_function.sol", + "lines": [ + 11, + 12, + 13, + 14, + 15, + 16, + 17, + 18, + 19, + 20, + 21, + 22, + 23, + 24, + 25, + 26, + 27, + 28, + 29 + ], + "starting_column": 1, + "ending_column": 2 + } + }, + "signature": "funcNotCalled2()" } } - } - ] - }, - { - "check": "external-function", - "impact": "Informational", - "confidence": "High", - "description": "ContractWithFunctionNotCalled.funcNotCalled (tests/external_function.sol#21-23) should be declared external\n", - "elements": [ - { - "type": "function", - "name": "funcNotCalled", - "source_mapping": { - "start": 353, - "length": 40, - "filename_used": "/home/travis/build/crytic/slither/tests/external_function.sol", - "filename_relative": "tests/external_function.sol", - "filename_absolute": "/home/travis/build/crytic/slither/tests/external_function.sol", - "filename_short": "tests/external_function.sol", - "lines": [ - 21, - 22, - 23 - ], - "starting_column": 5, - "ending_column": 6 - }, - "contract": { - "type": "contract", - "name": "ContractWithFunctionNotCalled", + ] + }, + { + "check": "external-function", + "impact": "Informational", + "confidence": "High", + "description": "ContractWithFunctionNotCalled.funcNotCalled (tests/external_function.sol#21-23) should be declared external\n", + "elements": [ + { + "type": "function", + "name": "funcNotCalled", "source_mapping": { - "start": 213, - "length": 258, + "start": 353, + "length": 40, "filename_used": "/home/travis/build/crytic/slither/tests/external_function.sol", "filename_relative": "tests/external_function.sol", "filename_absolute": "/home/travis/build/crytic/slither/tests/external_function.sol", "filename_short": "tests/external_function.sol", "lines": [ - 11, - 12, - 13, - 14, - 15, - 16, - 17, - 18, - 19, - 20, 21, 22, - 23, - 24, - 25, - 26, - 27, - 28, - 29 + 23 ], - "starting_column": 1, - "ending_column": 2 + "starting_column": 5, + "ending_column": 6 + }, + "type_specific_fields": { + "parent": { + "type": "contract", + "name": "ContractWithFunctionNotCalled", + "source_mapping": { + "start": 213, + "length": 258, + "filename_used": "/home/travis/build/crytic/slither/tests/external_function.sol", + "filename_relative": "tests/external_function.sol", + "filename_absolute": "/home/travis/build/crytic/slither/tests/external_function.sol", + "filename_short": "tests/external_function.sol", + "lines": [ + 11, + 12, + 13, + 14, + 15, + 16, + 17, + 18, + 19, + 20, + 21, + 22, + 23, + 24, + 25, + 26, + 27, + 28, + 29 + ], + "starting_column": 1, + "ending_column": 2 + } + }, + "signature": "funcNotCalled()" } } - } - ] - }, - { - "check": "external-function", - "impact": "Informational", - "confidence": "High", - "description": "ContractWithFunctionNotCalled2.funcNotCalled (tests/external_function.sol#32-39) should be declared external\n", - "elements": [ - { - "type": "function", - "name": "funcNotCalled", - "source_mapping": { - "start": 554, - "length": 325, - "filename_used": "/home/travis/build/crytic/slither/tests/external_function.sol", - "filename_relative": "tests/external_function.sol", - "filename_absolute": "/home/travis/build/crytic/slither/tests/external_function.sol", - "filename_short": "tests/external_function.sol", - "lines": [ - 32, - 33, - 34, - 35, - 36, - 37, - 38, - 39 - ], - "starting_column": 5, - "ending_column": 6 - }, - "contract": { - "type": "contract", - "name": "ContractWithFunctionNotCalled2", + ] + }, + { + "check": "external-function", + "impact": "Informational", + "confidence": "High", + "description": "ContractWithFunctionNotCalled2.funcNotCalled (tests/external_function.sol#32-39) should be declared external\n", + "elements": [ + { + "type": "function", + "name": "funcNotCalled", "source_mapping": { - "start": 473, - "length": 408, + "start": 554, + "length": 325, "filename_used": "/home/travis/build/crytic/slither/tests/external_function.sol", "filename_relative": "tests/external_function.sol", "filename_absolute": "/home/travis/build/crytic/slither/tests/external_function.sol", "filename_short": "tests/external_function.sol", "lines": [ - 31, 32, 33, 34, @@ -236,15 +222,43 @@ 36, 37, 38, - 39, - 40 + 39 ], - "starting_column": 1, - "ending_column": 2 + "starting_column": 5, + "ending_column": 6 + }, + "type_specific_fields": { + "parent": { + "type": "contract", + "name": "ContractWithFunctionNotCalled2", + "source_mapping": { + "start": 473, + "length": 408, + "filename_used": "/home/travis/build/crytic/slither/tests/external_function.sol", + "filename_relative": "tests/external_function.sol", + "filename_absolute": "/home/travis/build/crytic/slither/tests/external_function.sol", + "filename_short": "tests/external_function.sol", + "lines": [ + 31, + 32, + 33, + 34, + 35, + 36, + 37, + 38, + 39, + 40 + ], + "starting_column": 1, + "ending_column": 2 + } + }, + "signature": "funcNotCalled()" } } - } - ] - } - ] + ] + } + ] + } } \ No newline at end of file diff --git a/tests/expected_json/external_function_2.external-function.json b/tests/expected_json/external_function_2.external-function.json index 0e2fa6477..f8c07c1d8 100644 --- a/tests/expected_json/external_function_2.external-function.json +++ b/tests/expected_json/external_function_2.external-function.json @@ -1,5 +1,5 @@ { "success": true, "error": null, - "results": [] + "results": {} } \ No newline at end of file diff --git a/tests/expected_json/incorrect_equality.incorrect-equality.json b/tests/expected_json/incorrect_equality.incorrect-equality.json index ae2a7f0a9..2c9053dc2 100644 --- a/tests/expected_json/incorrect_equality.incorrect-equality.json +++ b/tests/expected_json/incorrect_equality.incorrect-equality.json @@ -1,30 +1,91 @@ { "success": true, "error": null, - "results": [ - { - "check": "incorrect-equality", - "impact": "Medium", - "confidence": "High", - "description": "ERC20TestBalance.bad0 (tests/incorrect_equality.sol#21-23) uses a dangerous strict equality:\n\t- require(bool)(erc.balanceOf(address(this)) == 10)\n", - "elements": [ - { - "type": "node", - "name": "require(bool)(erc.balanceOf(address(this)) == 10)", - "source_mapping": { - "start": 455, - "length": 43, - "filename_used": "/home/travis/build/crytic/slither/tests/incorrect_equality.sol", - "filename_relative": "tests/incorrect_equality.sol", - "filename_absolute": "/home/travis/build/crytic/slither/tests/incorrect_equality.sol", - "filename_short": "tests/incorrect_equality.sol", - "lines": [ - 22 - ], - "starting_column": 9, - "ending_column": 52 + "results": { + "detectors": [ + { + "check": "incorrect-equality", + "impact": "Medium", + "confidence": "High", + "description": "ERC20TestBalance.bad0 (tests/incorrect_equality.sol#21-23) uses a dangerous strict equality:\n\t- require(bool)(erc.balanceOf(address(this)) == 10)\n", + "elements": [ + { + "type": "node", + "name": "require(bool)(erc.balanceOf(address(this)) == 10)", + "source_mapping": { + "start": 455, + "length": 43, + "filename_used": "/home/travis/build/crytic/slither/tests/incorrect_equality.sol", + "filename_relative": "tests/incorrect_equality.sol", + "filename_absolute": "/home/travis/build/crytic/slither/tests/incorrect_equality.sol", + "filename_short": "tests/incorrect_equality.sol", + "lines": [ + 22 + ], + "starting_column": 9, + "ending_column": 52 + }, + "type_specific_fields": { + "parent": { + "type": "function", + "name": "bad0", + "source_mapping": { + "start": 404, + "length": 101, + "filename_used": "/home/travis/build/crytic/slither/tests/incorrect_equality.sol", + "filename_relative": "tests/incorrect_equality.sol", + "filename_absolute": "/home/travis/build/crytic/slither/tests/incorrect_equality.sol", + "filename_short": "tests/incorrect_equality.sol", + "lines": [ + 21, + 22, + 23 + ], + "starting_column": 5, + "ending_column": 6 + }, + "type_specific_fields": { + "parent": { + "type": "contract", + "name": "ERC20TestBalance", + "source_mapping": { + "start": 165, + "length": 445, + "filename_used": "/home/travis/build/crytic/slither/tests/incorrect_equality.sol", + "filename_relative": "tests/incorrect_equality.sol", + "filename_absolute": "/home/travis/build/crytic/slither/tests/incorrect_equality.sol", + "filename_short": "tests/incorrect_equality.sol", + "lines": [ + 10, + 11, + 12, + 13, + 14, + 15, + 16, + 17, + 18, + 19, + 20, + 21, + 22, + 23, + 24, + 25, + 26, + 27, + 28 + ], + "starting_column": 1, + "ending_column": 2 + } + }, + "signature": "bad0(ERC20Function)" + } + } + } }, - "function": { + { "type": "function", "name": "bad0", "source_mapping": { @@ -42,122 +103,130 @@ "starting_column": 5, "ending_column": 6 }, - "contract": { - "type": "contract", - "name": "ERC20TestBalance", - "source_mapping": { - "start": 165, - "length": 445, - "filename_used": "/home/travis/build/crytic/slither/tests/incorrect_equality.sol", - "filename_relative": "tests/incorrect_equality.sol", - "filename_absolute": "/home/travis/build/crytic/slither/tests/incorrect_equality.sol", - "filename_short": "tests/incorrect_equality.sol", - "lines": [ - 10, - 11, - 12, - 13, - 14, - 15, - 16, - 17, - 18, - 19, - 20, - 21, - 22, - 23, - 24, - 25, - 26, - 27, - 28 - ], - "starting_column": 1, - "ending_column": 2 - } + "type_specific_fields": { + "parent": { + "type": "contract", + "name": "ERC20TestBalance", + "source_mapping": { + "start": 165, + "length": 445, + "filename_used": "/home/travis/build/crytic/slither/tests/incorrect_equality.sol", + "filename_relative": "tests/incorrect_equality.sol", + "filename_absolute": "/home/travis/build/crytic/slither/tests/incorrect_equality.sol", + "filename_short": "tests/incorrect_equality.sol", + "lines": [ + 10, + 11, + 12, + 13, + 14, + 15, + 16, + 17, + 18, + 19, + 20, + 21, + 22, + 23, + 24, + 25, + 26, + 27, + 28 + ], + "starting_column": 1, + "ending_column": 2 + } + }, + "signature": "bad0(ERC20Function)" } } - }, - { - "type": "function", - "name": "bad0", - "source_mapping": { - "start": 404, - "length": 101, - "filename_used": "/home/travis/build/crytic/slither/tests/incorrect_equality.sol", - "filename_relative": "tests/incorrect_equality.sol", - "filename_absolute": "/home/travis/build/crytic/slither/tests/incorrect_equality.sol", - "filename_short": "tests/incorrect_equality.sol", - "lines": [ - 21, - 22, - 23 - ], - "starting_column": 5, - "ending_column": 6 - }, - "contract": { - "type": "contract", - "name": "ERC20TestBalance", + ] + }, + { + "check": "incorrect-equality", + "impact": "Medium", + "confidence": "High", + "description": "ERC20TestBalance.bad1 (tests/incorrect_equality.sol#25-27) uses a dangerous strict equality:\n\t- require(bool)(erc.balanceOf(msg.sender) == 10)\n", + "elements": [ + { + "type": "node", + "name": "require(bool)(erc.balanceOf(msg.sender) == 10)", "source_mapping": { - "start": 165, - "length": 445, + "start": 562, + "length": 39, "filename_used": "/home/travis/build/crytic/slither/tests/incorrect_equality.sol", "filename_relative": "tests/incorrect_equality.sol", "filename_absolute": "/home/travis/build/crytic/slither/tests/incorrect_equality.sol", "filename_short": "tests/incorrect_equality.sol", "lines": [ - 10, - 11, - 12, - 13, - 14, - 15, - 16, - 17, - 18, - 19, - 20, - 21, - 22, - 23, - 24, - 25, - 26, - 27, - 28 + 26 ], - "starting_column": 1, - "ending_column": 2 + "starting_column": 9, + "ending_column": 48 + }, + "type_specific_fields": { + "parent": { + "type": "function", + "name": "bad1", + "source_mapping": { + "start": 511, + "length": 97, + "filename_used": "/home/travis/build/crytic/slither/tests/incorrect_equality.sol", + "filename_relative": "tests/incorrect_equality.sol", + "filename_absolute": "/home/travis/build/crytic/slither/tests/incorrect_equality.sol", + "filename_short": "tests/incorrect_equality.sol", + "lines": [ + 25, + 26, + 27 + ], + "starting_column": 5, + "ending_column": 6 + }, + "type_specific_fields": { + "parent": { + "type": "contract", + "name": "ERC20TestBalance", + "source_mapping": { + "start": 165, + "length": 445, + "filename_used": "/home/travis/build/crytic/slither/tests/incorrect_equality.sol", + "filename_relative": "tests/incorrect_equality.sol", + "filename_absolute": "/home/travis/build/crytic/slither/tests/incorrect_equality.sol", + "filename_short": "tests/incorrect_equality.sol", + "lines": [ + 10, + 11, + 12, + 13, + 14, + 15, + 16, + 17, + 18, + 19, + 20, + 21, + 22, + 23, + 24, + 25, + 26, + 27, + 28 + ], + "starting_column": 1, + "ending_column": 2 + } + }, + "signature": "bad1(ERC20Variable)" + } + } } - } - } - ] - }, - { - "check": "incorrect-equality", - "impact": "Medium", - "confidence": "High", - "description": "ERC20TestBalance.bad1 (tests/incorrect_equality.sol#25-27) uses a dangerous strict equality:\n\t- require(bool)(erc.balanceOf(msg.sender) == 10)\n", - "elements": [ - { - "type": "node", - "name": "require(bool)(erc.balanceOf(msg.sender) == 10)", - "source_mapping": { - "start": 562, - "length": 39, - "filename_used": "/home/travis/build/crytic/slither/tests/incorrect_equality.sol", - "filename_relative": "tests/incorrect_equality.sol", - "filename_absolute": "/home/travis/build/crytic/slither/tests/incorrect_equality.sol", - "filename_short": "tests/incorrect_equality.sol", - "lines": [ - 26 - ], - "starting_column": 9, - "ending_column": 48 }, - "function": { + { "type": "function", "name": "bad1", "source_mapping": { @@ -175,122 +244,180 @@ "starting_column": 5, "ending_column": 6 }, - "contract": { - "type": "contract", - "name": "ERC20TestBalance", - "source_mapping": { - "start": 165, - "length": 445, - "filename_used": "/home/travis/build/crytic/slither/tests/incorrect_equality.sol", - "filename_relative": "tests/incorrect_equality.sol", - "filename_absolute": "/home/travis/build/crytic/slither/tests/incorrect_equality.sol", - "filename_short": "tests/incorrect_equality.sol", - "lines": [ - 10, - 11, - 12, - 13, - 14, - 15, - 16, - 17, - 18, - 19, - 20, - 21, - 22, - 23, - 24, - 25, - 26, - 27, - 28 - ], - "starting_column": 1, - "ending_column": 2 - } + "type_specific_fields": { + "parent": { + "type": "contract", + "name": "ERC20TestBalance", + "source_mapping": { + "start": 165, + "length": 445, + "filename_used": "/home/travis/build/crytic/slither/tests/incorrect_equality.sol", + "filename_relative": "tests/incorrect_equality.sol", + "filename_absolute": "/home/travis/build/crytic/slither/tests/incorrect_equality.sol", + "filename_short": "tests/incorrect_equality.sol", + "lines": [ + 10, + 11, + 12, + 13, + 14, + 15, + 16, + 17, + 18, + 19, + 20, + 21, + 22, + 23, + 24, + 25, + 26, + 27, + 28 + ], + "starting_column": 1, + "ending_column": 2 + } + }, + "signature": "bad1(ERC20Variable)" } } - }, - { - "type": "function", - "name": "bad1", - "source_mapping": { - "start": 511, - "length": 97, - "filename_used": "/home/travis/build/crytic/slither/tests/incorrect_equality.sol", - "filename_relative": "tests/incorrect_equality.sol", - "filename_absolute": "/home/travis/build/crytic/slither/tests/incorrect_equality.sol", - "filename_short": "tests/incorrect_equality.sol", - "lines": [ - 25, - 26, - 27 - ], - "starting_column": 5, - "ending_column": 6 - }, - "contract": { - "type": "contract", - "name": "ERC20TestBalance", + ] + }, + { + "check": "incorrect-equality", + "impact": "Medium", + "confidence": "High", + "description": "TestContractBalance.bad0 (tests/incorrect_equality.sol#32-35) uses a dangerous strict equality:\n\t- require(bool)(address(address(this)).balance == 10000000000000000000)\n", + "elements": [ + { + "type": "node", + "name": "require(bool)(address(address(this)).balance == 10000000000000000000)", "source_mapping": { - "start": 165, - "length": 445, + "start": 683, + "length": 51, "filename_used": "/home/travis/build/crytic/slither/tests/incorrect_equality.sol", "filename_relative": "tests/incorrect_equality.sol", "filename_absolute": "/home/travis/build/crytic/slither/tests/incorrect_equality.sol", "filename_short": "tests/incorrect_equality.sol", "lines": [ - 10, - 11, - 12, - 13, - 14, - 15, - 16, - 17, - 18, - 19, - 20, - 21, - 22, - 23, - 24, - 25, - 26, - 27, - 28 + 33 ], - "starting_column": 1, - "ending_column": 2 + "starting_column": 9, + "ending_column": 60 + }, + "type_specific_fields": { + "parent": { + "type": "function", + "name": "bad0", + "source_mapping": { + "start": 648, + "length": 133, + "filename_used": "/home/travis/build/crytic/slither/tests/incorrect_equality.sol", + "filename_relative": "tests/incorrect_equality.sol", + "filename_absolute": "/home/travis/build/crytic/slither/tests/incorrect_equality.sol", + "filename_short": "tests/incorrect_equality.sol", + "lines": [ + 32, + 33, + 34, + 35 + ], + "starting_column": 5, + "ending_column": 6 + }, + "type_specific_fields": { + "parent": { + "type": "contract", + "name": "TestContractBalance", + "source_mapping": { + "start": 612, + "length": 1754, + "filename_used": "/home/travis/build/crytic/slither/tests/incorrect_equality.sol", + "filename_relative": "tests/incorrect_equality.sol", + "filename_absolute": "/home/travis/build/crytic/slither/tests/incorrect_equality.sol", + "filename_short": "tests/incorrect_equality.sol", + "lines": [ + 30, + 31, + 32, + 33, + 34, + 35, + 36, + 37, + 38, + 39, + 40, + 41, + 42, + 43, + 44, + 45, + 46, + 47, + 48, + 49, + 50, + 51, + 52, + 53, + 54, + 55, + 56, + 57, + 58, + 59, + 60, + 61, + 62, + 63, + 64, + 65, + 66, + 67, + 68, + 69, + 70, + 71, + 72, + 73, + 74, + 75, + 76, + 77, + 78, + 79, + 80, + 81, + 82, + 83, + 84, + 85, + 86, + 87, + 88, + 89, + 90, + 91, + 92, + 93, + 94, + 95, + 96, + 97 + ], + "starting_column": 1, + "ending_column": 2 + } + }, + "signature": "bad0()" + } + } } - } - } - ] - }, - { - "check": "incorrect-equality", - "impact": "Medium", - "confidence": "High", - "description": "TestContractBalance.bad0 (tests/incorrect_equality.sol#32-35) uses a dangerous strict equality:\n\t- require(bool)(address(address(this)).balance == 10000000000000000000)\n", - "elements": [ - { - "type": "node", - "name": "require(bool)(address(address(this)).balance == 10000000000000000000)", - "source_mapping": { - "start": 683, - "length": 51, - "filename_used": "/home/travis/build/crytic/slither/tests/incorrect_equality.sol", - "filename_relative": "tests/incorrect_equality.sol", - "filename_absolute": "/home/travis/build/crytic/slither/tests/incorrect_equality.sol", - "filename_short": "tests/incorrect_equality.sol", - "lines": [ - 33 - ], - "starting_column": 9, - "ending_column": 60 }, - "function": { + { "type": "function", "name": "bad0", "source_mapping": { @@ -309,221 +436,229 @@ "starting_column": 5, "ending_column": 6 }, - "contract": { - "type": "contract", - "name": "TestContractBalance", - "source_mapping": { - "start": 612, - "length": 1754, - "filename_used": "/home/travis/build/crytic/slither/tests/incorrect_equality.sol", - "filename_relative": "tests/incorrect_equality.sol", - "filename_absolute": "/home/travis/build/crytic/slither/tests/incorrect_equality.sol", - "filename_short": "tests/incorrect_equality.sol", - "lines": [ - 30, - 31, - 32, - 33, - 34, - 35, - 36, - 37, - 38, - 39, - 40, - 41, - 42, - 43, - 44, - 45, - 46, - 47, - 48, - 49, - 50, - 51, - 52, - 53, - 54, - 55, - 56, - 57, - 58, - 59, - 60, - 61, - 62, - 63, - 64, - 65, - 66, - 67, - 68, - 69, - 70, - 71, - 72, - 73, - 74, - 75, - 76, - 77, - 78, - 79, - 80, - 81, - 82, - 83, - 84, - 85, - 86, - 87, - 88, - 89, - 90, - 91, - 92, - 93, - 94, - 95, - 96, - 97 - ], - "starting_column": 1, - "ending_column": 2 - } + "type_specific_fields": { + "parent": { + "type": "contract", + "name": "TestContractBalance", + "source_mapping": { + "start": 612, + "length": 1754, + "filename_used": "/home/travis/build/crytic/slither/tests/incorrect_equality.sol", + "filename_relative": "tests/incorrect_equality.sol", + "filename_absolute": "/home/travis/build/crytic/slither/tests/incorrect_equality.sol", + "filename_short": "tests/incorrect_equality.sol", + "lines": [ + 30, + 31, + 32, + 33, + 34, + 35, + 36, + 37, + 38, + 39, + 40, + 41, + 42, + 43, + 44, + 45, + 46, + 47, + 48, + 49, + 50, + 51, + 52, + 53, + 54, + 55, + 56, + 57, + 58, + 59, + 60, + 61, + 62, + 63, + 64, + 65, + 66, + 67, + 68, + 69, + 70, + 71, + 72, + 73, + 74, + 75, + 76, + 77, + 78, + 79, + 80, + 81, + 82, + 83, + 84, + 85, + 86, + 87, + 88, + 89, + 90, + 91, + 92, + 93, + 94, + 95, + 96, + 97 + ], + "starting_column": 1, + "ending_column": 2 + } + }, + "signature": "bad0()" } } - }, - { - "type": "function", - "name": "bad0", - "source_mapping": { - "start": 648, - "length": 133, - "filename_used": "/home/travis/build/crytic/slither/tests/incorrect_equality.sol", - "filename_relative": "tests/incorrect_equality.sol", - "filename_absolute": "/home/travis/build/crytic/slither/tests/incorrect_equality.sol", - "filename_short": "tests/incorrect_equality.sol", - "lines": [ - 32, - 33, - 34, - 35 - ], - "starting_column": 5, - "ending_column": 6 - }, - "contract": { - "type": "contract", - "name": "TestContractBalance", + ] + }, + { + "check": "incorrect-equality", + "impact": "Medium", + "confidence": "High", + "description": "TestContractBalance.bad1 (tests/incorrect_equality.sol#37-40) uses a dangerous strict equality:\n\t- require(bool)(10000000000000000000 == address(address(this)).balance)\n", + "elements": [ + { + "type": "node", + "name": "require(bool)(10000000000000000000 == address(address(this)).balance)", "source_mapping": { - "start": 612, - "length": 1754, + "start": 822, + "length": 51, "filename_used": "/home/travis/build/crytic/slither/tests/incorrect_equality.sol", "filename_relative": "tests/incorrect_equality.sol", "filename_absolute": "/home/travis/build/crytic/slither/tests/incorrect_equality.sol", "filename_short": "tests/incorrect_equality.sol", "lines": [ - 30, - 31, - 32, - 33, - 34, - 35, - 36, - 37, - 38, - 39, - 40, - 41, - 42, - 43, - 44, - 45, - 46, - 47, - 48, - 49, - 50, - 51, - 52, - 53, - 54, - 55, - 56, - 57, - 58, - 59, - 60, - 61, - 62, - 63, - 64, - 65, - 66, - 67, - 68, - 69, - 70, - 71, - 72, - 73, - 74, - 75, - 76, - 77, - 78, - 79, - 80, - 81, - 82, - 83, - 84, - 85, - 86, - 87, - 88, - 89, - 90, - 91, - 92, - 93, - 94, - 95, - 96, - 97 + 38 ], - "starting_column": 1, - "ending_column": 2 + "starting_column": 9, + "ending_column": 60 + }, + "type_specific_fields": { + "parent": { + "type": "function", + "name": "bad1", + "source_mapping": { + "start": 787, + "length": 133, + "filename_used": "/home/travis/build/crytic/slither/tests/incorrect_equality.sol", + "filename_relative": "tests/incorrect_equality.sol", + "filename_absolute": "/home/travis/build/crytic/slither/tests/incorrect_equality.sol", + "filename_short": "tests/incorrect_equality.sol", + "lines": [ + 37, + 38, + 39, + 40 + ], + "starting_column": 5, + "ending_column": 6 + }, + "type_specific_fields": { + "parent": { + "type": "contract", + "name": "TestContractBalance", + "source_mapping": { + "start": 612, + "length": 1754, + "filename_used": "/home/travis/build/crytic/slither/tests/incorrect_equality.sol", + "filename_relative": "tests/incorrect_equality.sol", + "filename_absolute": "/home/travis/build/crytic/slither/tests/incorrect_equality.sol", + "filename_short": "tests/incorrect_equality.sol", + "lines": [ + 30, + 31, + 32, + 33, + 34, + 35, + 36, + 37, + 38, + 39, + 40, + 41, + 42, + 43, + 44, + 45, + 46, + 47, + 48, + 49, + 50, + 51, + 52, + 53, + 54, + 55, + 56, + 57, + 58, + 59, + 60, + 61, + 62, + 63, + 64, + 65, + 66, + 67, + 68, + 69, + 70, + 71, + 72, + 73, + 74, + 75, + 76, + 77, + 78, + 79, + 80, + 81, + 82, + 83, + 84, + 85, + 86, + 87, + 88, + 89, + 90, + 91, + 92, + 93, + 94, + 95, + 96, + 97 + ], + "starting_column": 1, + "ending_column": 2 + } + }, + "signature": "bad1()" + } + } } - } - } - ] - }, - { - "check": "incorrect-equality", - "impact": "Medium", - "confidence": "High", - "description": "TestContractBalance.bad1 (tests/incorrect_equality.sol#37-40) uses a dangerous strict equality:\n\t- require(bool)(10000000000000000000 == address(address(this)).balance)\n", - "elements": [ - { - "type": "node", - "name": "require(bool)(10000000000000000000 == address(address(this)).balance)", - "source_mapping": { - "start": 822, - "length": 51, - "filename_used": "/home/travis/build/crytic/slither/tests/incorrect_equality.sol", - "filename_relative": "tests/incorrect_equality.sol", - "filename_absolute": "/home/travis/build/crytic/slither/tests/incorrect_equality.sol", - "filename_short": "tests/incorrect_equality.sol", - "lines": [ - 38 - ], - "starting_column": 9, - "ending_column": 60 }, - "function": { + { "type": "function", "name": "bad1", "source_mapping": { @@ -542,221 +677,229 @@ "starting_column": 5, "ending_column": 6 }, - "contract": { - "type": "contract", - "name": "TestContractBalance", - "source_mapping": { - "start": 612, - "length": 1754, - "filename_used": "/home/travis/build/crytic/slither/tests/incorrect_equality.sol", - "filename_relative": "tests/incorrect_equality.sol", - "filename_absolute": "/home/travis/build/crytic/slither/tests/incorrect_equality.sol", - "filename_short": "tests/incorrect_equality.sol", - "lines": [ - 30, - 31, - 32, - 33, - 34, - 35, - 36, - 37, - 38, - 39, - 40, - 41, - 42, - 43, - 44, - 45, - 46, - 47, - 48, - 49, - 50, - 51, - 52, - 53, - 54, - 55, - 56, - 57, - 58, - 59, - 60, - 61, - 62, - 63, - 64, - 65, - 66, - 67, - 68, - 69, - 70, - 71, - 72, - 73, - 74, - 75, - 76, - 77, - 78, - 79, - 80, - 81, - 82, - 83, - 84, - 85, - 86, - 87, - 88, - 89, - 90, - 91, - 92, - 93, - 94, - 95, - 96, - 97 - ], - "starting_column": 1, - "ending_column": 2 - } + "type_specific_fields": { + "parent": { + "type": "contract", + "name": "TestContractBalance", + "source_mapping": { + "start": 612, + "length": 1754, + "filename_used": "/home/travis/build/crytic/slither/tests/incorrect_equality.sol", + "filename_relative": "tests/incorrect_equality.sol", + "filename_absolute": "/home/travis/build/crytic/slither/tests/incorrect_equality.sol", + "filename_short": "tests/incorrect_equality.sol", + "lines": [ + 30, + 31, + 32, + 33, + 34, + 35, + 36, + 37, + 38, + 39, + 40, + 41, + 42, + 43, + 44, + 45, + 46, + 47, + 48, + 49, + 50, + 51, + 52, + 53, + 54, + 55, + 56, + 57, + 58, + 59, + 60, + 61, + 62, + 63, + 64, + 65, + 66, + 67, + 68, + 69, + 70, + 71, + 72, + 73, + 74, + 75, + 76, + 77, + 78, + 79, + 80, + 81, + 82, + 83, + 84, + 85, + 86, + 87, + 88, + 89, + 90, + 91, + 92, + 93, + 94, + 95, + 96, + 97 + ], + "starting_column": 1, + "ending_column": 2 + } + }, + "signature": "bad1()" } } - }, - { - "type": "function", - "name": "bad1", - "source_mapping": { - "start": 787, - "length": 133, - "filename_used": "/home/travis/build/crytic/slither/tests/incorrect_equality.sol", - "filename_relative": "tests/incorrect_equality.sol", - "filename_absolute": "/home/travis/build/crytic/slither/tests/incorrect_equality.sol", - "filename_short": "tests/incorrect_equality.sol", - "lines": [ - 37, - 38, - 39, - 40 - ], - "starting_column": 5, - "ending_column": 6 - }, - "contract": { - "type": "contract", - "name": "TestContractBalance", + ] + }, + { + "check": "incorrect-equality", + "impact": "Medium", + "confidence": "High", + "description": "TestContractBalance.bad2 (tests/incorrect_equality.sol#42-45) uses a dangerous strict equality:\n\t- require(bool)(address(this).balance == 10000000000000000000)\n", + "elements": [ + { + "type": "node", + "name": "require(bool)(address(this).balance == 10000000000000000000)", "source_mapping": { - "start": 612, - "length": 1754, + "start": 961, + "length": 42, "filename_used": "/home/travis/build/crytic/slither/tests/incorrect_equality.sol", "filename_relative": "tests/incorrect_equality.sol", "filename_absolute": "/home/travis/build/crytic/slither/tests/incorrect_equality.sol", "filename_short": "tests/incorrect_equality.sol", "lines": [ - 30, - 31, - 32, - 33, - 34, - 35, - 36, - 37, - 38, - 39, - 40, - 41, - 42, - 43, - 44, - 45, - 46, - 47, - 48, - 49, - 50, - 51, - 52, - 53, - 54, - 55, - 56, - 57, - 58, - 59, - 60, - 61, - 62, - 63, - 64, - 65, - 66, - 67, - 68, - 69, - 70, - 71, - 72, - 73, - 74, - 75, - 76, - 77, - 78, - 79, - 80, - 81, - 82, - 83, - 84, - 85, - 86, - 87, - 88, - 89, - 90, - 91, - 92, - 93, - 94, - 95, - 96, - 97 + 43 ], - "starting_column": 1, - "ending_column": 2 + "starting_column": 9, + "ending_column": 51 + }, + "type_specific_fields": { + "parent": { + "type": "function", + "name": "bad2", + "source_mapping": { + "start": 926, + "length": 124, + "filename_used": "/home/travis/build/crytic/slither/tests/incorrect_equality.sol", + "filename_relative": "tests/incorrect_equality.sol", + "filename_absolute": "/home/travis/build/crytic/slither/tests/incorrect_equality.sol", + "filename_short": "tests/incorrect_equality.sol", + "lines": [ + 42, + 43, + 44, + 45 + ], + "starting_column": 5, + "ending_column": 6 + }, + "type_specific_fields": { + "parent": { + "type": "contract", + "name": "TestContractBalance", + "source_mapping": { + "start": 612, + "length": 1754, + "filename_used": "/home/travis/build/crytic/slither/tests/incorrect_equality.sol", + "filename_relative": "tests/incorrect_equality.sol", + "filename_absolute": "/home/travis/build/crytic/slither/tests/incorrect_equality.sol", + "filename_short": "tests/incorrect_equality.sol", + "lines": [ + 30, + 31, + 32, + 33, + 34, + 35, + 36, + 37, + 38, + 39, + 40, + 41, + 42, + 43, + 44, + 45, + 46, + 47, + 48, + 49, + 50, + 51, + 52, + 53, + 54, + 55, + 56, + 57, + 58, + 59, + 60, + 61, + 62, + 63, + 64, + 65, + 66, + 67, + 68, + 69, + 70, + 71, + 72, + 73, + 74, + 75, + 76, + 77, + 78, + 79, + 80, + 81, + 82, + 83, + 84, + 85, + 86, + 87, + 88, + 89, + 90, + 91, + 92, + 93, + 94, + 95, + 96, + 97 + ], + "starting_column": 1, + "ending_column": 2 + } + }, + "signature": "bad2()" + } + } } - } - } - ] - }, - { - "check": "incorrect-equality", - "impact": "Medium", - "confidence": "High", - "description": "TestContractBalance.bad2 (tests/incorrect_equality.sol#42-45) uses a dangerous strict equality:\n\t- require(bool)(address(this).balance == 10000000000000000000)\n", - "elements": [ - { - "type": "node", - "name": "require(bool)(address(this).balance == 10000000000000000000)", - "source_mapping": { - "start": 961, - "length": 42, - "filename_used": "/home/travis/build/crytic/slither/tests/incorrect_equality.sol", - "filename_relative": "tests/incorrect_equality.sol", - "filename_absolute": "/home/travis/build/crytic/slither/tests/incorrect_equality.sol", - "filename_short": "tests/incorrect_equality.sol", - "lines": [ - 43 - ], - "starting_column": 9, - "ending_column": 51 }, - "function": { + { "type": "function", "name": "bad2", "source_mapping": { @@ -775,221 +918,229 @@ "starting_column": 5, "ending_column": 6 }, - "contract": { - "type": "contract", - "name": "TestContractBalance", - "source_mapping": { - "start": 612, - "length": 1754, - "filename_used": "/home/travis/build/crytic/slither/tests/incorrect_equality.sol", - "filename_relative": "tests/incorrect_equality.sol", - "filename_absolute": "/home/travis/build/crytic/slither/tests/incorrect_equality.sol", - "filename_short": "tests/incorrect_equality.sol", - "lines": [ - 30, - 31, - 32, - 33, - 34, - 35, - 36, - 37, - 38, - 39, - 40, - 41, - 42, - 43, - 44, - 45, - 46, - 47, - 48, - 49, - 50, - 51, - 52, - 53, - 54, - 55, - 56, - 57, - 58, - 59, - 60, - 61, - 62, - 63, - 64, - 65, - 66, - 67, - 68, - 69, - 70, - 71, - 72, - 73, - 74, - 75, - 76, - 77, - 78, - 79, - 80, - 81, - 82, - 83, - 84, - 85, - 86, - 87, - 88, - 89, - 90, - 91, - 92, - 93, - 94, - 95, - 96, - 97 - ], - "starting_column": 1, - "ending_column": 2 - } + "type_specific_fields": { + "parent": { + "type": "contract", + "name": "TestContractBalance", + "source_mapping": { + "start": 612, + "length": 1754, + "filename_used": "/home/travis/build/crytic/slither/tests/incorrect_equality.sol", + "filename_relative": "tests/incorrect_equality.sol", + "filename_absolute": "/home/travis/build/crytic/slither/tests/incorrect_equality.sol", + "filename_short": "tests/incorrect_equality.sol", + "lines": [ + 30, + 31, + 32, + 33, + 34, + 35, + 36, + 37, + 38, + 39, + 40, + 41, + 42, + 43, + 44, + 45, + 46, + 47, + 48, + 49, + 50, + 51, + 52, + 53, + 54, + 55, + 56, + 57, + 58, + 59, + 60, + 61, + 62, + 63, + 64, + 65, + 66, + 67, + 68, + 69, + 70, + 71, + 72, + 73, + 74, + 75, + 76, + 77, + 78, + 79, + 80, + 81, + 82, + 83, + 84, + 85, + 86, + 87, + 88, + 89, + 90, + 91, + 92, + 93, + 94, + 95, + 96, + 97 + ], + "starting_column": 1, + "ending_column": 2 + } + }, + "signature": "bad2()" } } - }, - { - "type": "function", - "name": "bad2", - "source_mapping": { - "start": 926, - "length": 124, - "filename_used": "/home/travis/build/crytic/slither/tests/incorrect_equality.sol", - "filename_relative": "tests/incorrect_equality.sol", - "filename_absolute": "/home/travis/build/crytic/slither/tests/incorrect_equality.sol", - "filename_short": "tests/incorrect_equality.sol", - "lines": [ - 42, - 43, - 44, - 45 - ], - "starting_column": 5, - "ending_column": 6 - }, - "contract": { - "type": "contract", - "name": "TestContractBalance", + ] + }, + { + "check": "incorrect-equality", + "impact": "Medium", + "confidence": "High", + "description": "TestContractBalance.bad3 (tests/incorrect_equality.sol#47-50) uses a dangerous strict equality:\n\t- require(bool)(10000000000000000000 == address(this).balance)\n", + "elements": [ + { + "type": "node", + "name": "require(bool)(10000000000000000000 == address(this).balance)", "source_mapping": { - "start": 612, - "length": 1754, + "start": 1091, + "length": 42, "filename_used": "/home/travis/build/crytic/slither/tests/incorrect_equality.sol", "filename_relative": "tests/incorrect_equality.sol", "filename_absolute": "/home/travis/build/crytic/slither/tests/incorrect_equality.sol", "filename_short": "tests/incorrect_equality.sol", "lines": [ - 30, - 31, - 32, - 33, - 34, - 35, - 36, - 37, - 38, - 39, - 40, - 41, - 42, - 43, - 44, - 45, - 46, - 47, - 48, - 49, - 50, - 51, - 52, - 53, - 54, - 55, - 56, - 57, - 58, - 59, - 60, - 61, - 62, - 63, - 64, - 65, - 66, - 67, - 68, - 69, - 70, - 71, - 72, - 73, - 74, - 75, - 76, - 77, - 78, - 79, - 80, - 81, - 82, - 83, - 84, - 85, - 86, - 87, - 88, - 89, - 90, - 91, - 92, - 93, - 94, - 95, - 96, - 97 + 48 ], - "starting_column": 1, - "ending_column": 2 + "starting_column": 9, + "ending_column": 51 + }, + "type_specific_fields": { + "parent": { + "type": "function", + "name": "bad3", + "source_mapping": { + "start": 1056, + "length": 124, + "filename_used": "/home/travis/build/crytic/slither/tests/incorrect_equality.sol", + "filename_relative": "tests/incorrect_equality.sol", + "filename_absolute": "/home/travis/build/crytic/slither/tests/incorrect_equality.sol", + "filename_short": "tests/incorrect_equality.sol", + "lines": [ + 47, + 48, + 49, + 50 + ], + "starting_column": 5, + "ending_column": 6 + }, + "type_specific_fields": { + "parent": { + "type": "contract", + "name": "TestContractBalance", + "source_mapping": { + "start": 612, + "length": 1754, + "filename_used": "/home/travis/build/crytic/slither/tests/incorrect_equality.sol", + "filename_relative": "tests/incorrect_equality.sol", + "filename_absolute": "/home/travis/build/crytic/slither/tests/incorrect_equality.sol", + "filename_short": "tests/incorrect_equality.sol", + "lines": [ + 30, + 31, + 32, + 33, + 34, + 35, + 36, + 37, + 38, + 39, + 40, + 41, + 42, + 43, + 44, + 45, + 46, + 47, + 48, + 49, + 50, + 51, + 52, + 53, + 54, + 55, + 56, + 57, + 58, + 59, + 60, + 61, + 62, + 63, + 64, + 65, + 66, + 67, + 68, + 69, + 70, + 71, + 72, + 73, + 74, + 75, + 76, + 77, + 78, + 79, + 80, + 81, + 82, + 83, + 84, + 85, + 86, + 87, + 88, + 89, + 90, + 91, + 92, + 93, + 94, + 95, + 96, + 97 + ], + "starting_column": 1, + "ending_column": 2 + } + }, + "signature": "bad3()" + } + } } - } - } - ] - }, - { - "check": "incorrect-equality", - "impact": "Medium", - "confidence": "High", - "description": "TestContractBalance.bad3 (tests/incorrect_equality.sol#47-50) uses a dangerous strict equality:\n\t- require(bool)(10000000000000000000 == address(this).balance)\n", - "elements": [ - { - "type": "node", - "name": "require(bool)(10000000000000000000 == address(this).balance)", - "source_mapping": { - "start": 1091, - "length": 42, - "filename_used": "/home/travis/build/crytic/slither/tests/incorrect_equality.sol", - "filename_relative": "tests/incorrect_equality.sol", - "filename_absolute": "/home/travis/build/crytic/slither/tests/incorrect_equality.sol", - "filename_short": "tests/incorrect_equality.sol", - "lines": [ - 48 - ], - "starting_column": 9, - "ending_column": 51 }, - "function": { + { "type": "function", "name": "bad3", "source_mapping": { @@ -1008,223 +1159,233 @@ "starting_column": 5, "ending_column": 6 }, - "contract": { - "type": "contract", - "name": "TestContractBalance", - "source_mapping": { - "start": 612, - "length": 1754, - "filename_used": "/home/travis/build/crytic/slither/tests/incorrect_equality.sol", - "filename_relative": "tests/incorrect_equality.sol", - "filename_absolute": "/home/travis/build/crytic/slither/tests/incorrect_equality.sol", - "filename_short": "tests/incorrect_equality.sol", - "lines": [ - 30, - 31, - 32, - 33, - 34, - 35, - 36, - 37, - 38, - 39, - 40, - 41, - 42, - 43, - 44, - 45, - 46, - 47, - 48, - 49, - 50, - 51, - 52, - 53, - 54, - 55, - 56, - 57, - 58, - 59, - 60, - 61, - 62, - 63, - 64, - 65, - 66, - 67, - 68, - 69, - 70, - 71, - 72, - 73, - 74, - 75, - 76, - 77, - 78, - 79, - 80, - 81, - 82, - 83, - 84, - 85, - 86, - 87, - 88, - 89, - 90, - 91, - 92, - 93, - 94, - 95, - 96, - 97 - ], - "starting_column": 1, - "ending_column": 2 - } + "type_specific_fields": { + "parent": { + "type": "contract", + "name": "TestContractBalance", + "source_mapping": { + "start": 612, + "length": 1754, + "filename_used": "/home/travis/build/crytic/slither/tests/incorrect_equality.sol", + "filename_relative": "tests/incorrect_equality.sol", + "filename_absolute": "/home/travis/build/crytic/slither/tests/incorrect_equality.sol", + "filename_short": "tests/incorrect_equality.sol", + "lines": [ + 30, + 31, + 32, + 33, + 34, + 35, + 36, + 37, + 38, + 39, + 40, + 41, + 42, + 43, + 44, + 45, + 46, + 47, + 48, + 49, + 50, + 51, + 52, + 53, + 54, + 55, + 56, + 57, + 58, + 59, + 60, + 61, + 62, + 63, + 64, + 65, + 66, + 67, + 68, + 69, + 70, + 71, + 72, + 73, + 74, + 75, + 76, + 77, + 78, + 79, + 80, + 81, + 82, + 83, + 84, + 85, + 86, + 87, + 88, + 89, + 90, + 91, + 92, + 93, + 94, + 95, + 96, + 97 + ], + "starting_column": 1, + "ending_column": 2 + } + }, + "signature": "bad3()" } } - }, - { - "type": "function", - "name": "bad3", - "source_mapping": { - "start": 1056, - "length": 124, - "filename_used": "/home/travis/build/crytic/slither/tests/incorrect_equality.sol", - "filename_relative": "tests/incorrect_equality.sol", - "filename_absolute": "/home/travis/build/crytic/slither/tests/incorrect_equality.sol", - "filename_short": "tests/incorrect_equality.sol", - "lines": [ - 47, - 48, - 49, - 50 - ], - "starting_column": 5, - "ending_column": 6 - }, - "contract": { - "type": "contract", - "name": "TestContractBalance", + ] + }, + { + "check": "incorrect-equality", + "impact": "Medium", + "confidence": "High", + "description": "TestContractBalance.bad4 (tests/incorrect_equality.sol#52-57) uses a dangerous strict equality:\n\t- balance == 10000000000000000000\n", + "elements": [ + { + "type": "node", + "name": "balance == 10000000000000000000", "source_mapping": { - "start": 612, - "length": 1754, + "start": 1270, + "length": 80, "filename_used": "/home/travis/build/crytic/slither/tests/incorrect_equality.sol", "filename_relative": "tests/incorrect_equality.sol", "filename_absolute": "/home/travis/build/crytic/slither/tests/incorrect_equality.sol", "filename_short": "tests/incorrect_equality.sol", "lines": [ - 30, - 31, - 32, - 33, - 34, - 35, - 36, - 37, - 38, - 39, - 40, - 41, - 42, - 43, - 44, - 45, - 46, - 47, - 48, - 49, - 50, - 51, - 52, - 53, 54, 55, - 56, - 57, - 58, - 59, - 60, - 61, - 62, - 63, - 64, - 65, - 66, - 67, - 68, - 69, - 70, - 71, - 72, - 73, - 74, - 75, - 76, - 77, - 78, - 79, - 80, - 81, - 82, - 83, - 84, - 85, - 86, - 87, - 88, - 89, - 90, - 91, - 92, - 93, - 94, - 95, - 96, - 97 + 56 ], - "starting_column": 1, - "ending_column": 2 + "starting_column": 9, + "ending_column": 10 + }, + "type_specific_fields": { + "parent": { + "type": "function", + "name": "bad4", + "source_mapping": { + "start": 1186, + "length": 170, + "filename_used": "/home/travis/build/crytic/slither/tests/incorrect_equality.sol", + "filename_relative": "tests/incorrect_equality.sol", + "filename_absolute": "/home/travis/build/crytic/slither/tests/incorrect_equality.sol", + "filename_short": "tests/incorrect_equality.sol", + "lines": [ + 52, + 53, + 54, + 55, + 56, + 57 + ], + "starting_column": 5, + "ending_column": 6 + }, + "type_specific_fields": { + "parent": { + "type": "contract", + "name": "TestContractBalance", + "source_mapping": { + "start": 612, + "length": 1754, + "filename_used": "/home/travis/build/crytic/slither/tests/incorrect_equality.sol", + "filename_relative": "tests/incorrect_equality.sol", + "filename_absolute": "/home/travis/build/crytic/slither/tests/incorrect_equality.sol", + "filename_short": "tests/incorrect_equality.sol", + "lines": [ + 30, + 31, + 32, + 33, + 34, + 35, + 36, + 37, + 38, + 39, + 40, + 41, + 42, + 43, + 44, + 45, + 46, + 47, + 48, + 49, + 50, + 51, + 52, + 53, + 54, + 55, + 56, + 57, + 58, + 59, + 60, + 61, + 62, + 63, + 64, + 65, + 66, + 67, + 68, + 69, + 70, + 71, + 72, + 73, + 74, + 75, + 76, + 77, + 78, + 79, + 80, + 81, + 82, + 83, + 84, + 85, + 86, + 87, + 88, + 89, + 90, + 91, + 92, + 93, + 94, + 95, + 96, + 97 + ], + "starting_column": 1, + "ending_column": 2 + } + }, + "signature": "bad4()" + } + } } - } - } - ] - }, - { - "check": "incorrect-equality", - "impact": "Medium", - "confidence": "High", - "description": "TestContractBalance.bad4 (tests/incorrect_equality.sol#52-57) uses a dangerous strict equality:\n\t- balance == 10000000000000000000\n", - "elements": [ - { - "type": "node", - "name": "balance == 10000000000000000000", - "source_mapping": { - "start": 1270, - "length": 80, - "filename_used": "/home/travis/build/crytic/slither/tests/incorrect_equality.sol", - "filename_relative": "tests/incorrect_equality.sol", - "filename_absolute": "/home/travis/build/crytic/slither/tests/incorrect_equality.sol", - "filename_short": "tests/incorrect_equality.sol", - "lines": [ - 54, - 55, - 56 - ], - "starting_column": 9, - "ending_column": 10 }, - "function": { + { "type": "function", "name": "bad4", "source_mapping": { @@ -1245,225 +1406,233 @@ "starting_column": 5, "ending_column": 6 }, - "contract": { - "type": "contract", - "name": "TestContractBalance", - "source_mapping": { - "start": 612, - "length": 1754, - "filename_used": "/home/travis/build/crytic/slither/tests/incorrect_equality.sol", - "filename_relative": "tests/incorrect_equality.sol", - "filename_absolute": "/home/travis/build/crytic/slither/tests/incorrect_equality.sol", - "filename_short": "tests/incorrect_equality.sol", - "lines": [ - 30, - 31, - 32, - 33, - 34, - 35, - 36, - 37, - 38, - 39, - 40, - 41, - 42, - 43, - 44, - 45, - 46, - 47, - 48, - 49, - 50, - 51, - 52, - 53, - 54, - 55, - 56, - 57, - 58, - 59, - 60, - 61, - 62, - 63, - 64, - 65, - 66, - 67, - 68, - 69, - 70, - 71, - 72, - 73, - 74, - 75, - 76, - 77, - 78, - 79, - 80, - 81, - 82, - 83, - 84, - 85, - 86, - 87, - 88, - 89, - 90, - 91, - 92, - 93, - 94, - 95, - 96, - 97 - ], - "starting_column": 1, - "ending_column": 2 - } + "type_specific_fields": { + "parent": { + "type": "contract", + "name": "TestContractBalance", + "source_mapping": { + "start": 612, + "length": 1754, + "filename_used": "/home/travis/build/crytic/slither/tests/incorrect_equality.sol", + "filename_relative": "tests/incorrect_equality.sol", + "filename_absolute": "/home/travis/build/crytic/slither/tests/incorrect_equality.sol", + "filename_short": "tests/incorrect_equality.sol", + "lines": [ + 30, + 31, + 32, + 33, + 34, + 35, + 36, + 37, + 38, + 39, + 40, + 41, + 42, + 43, + 44, + 45, + 46, + 47, + 48, + 49, + 50, + 51, + 52, + 53, + 54, + 55, + 56, + 57, + 58, + 59, + 60, + 61, + 62, + 63, + 64, + 65, + 66, + 67, + 68, + 69, + 70, + 71, + 72, + 73, + 74, + 75, + 76, + 77, + 78, + 79, + 80, + 81, + 82, + 83, + 84, + 85, + 86, + 87, + 88, + 89, + 90, + 91, + 92, + 93, + 94, + 95, + 96, + 97 + ], + "starting_column": 1, + "ending_column": 2 + } + }, + "signature": "bad4()" } } - }, - { - "type": "function", - "name": "bad4", - "source_mapping": { - "start": 1186, - "length": 170, - "filename_used": "/home/travis/build/crytic/slither/tests/incorrect_equality.sol", - "filename_relative": "tests/incorrect_equality.sol", - "filename_absolute": "/home/travis/build/crytic/slither/tests/incorrect_equality.sol", - "filename_short": "tests/incorrect_equality.sol", - "lines": [ - 52, - 53, - 54, - 55, - 56, - 57 - ], - "starting_column": 5, - "ending_column": 6 - }, - "contract": { - "type": "contract", - "name": "TestContractBalance", + ] + }, + { + "check": "incorrect-equality", + "impact": "Medium", + "confidence": "High", + "description": "TestContractBalance.bad5 (tests/incorrect_equality.sol#59-64) uses a dangerous strict equality:\n\t- 10000000000000000000 == balance\n", + "elements": [ + { + "type": "node", + "name": "10000000000000000000 == balance", "source_mapping": { - "start": 612, - "length": 1754, + "start": 1446, + "length": 80, "filename_used": "/home/travis/build/crytic/slither/tests/incorrect_equality.sol", "filename_relative": "tests/incorrect_equality.sol", "filename_absolute": "/home/travis/build/crytic/slither/tests/incorrect_equality.sol", "filename_short": "tests/incorrect_equality.sol", "lines": [ - 30, - 31, - 32, - 33, - 34, - 35, - 36, - 37, - 38, - 39, - 40, - 41, - 42, - 43, - 44, - 45, - 46, - 47, - 48, - 49, - 50, - 51, - 52, - 53, - 54, - 55, - 56, - 57, - 58, - 59, - 60, 61, 62, - 63, - 64, - 65, - 66, - 67, - 68, - 69, - 70, - 71, - 72, - 73, - 74, - 75, - 76, - 77, - 78, - 79, - 80, - 81, - 82, - 83, - 84, - 85, - 86, - 87, - 88, - 89, - 90, - 91, - 92, - 93, - 94, - 95, - 96, - 97 + 63 ], - "starting_column": 1, - "ending_column": 2 + "starting_column": 9, + "ending_column": 10 + }, + "type_specific_fields": { + "parent": { + "type": "function", + "name": "bad5", + "source_mapping": { + "start": 1362, + "length": 170, + "filename_used": "/home/travis/build/crytic/slither/tests/incorrect_equality.sol", + "filename_relative": "tests/incorrect_equality.sol", + "filename_absolute": "/home/travis/build/crytic/slither/tests/incorrect_equality.sol", + "filename_short": "tests/incorrect_equality.sol", + "lines": [ + 59, + 60, + 61, + 62, + 63, + 64 + ], + "starting_column": 5, + "ending_column": 6 + }, + "type_specific_fields": { + "parent": { + "type": "contract", + "name": "TestContractBalance", + "source_mapping": { + "start": 612, + "length": 1754, + "filename_used": "/home/travis/build/crytic/slither/tests/incorrect_equality.sol", + "filename_relative": "tests/incorrect_equality.sol", + "filename_absolute": "/home/travis/build/crytic/slither/tests/incorrect_equality.sol", + "filename_short": "tests/incorrect_equality.sol", + "lines": [ + 30, + 31, + 32, + 33, + 34, + 35, + 36, + 37, + 38, + 39, + 40, + 41, + 42, + 43, + 44, + 45, + 46, + 47, + 48, + 49, + 50, + 51, + 52, + 53, + 54, + 55, + 56, + 57, + 58, + 59, + 60, + 61, + 62, + 63, + 64, + 65, + 66, + 67, + 68, + 69, + 70, + 71, + 72, + 73, + 74, + 75, + 76, + 77, + 78, + 79, + 80, + 81, + 82, + 83, + 84, + 85, + 86, + 87, + 88, + 89, + 90, + 91, + 92, + 93, + 94, + 95, + 96, + 97 + ], + "starting_column": 1, + "ending_column": 2 + } + }, + "signature": "bad5()" + } + } } - } - } - ] - }, - { - "check": "incorrect-equality", - "impact": "Medium", - "confidence": "High", - "description": "TestContractBalance.bad5 (tests/incorrect_equality.sol#59-64) uses a dangerous strict equality:\n\t- 10000000000000000000 == balance\n", - "elements": [ - { - "type": "node", - "name": "10000000000000000000 == balance", - "source_mapping": { - "start": 1446, - "length": 80, - "filename_used": "/home/travis/build/crytic/slither/tests/incorrect_equality.sol", - "filename_relative": "tests/incorrect_equality.sol", - "filename_absolute": "/home/travis/build/crytic/slither/tests/incorrect_equality.sol", - "filename_short": "tests/incorrect_equality.sol", - "lines": [ - 61, - 62, - 63 - ], - "starting_column": 9, - "ending_column": 10 }, - "function": { + { "type": "function", "name": "bad5", "source_mapping": { @@ -1484,225 +1653,233 @@ "starting_column": 5, "ending_column": 6 }, - "contract": { - "type": "contract", - "name": "TestContractBalance", - "source_mapping": { - "start": 612, - "length": 1754, - "filename_used": "/home/travis/build/crytic/slither/tests/incorrect_equality.sol", - "filename_relative": "tests/incorrect_equality.sol", - "filename_absolute": "/home/travis/build/crytic/slither/tests/incorrect_equality.sol", - "filename_short": "tests/incorrect_equality.sol", - "lines": [ - 30, - 31, - 32, - 33, - 34, - 35, - 36, - 37, - 38, - 39, - 40, - 41, - 42, - 43, - 44, - 45, - 46, - 47, - 48, - 49, - 50, - 51, - 52, - 53, - 54, - 55, - 56, - 57, - 58, - 59, - 60, - 61, - 62, - 63, - 64, - 65, - 66, - 67, - 68, - 69, - 70, - 71, - 72, - 73, - 74, - 75, - 76, - 77, - 78, - 79, - 80, - 81, - 82, - 83, - 84, - 85, - 86, - 87, - 88, - 89, - 90, - 91, - 92, - 93, - 94, - 95, - 96, - 97 - ], - "starting_column": 1, - "ending_column": 2 - } + "type_specific_fields": { + "parent": { + "type": "contract", + "name": "TestContractBalance", + "source_mapping": { + "start": 612, + "length": 1754, + "filename_used": "/home/travis/build/crytic/slither/tests/incorrect_equality.sol", + "filename_relative": "tests/incorrect_equality.sol", + "filename_absolute": "/home/travis/build/crytic/slither/tests/incorrect_equality.sol", + "filename_short": "tests/incorrect_equality.sol", + "lines": [ + 30, + 31, + 32, + 33, + 34, + 35, + 36, + 37, + 38, + 39, + 40, + 41, + 42, + 43, + 44, + 45, + 46, + 47, + 48, + 49, + 50, + 51, + 52, + 53, + 54, + 55, + 56, + 57, + 58, + 59, + 60, + 61, + 62, + 63, + 64, + 65, + 66, + 67, + 68, + 69, + 70, + 71, + 72, + 73, + 74, + 75, + 76, + 77, + 78, + 79, + 80, + 81, + 82, + 83, + 84, + 85, + 86, + 87, + 88, + 89, + 90, + 91, + 92, + 93, + 94, + 95, + 96, + 97 + ], + "starting_column": 1, + "ending_column": 2 + } + }, + "signature": "bad5()" } } - }, - { - "type": "function", - "name": "bad5", - "source_mapping": { - "start": 1362, - "length": 170, - "filename_used": "/home/travis/build/crytic/slither/tests/incorrect_equality.sol", - "filename_relative": "tests/incorrect_equality.sol", - "filename_absolute": "/home/travis/build/crytic/slither/tests/incorrect_equality.sol", - "filename_short": "tests/incorrect_equality.sol", - "lines": [ - 59, - 60, - 61, - 62, - 63, - 64 - ], - "starting_column": 5, - "ending_column": 6 - }, - "contract": { - "type": "contract", - "name": "TestContractBalance", + ] + }, + { + "check": "incorrect-equality", + "impact": "Medium", + "confidence": "High", + "description": "TestContractBalance.bad6 (tests/incorrect_equality.sol#66-71) uses a dangerous strict equality:\n\t- balance == 10000000000000000000\n", + "elements": [ + { + "type": "node", + "name": "balance == 10000000000000000000", "source_mapping": { - "start": 612, - "length": 1754, + "start": 1631, + "length": 80, "filename_used": "/home/travis/build/crytic/slither/tests/incorrect_equality.sol", "filename_relative": "tests/incorrect_equality.sol", "filename_absolute": "/home/travis/build/crytic/slither/tests/incorrect_equality.sol", "filename_short": "tests/incorrect_equality.sol", "lines": [ - 30, - 31, - 32, - 33, - 34, - 35, - 36, - 37, - 38, - 39, - 40, - 41, - 42, - 43, - 44, - 45, - 46, - 47, - 48, - 49, - 50, - 51, - 52, - 53, - 54, - 55, - 56, - 57, - 58, - 59, - 60, - 61, - 62, - 63, - 64, - 65, - 66, - 67, 68, 69, - 70, - 71, - 72, - 73, - 74, - 75, - 76, - 77, - 78, - 79, - 80, - 81, - 82, - 83, - 84, - 85, - 86, - 87, - 88, - 89, - 90, - 91, - 92, - 93, - 94, - 95, - 96, - 97 + 70 ], - "starting_column": 1, - "ending_column": 2 + "starting_column": 9, + "ending_column": 10 + }, + "type_specific_fields": { + "parent": { + "type": "function", + "name": "bad6", + "source_mapping": { + "start": 1538, + "length": 179, + "filename_used": "/home/travis/build/crytic/slither/tests/incorrect_equality.sol", + "filename_relative": "tests/incorrect_equality.sol", + "filename_absolute": "/home/travis/build/crytic/slither/tests/incorrect_equality.sol", + "filename_short": "tests/incorrect_equality.sol", + "lines": [ + 66, + 67, + 68, + 69, + 70, + 71 + ], + "starting_column": 5, + "ending_column": 6 + }, + "type_specific_fields": { + "parent": { + "type": "contract", + "name": "TestContractBalance", + "source_mapping": { + "start": 612, + "length": 1754, + "filename_used": "/home/travis/build/crytic/slither/tests/incorrect_equality.sol", + "filename_relative": "tests/incorrect_equality.sol", + "filename_absolute": "/home/travis/build/crytic/slither/tests/incorrect_equality.sol", + "filename_short": "tests/incorrect_equality.sol", + "lines": [ + 30, + 31, + 32, + 33, + 34, + 35, + 36, + 37, + 38, + 39, + 40, + 41, + 42, + 43, + 44, + 45, + 46, + 47, + 48, + 49, + 50, + 51, + 52, + 53, + 54, + 55, + 56, + 57, + 58, + 59, + 60, + 61, + 62, + 63, + 64, + 65, + 66, + 67, + 68, + 69, + 70, + 71, + 72, + 73, + 74, + 75, + 76, + 77, + 78, + 79, + 80, + 81, + 82, + 83, + 84, + 85, + 86, + 87, + 88, + 89, + 90, + 91, + 92, + 93, + 94, + 95, + 96, + 97 + ], + "starting_column": 1, + "ending_column": 2 + } + }, + "signature": "bad6()" + } + } } - } - } - ] - }, - { - "check": "incorrect-equality", - "impact": "Medium", - "confidence": "High", - "description": "TestContractBalance.bad6 (tests/incorrect_equality.sol#66-71) uses a dangerous strict equality:\n\t- balance == 10000000000000000000\n", - "elements": [ - { - "type": "node", - "name": "balance == 10000000000000000000", - "source_mapping": { - "start": 1631, - "length": 80, - "filename_used": "/home/travis/build/crytic/slither/tests/incorrect_equality.sol", - "filename_relative": "tests/incorrect_equality.sol", - "filename_absolute": "/home/travis/build/crytic/slither/tests/incorrect_equality.sol", - "filename_short": "tests/incorrect_equality.sol", - "lines": [ - 68, - 69, - 70 - ], - "starting_column": 9, - "ending_column": 10 }, - "function": { + { "type": "function", "name": "bad6", "source_mapping": { @@ -1723,223 +1900,197 @@ "starting_column": 5, "ending_column": 6 }, - "contract": { - "type": "contract", - "name": "TestContractBalance", - "source_mapping": { - "start": 612, - "length": 1754, - "filename_used": "/home/travis/build/crytic/slither/tests/incorrect_equality.sol", - "filename_relative": "tests/incorrect_equality.sol", - "filename_absolute": "/home/travis/build/crytic/slither/tests/incorrect_equality.sol", - "filename_short": "tests/incorrect_equality.sol", - "lines": [ - 30, - 31, - 32, - 33, - 34, - 35, - 36, - 37, - 38, - 39, - 40, - 41, - 42, - 43, - 44, - 45, - 46, - 47, - 48, - 49, - 50, - 51, - 52, - 53, - 54, - 55, - 56, - 57, - 58, - 59, - 60, - 61, - 62, - 63, - 64, - 65, - 66, - 67, - 68, - 69, - 70, - 71, - 72, - 73, - 74, - 75, - 76, - 77, - 78, - 79, - 80, - 81, - 82, - 83, - 84, - 85, - 86, - 87, - 88, - 89, - 90, - 91, - 92, - 93, - 94, - 95, - 96, - 97 - ], - "starting_column": 1, - "ending_column": 2 - } + "type_specific_fields": { + "parent": { + "type": "contract", + "name": "TestContractBalance", + "source_mapping": { + "start": 612, + "length": 1754, + "filename_used": "/home/travis/build/crytic/slither/tests/incorrect_equality.sol", + "filename_relative": "tests/incorrect_equality.sol", + "filename_absolute": "/home/travis/build/crytic/slither/tests/incorrect_equality.sol", + "filename_short": "tests/incorrect_equality.sol", + "lines": [ + 30, + 31, + 32, + 33, + 34, + 35, + 36, + 37, + 38, + 39, + 40, + 41, + 42, + 43, + 44, + 45, + 46, + 47, + 48, + 49, + 50, + 51, + 52, + 53, + 54, + 55, + 56, + 57, + 58, + 59, + 60, + 61, + 62, + 63, + 64, + 65, + 66, + 67, + 68, + 69, + 70, + 71, + 72, + 73, + 74, + 75, + 76, + 77, + 78, + 79, + 80, + 81, + 82, + 83, + 84, + 85, + 86, + 87, + 88, + 89, + 90, + 91, + 92, + 93, + 94, + 95, + 96, + 97 + ], + "starting_column": 1, + "ending_column": 2 + } + }, + "signature": "bad6()" } } - }, - { - "type": "function", - "name": "bad6", - "source_mapping": { - "start": 1538, - "length": 179, - "filename_used": "/home/travis/build/crytic/slither/tests/incorrect_equality.sol", - "filename_relative": "tests/incorrect_equality.sol", - "filename_absolute": "/home/travis/build/crytic/slither/tests/incorrect_equality.sol", - "filename_short": "tests/incorrect_equality.sol", - "lines": [ - 66, - 67, - 68, - 69, - 70, - 71 - ], - "starting_column": 5, - "ending_column": 6 - }, - "contract": { - "type": "contract", - "name": "TestContractBalance", + ] + }, + { + "check": "incorrect-equality", + "impact": "Medium", + "confidence": "High", + "description": "TestSolidityKeyword.bad0 (tests/incorrect_equality.sol#123-125) uses a dangerous strict equality:\n\t- require(bool)(now == 0)\n", + "elements": [ + { + "type": "node", + "name": "require(bool)(now == 0)", "source_mapping": { - "start": 612, - "length": 1754, + "start": 2969, + "length": 18, "filename_used": "/home/travis/build/crytic/slither/tests/incorrect_equality.sol", "filename_relative": "tests/incorrect_equality.sol", "filename_absolute": "/home/travis/build/crytic/slither/tests/incorrect_equality.sol", "filename_short": "tests/incorrect_equality.sol", "lines": [ - 30, - 31, - 32, - 33, - 34, - 35, - 36, - 37, - 38, - 39, - 40, - 41, - 42, - 43, - 44, - 45, - 46, - 47, - 48, - 49, - 50, - 51, - 52, - 53, - 54, - 55, - 56, - 57, - 58, - 59, - 60, - 61, - 62, - 63, - 64, - 65, - 66, - 67, - 68, - 69, - 70, - 71, - 72, - 73, - 74, - 75, - 76, - 77, - 78, - 79, - 80, - 81, - 82, - 83, - 84, - 85, - 86, - 87, - 88, - 89, - 90, - 91, - 92, - 93, - 94, - 95, - 96, - 97 + 124 ], - "starting_column": 1, - "ending_column": 2 + "starting_column": 9, + "ending_column": 27 + }, + "type_specific_fields": { + "parent": { + "type": "function", + "name": "bad0", + "source_mapping": { + "start": 2935, + "length": 59, + "filename_used": "/home/travis/build/crytic/slither/tests/incorrect_equality.sol", + "filename_relative": "tests/incorrect_equality.sol", + "filename_absolute": "/home/travis/build/crytic/slither/tests/incorrect_equality.sol", + "filename_short": "tests/incorrect_equality.sol", + "lines": [ + 123, + 124, + 125 + ], + "starting_column": 5, + "ending_column": 6 + }, + "type_specific_fields": { + "parent": { + "type": "contract", + "name": "TestSolidityKeyword", + "source_mapping": { + "start": 2368, + "length": 774, + "filename_used": "/home/travis/build/crytic/slither/tests/incorrect_equality.sol", + "filename_relative": "tests/incorrect_equality.sol", + "filename_absolute": "/home/travis/build/crytic/slither/tests/incorrect_equality.sol", + "filename_short": "tests/incorrect_equality.sol", + "lines": [ + 99, + 100, + 101, + 102, + 103, + 104, + 105, + 106, + 107, + 108, + 109, + 110, + 111, + 112, + 113, + 114, + 115, + 116, + 117, + 118, + 119, + 120, + 121, + 122, + 123, + 124, + 125, + 126, + 127, + 128, + 129, + 130, + 131, + 132, + 133, + 134, + 135 + ], + "starting_column": 1, + "ending_column": 2 + } + }, + "signature": "bad0()" + } + } } - } - } - ] - }, - { - "check": "incorrect-equality", - "impact": "Medium", - "confidence": "High", - "description": "TestSolidityKeyword.bad0 (tests/incorrect_equality.sol#123-125) uses a dangerous strict equality:\n\t- require(bool)(now == 0)\n", - "elements": [ - { - "type": "node", - "name": "require(bool)(now == 0)", - "source_mapping": { - "start": 2969, - "length": 18, - "filename_used": "/home/travis/build/crytic/slither/tests/incorrect_equality.sol", - "filename_relative": "tests/incorrect_equality.sol", - "filename_absolute": "/home/travis/build/crytic/slither/tests/incorrect_equality.sol", - "filename_short": "tests/incorrect_equality.sol", - "lines": [ - 124 - ], - "starting_column": 9, - "ending_column": 27 }, - "function": { + { "type": "function", "name": "bad0", "source_mapping": { @@ -1957,158 +2108,166 @@ "starting_column": 5, "ending_column": 6 }, - "contract": { - "type": "contract", - "name": "TestSolidityKeyword", - "source_mapping": { - "start": 2368, - "length": 774, - "filename_used": "/home/travis/build/crytic/slither/tests/incorrect_equality.sol", - "filename_relative": "tests/incorrect_equality.sol", - "filename_absolute": "/home/travis/build/crytic/slither/tests/incorrect_equality.sol", - "filename_short": "tests/incorrect_equality.sol", - "lines": [ - 99, - 100, - 101, - 102, - 103, - 104, - 105, - 106, - 107, - 108, - 109, - 110, - 111, - 112, - 113, - 114, - 115, - 116, - 117, - 118, - 119, - 120, - 121, - 122, - 123, - 124, - 125, - 126, - 127, - 128, - 129, - 130, - 131, - 132, - 133, - 134, - 135 - ], - "starting_column": 1, - "ending_column": 2 - } + "type_specific_fields": { + "parent": { + "type": "contract", + "name": "TestSolidityKeyword", + "source_mapping": { + "start": 2368, + "length": 774, + "filename_used": "/home/travis/build/crytic/slither/tests/incorrect_equality.sol", + "filename_relative": "tests/incorrect_equality.sol", + "filename_absolute": "/home/travis/build/crytic/slither/tests/incorrect_equality.sol", + "filename_short": "tests/incorrect_equality.sol", + "lines": [ + 99, + 100, + 101, + 102, + 103, + 104, + 105, + 106, + 107, + 108, + 109, + 110, + 111, + 112, + 113, + 114, + 115, + 116, + 117, + 118, + 119, + 120, + 121, + 122, + 123, + 124, + 125, + 126, + 127, + 128, + 129, + 130, + 131, + 132, + 133, + 134, + 135 + ], + "starting_column": 1, + "ending_column": 2 + } + }, + "signature": "bad0()" } } - }, - { - "type": "function", - "name": "bad0", - "source_mapping": { - "start": 2935, - "length": 59, - "filename_used": "/home/travis/build/crytic/slither/tests/incorrect_equality.sol", - "filename_relative": "tests/incorrect_equality.sol", - "filename_absolute": "/home/travis/build/crytic/slither/tests/incorrect_equality.sol", - "filename_short": "tests/incorrect_equality.sol", - "lines": [ - 123, - 124, - 125 - ], - "starting_column": 5, - "ending_column": 6 - }, - "contract": { - "type": "contract", - "name": "TestSolidityKeyword", + ] + }, + { + "check": "incorrect-equality", + "impact": "Medium", + "confidence": "High", + "description": "TestSolidityKeyword.bad1 (tests/incorrect_equality.sol#127-129) uses a dangerous strict equality:\n\t- require(bool)(block.number == 0)\n", + "elements": [ + { + "type": "node", + "name": "require(bool)(block.number == 0)", "source_mapping": { - "start": 2368, - "length": 774, + "start": 3034, + "length": 25, "filename_used": "/home/travis/build/crytic/slither/tests/incorrect_equality.sol", "filename_relative": "tests/incorrect_equality.sol", "filename_absolute": "/home/travis/build/crytic/slither/tests/incorrect_equality.sol", "filename_short": "tests/incorrect_equality.sol", "lines": [ - 99, - 100, - 101, - 102, - 103, - 104, - 105, - 106, - 107, - 108, - 109, - 110, - 111, - 112, - 113, - 114, - 115, - 116, - 117, - 118, - 119, - 120, - 121, - 122, - 123, - 124, - 125, - 126, - 127, - 128, - 129, - 130, - 131, - 132, - 133, - 134, - 135 + 128 ], - "starting_column": 1, - "ending_column": 2 + "starting_column": 9, + "ending_column": 34 + }, + "type_specific_fields": { + "parent": { + "type": "function", + "name": "bad1", + "source_mapping": { + "start": 3000, + "length": 66, + "filename_used": "/home/travis/build/crytic/slither/tests/incorrect_equality.sol", + "filename_relative": "tests/incorrect_equality.sol", + "filename_absolute": "/home/travis/build/crytic/slither/tests/incorrect_equality.sol", + "filename_short": "tests/incorrect_equality.sol", + "lines": [ + 127, + 128, + 129 + ], + "starting_column": 5, + "ending_column": 6 + }, + "type_specific_fields": { + "parent": { + "type": "contract", + "name": "TestSolidityKeyword", + "source_mapping": { + "start": 2368, + "length": 774, + "filename_used": "/home/travis/build/crytic/slither/tests/incorrect_equality.sol", + "filename_relative": "tests/incorrect_equality.sol", + "filename_absolute": "/home/travis/build/crytic/slither/tests/incorrect_equality.sol", + "filename_short": "tests/incorrect_equality.sol", + "lines": [ + 99, + 100, + 101, + 102, + 103, + 104, + 105, + 106, + 107, + 108, + 109, + 110, + 111, + 112, + 113, + 114, + 115, + 116, + 117, + 118, + 119, + 120, + 121, + 122, + 123, + 124, + 125, + 126, + 127, + 128, + 129, + 130, + 131, + 132, + 133, + 134, + 135 + ], + "starting_column": 1, + "ending_column": 2 + } + }, + "signature": "bad1()" + } + } } - } - } - ] - }, - { - "check": "incorrect-equality", - "impact": "Medium", - "confidence": "High", - "description": "TestSolidityKeyword.bad1 (tests/incorrect_equality.sol#127-129) uses a dangerous strict equality:\n\t- require(bool)(block.number == 0)\n", - "elements": [ - { - "type": "node", - "name": "require(bool)(block.number == 0)", - "source_mapping": { - "start": 3034, - "length": 25, - "filename_used": "/home/travis/build/crytic/slither/tests/incorrect_equality.sol", - "filename_relative": "tests/incorrect_equality.sol", - "filename_absolute": "/home/travis/build/crytic/slither/tests/incorrect_equality.sol", - "filename_short": "tests/incorrect_equality.sol", - "lines": [ - 128 - ], - "starting_column": 9, - "ending_column": 34 }, - "function": { + { "type": "function", "name": "bad1", "source_mapping": { @@ -2126,158 +2285,166 @@ "starting_column": 5, "ending_column": 6 }, - "contract": { - "type": "contract", - "name": "TestSolidityKeyword", - "source_mapping": { - "start": 2368, - "length": 774, - "filename_used": "/home/travis/build/crytic/slither/tests/incorrect_equality.sol", - "filename_relative": "tests/incorrect_equality.sol", - "filename_absolute": "/home/travis/build/crytic/slither/tests/incorrect_equality.sol", - "filename_short": "tests/incorrect_equality.sol", - "lines": [ - 99, - 100, - 101, - 102, - 103, - 104, - 105, - 106, - 107, - 108, - 109, - 110, - 111, - 112, - 113, - 114, - 115, - 116, - 117, - 118, - 119, - 120, - 121, - 122, - 123, - 124, - 125, - 126, - 127, - 128, - 129, - 130, - 131, - 132, - 133, - 134, - 135 - ], - "starting_column": 1, - "ending_column": 2 - } + "type_specific_fields": { + "parent": { + "type": "contract", + "name": "TestSolidityKeyword", + "source_mapping": { + "start": 2368, + "length": 774, + "filename_used": "/home/travis/build/crytic/slither/tests/incorrect_equality.sol", + "filename_relative": "tests/incorrect_equality.sol", + "filename_absolute": "/home/travis/build/crytic/slither/tests/incorrect_equality.sol", + "filename_short": "tests/incorrect_equality.sol", + "lines": [ + 99, + 100, + 101, + 102, + 103, + 104, + 105, + 106, + 107, + 108, + 109, + 110, + 111, + 112, + 113, + 114, + 115, + 116, + 117, + 118, + 119, + 120, + 121, + 122, + 123, + 124, + 125, + 126, + 127, + 128, + 129, + 130, + 131, + 132, + 133, + 134, + 135 + ], + "starting_column": 1, + "ending_column": 2 + } + }, + "signature": "bad1()" } } - }, - { - "type": "function", - "name": "bad1", - "source_mapping": { - "start": 3000, - "length": 66, - "filename_used": "/home/travis/build/crytic/slither/tests/incorrect_equality.sol", - "filename_relative": "tests/incorrect_equality.sol", - "filename_absolute": "/home/travis/build/crytic/slither/tests/incorrect_equality.sol", - "filename_short": "tests/incorrect_equality.sol", - "lines": [ - 127, - 128, - 129 - ], - "starting_column": 5, - "ending_column": 6 - }, - "contract": { - "type": "contract", - "name": "TestSolidityKeyword", + ] + }, + { + "check": "incorrect-equality", + "impact": "Medium", + "confidence": "High", + "description": "TestSolidityKeyword.bad2 (tests/incorrect_equality.sol#131-133) uses a dangerous strict equality:\n\t- require(bool)(block.number == 0)\n", + "elements": [ + { + "type": "node", + "name": "require(bool)(block.number == 0)", "source_mapping": { - "start": 2368, - "length": 774, + "start": 3106, + "length": 26, "filename_used": "/home/travis/build/crytic/slither/tests/incorrect_equality.sol", "filename_relative": "tests/incorrect_equality.sol", "filename_absolute": "/home/travis/build/crytic/slither/tests/incorrect_equality.sol", "filename_short": "tests/incorrect_equality.sol", "lines": [ - 99, - 100, - 101, - 102, - 103, - 104, - 105, - 106, - 107, - 108, - 109, - 110, - 111, - 112, - 113, - 114, - 115, - 116, - 117, - 118, - 119, - 120, - 121, - 122, - 123, - 124, - 125, - 126, - 127, - 128, - 129, - 130, - 131, - 132, - 133, - 134, - 135 + 132 ], - "starting_column": 1, - "ending_column": 2 + "starting_column": 9, + "ending_column": 35 + }, + "type_specific_fields": { + "parent": { + "type": "function", + "name": "bad2", + "source_mapping": { + "start": 3072, + "length": 67, + "filename_used": "/home/travis/build/crytic/slither/tests/incorrect_equality.sol", + "filename_relative": "tests/incorrect_equality.sol", + "filename_absolute": "/home/travis/build/crytic/slither/tests/incorrect_equality.sol", + "filename_short": "tests/incorrect_equality.sol", + "lines": [ + 131, + 132, + 133 + ], + "starting_column": 5, + "ending_column": 6 + }, + "type_specific_fields": { + "parent": { + "type": "contract", + "name": "TestSolidityKeyword", + "source_mapping": { + "start": 2368, + "length": 774, + "filename_used": "/home/travis/build/crytic/slither/tests/incorrect_equality.sol", + "filename_relative": "tests/incorrect_equality.sol", + "filename_absolute": "/home/travis/build/crytic/slither/tests/incorrect_equality.sol", + "filename_short": "tests/incorrect_equality.sol", + "lines": [ + 99, + 100, + 101, + 102, + 103, + 104, + 105, + 106, + 107, + 108, + 109, + 110, + 111, + 112, + 113, + 114, + 115, + 116, + 117, + 118, + 119, + 120, + 121, + 122, + 123, + 124, + 125, + 126, + 127, + 128, + 129, + 130, + 131, + 132, + 133, + 134, + 135 + ], + "starting_column": 1, + "ending_column": 2 + } + }, + "signature": "bad2()" + } + } } - } - } - ] - }, - { - "check": "incorrect-equality", - "impact": "Medium", - "confidence": "High", - "description": "TestSolidityKeyword.bad2 (tests/incorrect_equality.sol#131-133) uses a dangerous strict equality:\n\t- require(bool)(block.number == 0)\n", - "elements": [ - { - "type": "node", - "name": "require(bool)(block.number == 0)", - "source_mapping": { - "start": 3106, - "length": 26, - "filename_used": "/home/travis/build/crytic/slither/tests/incorrect_equality.sol", - "filename_relative": "tests/incorrect_equality.sol", - "filename_absolute": "/home/travis/build/crytic/slither/tests/incorrect_equality.sol", - "filename_short": "tests/incorrect_equality.sol", - "lines": [ - 132 - ], - "starting_column": 9, - "ending_column": 35 }, - "function": { + { "type": "function", "name": "bad2", "source_mapping": { @@ -2295,134 +2462,65 @@ "starting_column": 5, "ending_column": 6 }, - "contract": { - "type": "contract", - "name": "TestSolidityKeyword", - "source_mapping": { - "start": 2368, - "length": 774, - "filename_used": "/home/travis/build/crytic/slither/tests/incorrect_equality.sol", - "filename_relative": "tests/incorrect_equality.sol", - "filename_absolute": "/home/travis/build/crytic/slither/tests/incorrect_equality.sol", - "filename_short": "tests/incorrect_equality.sol", - "lines": [ - 99, - 100, - 101, - 102, - 103, - 104, - 105, - 106, - 107, - 108, - 109, - 110, - 111, - 112, - 113, - 114, - 115, - 116, - 117, - 118, - 119, - 120, - 121, - 122, - 123, - 124, - 125, - 126, - 127, - 128, - 129, - 130, - 131, - 132, - 133, - 134, - 135 - ], - "starting_column": 1, - "ending_column": 2 - } - } - } - }, - { - "type": "function", - "name": "bad2", - "source_mapping": { - "start": 3072, - "length": 67, - "filename_used": "/home/travis/build/crytic/slither/tests/incorrect_equality.sol", - "filename_relative": "tests/incorrect_equality.sol", - "filename_absolute": "/home/travis/build/crytic/slither/tests/incorrect_equality.sol", - "filename_short": "tests/incorrect_equality.sol", - "lines": [ - 131, - 132, - 133 - ], - "starting_column": 5, - "ending_column": 6 - }, - "contract": { - "type": "contract", - "name": "TestSolidityKeyword", - "source_mapping": { - "start": 2368, - "length": 774, - "filename_used": "/home/travis/build/crytic/slither/tests/incorrect_equality.sol", - "filename_relative": "tests/incorrect_equality.sol", - "filename_absolute": "/home/travis/build/crytic/slither/tests/incorrect_equality.sol", - "filename_short": "tests/incorrect_equality.sol", - "lines": [ - 99, - 100, - 101, - 102, - 103, - 104, - 105, - 106, - 107, - 108, - 109, - 110, - 111, - 112, - 113, - 114, - 115, - 116, - 117, - 118, - 119, - 120, - 121, - 122, - 123, - 124, - 125, - 126, - 127, - 128, - 129, - 130, - 131, - 132, - 133, - 134, - 135 - ], - "starting_column": 1, - "ending_column": 2 + "type_specific_fields": { + "parent": { + "type": "contract", + "name": "TestSolidityKeyword", + "source_mapping": { + "start": 2368, + "length": 774, + "filename_used": "/home/travis/build/crytic/slither/tests/incorrect_equality.sol", + "filename_relative": "tests/incorrect_equality.sol", + "filename_absolute": "/home/travis/build/crytic/slither/tests/incorrect_equality.sol", + "filename_short": "tests/incorrect_equality.sol", + "lines": [ + 99, + 100, + 101, + 102, + 103, + 104, + 105, + 106, + 107, + 108, + 109, + 110, + 111, + 112, + 113, + 114, + 115, + 116, + 117, + 118, + 119, + 120, + 121, + 122, + 123, + 124, + 125, + 126, + 127, + 128, + 129, + 130, + 131, + 132, + 133, + 134, + 135 + ], + "starting_column": 1, + "ending_column": 2 + } + }, + "signature": "bad2()" } } - } - ] - } - ] + ] + } + ] + } } \ No newline at end of file diff --git a/tests/expected_json/incorrect_erc20_interface.erc20-interface.json b/tests/expected_json/incorrect_erc20_interface.erc20-interface.json index 7edefc0bb..34f7ff786 100644 --- a/tests/expected_json/incorrect_erc20_interface.erc20-interface.json +++ b/tests/expected_json/incorrect_erc20_interface.erc20-interface.json @@ -1,300 +1,320 @@ { "success": true, "error": null, - "results": [ - { - "check": "erc20-interface", - "impact": "Medium", - "confidence": "High", - "description": "Token (tests/incorrect_erc20_interface.sol#3-10) has incorrect ERC20 function interface: transfer (tests/incorrect_erc20_interface.sol#4)\n", - "elements": [ - { - "type": "function", - "name": "transfer", - "source_mapping": { - "start": 46, - "length": 51, - "filename_used": "/home/travis/build/crytic/slither/tests/incorrect_erc20_interface.sol", - "filename_relative": "tests/incorrect_erc20_interface.sol", - "filename_absolute": "/home/travis/build/crytic/slither/tests/incorrect_erc20_interface.sol", - "filename_short": "tests/incorrect_erc20_interface.sol", - "lines": [ - 4 - ], - "starting_column": 5, - "ending_column": 56 - }, - "contract": { - "type": "contract", - "name": "Token", + "results": { + "detectors": [ + { + "check": "erc20-interface", + "impact": "Medium", + "confidence": "High", + "description": "Token (tests/incorrect_erc20_interface.sol#3-10) has incorrect ERC20 function interface: transfer (tests/incorrect_erc20_interface.sol#4)\n", + "elements": [ + { + "type": "function", + "name": "transfer", "source_mapping": { - "start": 26, - "length": 355, + "start": 46, + "length": 51, "filename_used": "/home/travis/build/crytic/slither/tests/incorrect_erc20_interface.sol", "filename_relative": "tests/incorrect_erc20_interface.sol", "filename_absolute": "/home/travis/build/crytic/slither/tests/incorrect_erc20_interface.sol", "filename_short": "tests/incorrect_erc20_interface.sol", "lines": [ - 3, - 4, - 5, - 6, - 7, - 8, - 9, - 10 + 4 ], - "starting_column": 1, - "ending_column": 2 + "starting_column": 5, + "ending_column": 56 + }, + "type_specific_fields": { + "parent": { + "type": "contract", + "name": "Token", + "source_mapping": { + "start": 26, + "length": 355, + "filename_used": "/home/travis/build/crytic/slither/tests/incorrect_erc20_interface.sol", + "filename_relative": "tests/incorrect_erc20_interface.sol", + "filename_absolute": "/home/travis/build/crytic/slither/tests/incorrect_erc20_interface.sol", + "filename_short": "tests/incorrect_erc20_interface.sol", + "lines": [ + 3, + 4, + 5, + 6, + 7, + 8, + 9, + 10 + ], + "starting_column": 1, + "ending_column": 2 + } + }, + "signature": "transfer(address,uint256)" } } - } - ] - }, - { - "check": "erc20-interface", - "impact": "Medium", - "confidence": "High", - "description": "Token (tests/incorrect_erc20_interface.sol#3-10) has incorrect ERC20 function interface: approve (tests/incorrect_erc20_interface.sol#5)\n", - "elements": [ - { - "type": "function", - "name": "approve", - "source_mapping": { - "start": 102, - "length": 55, - "filename_used": "/home/travis/build/crytic/slither/tests/incorrect_erc20_interface.sol", - "filename_relative": "tests/incorrect_erc20_interface.sol", - "filename_absolute": "/home/travis/build/crytic/slither/tests/incorrect_erc20_interface.sol", - "filename_short": "tests/incorrect_erc20_interface.sol", - "lines": [ - 5 - ], - "starting_column": 5, - "ending_column": 60 - }, - "contract": { - "type": "contract", - "name": "Token", + ] + }, + { + "check": "erc20-interface", + "impact": "Medium", + "confidence": "High", + "description": "Token (tests/incorrect_erc20_interface.sol#3-10) has incorrect ERC20 function interface: approve (tests/incorrect_erc20_interface.sol#5)\n", + "elements": [ + { + "type": "function", + "name": "approve", "source_mapping": { - "start": 26, - "length": 355, + "start": 102, + "length": 55, "filename_used": "/home/travis/build/crytic/slither/tests/incorrect_erc20_interface.sol", "filename_relative": "tests/incorrect_erc20_interface.sol", "filename_absolute": "/home/travis/build/crytic/slither/tests/incorrect_erc20_interface.sol", "filename_short": "tests/incorrect_erc20_interface.sol", "lines": [ - 3, - 4, - 5, - 6, - 7, - 8, - 9, - 10 + 5 ], - "starting_column": 1, - "ending_column": 2 + "starting_column": 5, + "ending_column": 60 + }, + "type_specific_fields": { + "parent": { + "type": "contract", + "name": "Token", + "source_mapping": { + "start": 26, + "length": 355, + "filename_used": "/home/travis/build/crytic/slither/tests/incorrect_erc20_interface.sol", + "filename_relative": "tests/incorrect_erc20_interface.sol", + "filename_absolute": "/home/travis/build/crytic/slither/tests/incorrect_erc20_interface.sol", + "filename_short": "tests/incorrect_erc20_interface.sol", + "lines": [ + 3, + 4, + 5, + 6, + 7, + 8, + 9, + 10 + ], + "starting_column": 1, + "ending_column": 2 + } + }, + "signature": "approve(address,uint256)" } } - } - ] - }, - { - "check": "erc20-interface", - "impact": "Medium", - "confidence": "High", - "description": "Token (tests/incorrect_erc20_interface.sol#3-10) has incorrect ERC20 function interface: transferFrom (tests/incorrect_erc20_interface.sol#6)\n", - "elements": [ - { - "type": "function", - "name": "transferFrom", - "source_mapping": { - "start": 162, - "length": 69, - "filename_used": "/home/travis/build/crytic/slither/tests/incorrect_erc20_interface.sol", - "filename_relative": "tests/incorrect_erc20_interface.sol", - "filename_absolute": "/home/travis/build/crytic/slither/tests/incorrect_erc20_interface.sol", - "filename_short": "tests/incorrect_erc20_interface.sol", - "lines": [ - 6 - ], - "starting_column": 5, - "ending_column": 74 - }, - "contract": { - "type": "contract", - "name": "Token", + ] + }, + { + "check": "erc20-interface", + "impact": "Medium", + "confidence": "High", + "description": "Token (tests/incorrect_erc20_interface.sol#3-10) has incorrect ERC20 function interface: transferFrom (tests/incorrect_erc20_interface.sol#6)\n", + "elements": [ + { + "type": "function", + "name": "transferFrom", "source_mapping": { - "start": 26, - "length": 355, + "start": 162, + "length": 69, "filename_used": "/home/travis/build/crytic/slither/tests/incorrect_erc20_interface.sol", "filename_relative": "tests/incorrect_erc20_interface.sol", "filename_absolute": "/home/travis/build/crytic/slither/tests/incorrect_erc20_interface.sol", "filename_short": "tests/incorrect_erc20_interface.sol", "lines": [ - 3, - 4, - 5, - 6, - 7, - 8, - 9, - 10 + 6 ], - "starting_column": 1, - "ending_column": 2 + "starting_column": 5, + "ending_column": 74 + }, + "type_specific_fields": { + "parent": { + "type": "contract", + "name": "Token", + "source_mapping": { + "start": 26, + "length": 355, + "filename_used": "/home/travis/build/crytic/slither/tests/incorrect_erc20_interface.sol", + "filename_relative": "tests/incorrect_erc20_interface.sol", + "filename_absolute": "/home/travis/build/crytic/slither/tests/incorrect_erc20_interface.sol", + "filename_short": "tests/incorrect_erc20_interface.sol", + "lines": [ + 3, + 4, + 5, + 6, + 7, + 8, + 9, + 10 + ], + "starting_column": 1, + "ending_column": 2 + } + }, + "signature": "transferFrom(address,address,uint256)" } } - } - ] - }, - { - "check": "erc20-interface", - "impact": "Medium", - "confidence": "High", - "description": "Token (tests/incorrect_erc20_interface.sol#3-10) has incorrect ERC20 function interface: totalSupply (tests/incorrect_erc20_interface.sol#7)\n", - "elements": [ - { - "type": "function", - "name": "totalSupply", - "source_mapping": { - "start": 236, - "length": 32, - "filename_used": "/home/travis/build/crytic/slither/tests/incorrect_erc20_interface.sol", - "filename_relative": "tests/incorrect_erc20_interface.sol", - "filename_absolute": "/home/travis/build/crytic/slither/tests/incorrect_erc20_interface.sol", - "filename_short": "tests/incorrect_erc20_interface.sol", - "lines": [ - 7 - ], - "starting_column": 5, - "ending_column": 37 - }, - "contract": { - "type": "contract", - "name": "Token", + ] + }, + { + "check": "erc20-interface", + "impact": "Medium", + "confidence": "High", + "description": "Token (tests/incorrect_erc20_interface.sol#3-10) has incorrect ERC20 function interface: totalSupply (tests/incorrect_erc20_interface.sol#7)\n", + "elements": [ + { + "type": "function", + "name": "totalSupply", "source_mapping": { - "start": 26, - "length": 355, + "start": 236, + "length": 32, "filename_used": "/home/travis/build/crytic/slither/tests/incorrect_erc20_interface.sol", "filename_relative": "tests/incorrect_erc20_interface.sol", "filename_absolute": "/home/travis/build/crytic/slither/tests/incorrect_erc20_interface.sol", "filename_short": "tests/incorrect_erc20_interface.sol", "lines": [ - 3, - 4, - 5, - 6, - 7, - 8, - 9, - 10 + 7 ], - "starting_column": 1, - "ending_column": 2 + "starting_column": 5, + "ending_column": 37 + }, + "type_specific_fields": { + "parent": { + "type": "contract", + "name": "Token", + "source_mapping": { + "start": 26, + "length": 355, + "filename_used": "/home/travis/build/crytic/slither/tests/incorrect_erc20_interface.sol", + "filename_relative": "tests/incorrect_erc20_interface.sol", + "filename_absolute": "/home/travis/build/crytic/slither/tests/incorrect_erc20_interface.sol", + "filename_short": "tests/incorrect_erc20_interface.sol", + "lines": [ + 3, + 4, + 5, + 6, + 7, + 8, + 9, + 10 + ], + "starting_column": 1, + "ending_column": 2 + } + }, + "signature": "totalSupply()" } } - } - ] - }, - { - "check": "erc20-interface", - "impact": "Medium", - "confidence": "High", - "description": "Token (tests/incorrect_erc20_interface.sol#3-10) has incorrect ERC20 function interface: balanceOf (tests/incorrect_erc20_interface.sol#8)\n", - "elements": [ - { - "type": "function", - "name": "balanceOf", - "source_mapping": { - "start": 273, - "length": 41, - "filename_used": "/home/travis/build/crytic/slither/tests/incorrect_erc20_interface.sol", - "filename_relative": "tests/incorrect_erc20_interface.sol", - "filename_absolute": "/home/travis/build/crytic/slither/tests/incorrect_erc20_interface.sol", - "filename_short": "tests/incorrect_erc20_interface.sol", - "lines": [ - 8 - ], - "starting_column": 5, - "ending_column": 46 - }, - "contract": { - "type": "contract", - "name": "Token", + ] + }, + { + "check": "erc20-interface", + "impact": "Medium", + "confidence": "High", + "description": "Token (tests/incorrect_erc20_interface.sol#3-10) has incorrect ERC20 function interface: balanceOf (tests/incorrect_erc20_interface.sol#8)\n", + "elements": [ + { + "type": "function", + "name": "balanceOf", "source_mapping": { - "start": 26, - "length": 355, + "start": 273, + "length": 41, "filename_used": "/home/travis/build/crytic/slither/tests/incorrect_erc20_interface.sol", "filename_relative": "tests/incorrect_erc20_interface.sol", "filename_absolute": "/home/travis/build/crytic/slither/tests/incorrect_erc20_interface.sol", "filename_short": "tests/incorrect_erc20_interface.sol", "lines": [ - 3, - 4, - 5, - 6, - 7, - 8, - 9, - 10 + 8 ], - "starting_column": 1, - "ending_column": 2 + "starting_column": 5, + "ending_column": 46 + }, + "type_specific_fields": { + "parent": { + "type": "contract", + "name": "Token", + "source_mapping": { + "start": 26, + "length": 355, + "filename_used": "/home/travis/build/crytic/slither/tests/incorrect_erc20_interface.sol", + "filename_relative": "tests/incorrect_erc20_interface.sol", + "filename_absolute": "/home/travis/build/crytic/slither/tests/incorrect_erc20_interface.sol", + "filename_short": "tests/incorrect_erc20_interface.sol", + "lines": [ + 3, + 4, + 5, + 6, + 7, + 8, + 9, + 10 + ], + "starting_column": 1, + "ending_column": 2 + } + }, + "signature": "balanceOf(address)" } } - } - ] - }, - { - "check": "erc20-interface", - "impact": "Medium", - "confidence": "High", - "description": "Token (tests/incorrect_erc20_interface.sol#3-10) has incorrect ERC20 function interface: allowance (tests/incorrect_erc20_interface.sol#9)\n", - "elements": [ - { - "type": "function", - "name": "allowance", - "source_mapping": { - "start": 319, - "length": 60, - "filename_used": "/home/travis/build/crytic/slither/tests/incorrect_erc20_interface.sol", - "filename_relative": "tests/incorrect_erc20_interface.sol", - "filename_absolute": "/home/travis/build/crytic/slither/tests/incorrect_erc20_interface.sol", - "filename_short": "tests/incorrect_erc20_interface.sol", - "lines": [ - 9 - ], - "starting_column": 5, - "ending_column": 65 - }, - "contract": { - "type": "contract", - "name": "Token", + ] + }, + { + "check": "erc20-interface", + "impact": "Medium", + "confidence": "High", + "description": "Token (tests/incorrect_erc20_interface.sol#3-10) has incorrect ERC20 function interface: allowance (tests/incorrect_erc20_interface.sol#9)\n", + "elements": [ + { + "type": "function", + "name": "allowance", "source_mapping": { - "start": 26, - "length": 355, + "start": 319, + "length": 60, "filename_used": "/home/travis/build/crytic/slither/tests/incorrect_erc20_interface.sol", "filename_relative": "tests/incorrect_erc20_interface.sol", "filename_absolute": "/home/travis/build/crytic/slither/tests/incorrect_erc20_interface.sol", "filename_short": "tests/incorrect_erc20_interface.sol", "lines": [ - 3, - 4, - 5, - 6, - 7, - 8, - 9, - 10 + 9 ], - "starting_column": 1, - "ending_column": 2 + "starting_column": 5, + "ending_column": 65 + }, + "type_specific_fields": { + "parent": { + "type": "contract", + "name": "Token", + "source_mapping": { + "start": 26, + "length": 355, + "filename_used": "/home/travis/build/crytic/slither/tests/incorrect_erc20_interface.sol", + "filename_relative": "tests/incorrect_erc20_interface.sol", + "filename_absolute": "/home/travis/build/crytic/slither/tests/incorrect_erc20_interface.sol", + "filename_short": "tests/incorrect_erc20_interface.sol", + "lines": [ + 3, + 4, + 5, + 6, + 7, + 8, + 9, + 10 + ], + "starting_column": 1, + "ending_column": 2 + } + }, + "signature": "allowance(address,address)" } } - } - ] - } - ] + ] + } + ] + } } \ No newline at end of file diff --git a/tests/expected_json/incorrect_erc721_interface.erc721-interface.json b/tests/expected_json/incorrect_erc721_interface.erc721-interface.json index 80199df3e..5eaab9f00 100644 --- a/tests/expected_json/incorrect_erc721_interface.erc721-interface.json +++ b/tests/expected_json/incorrect_erc721_interface.erc721-interface.json @@ -1,518 +1,550 @@ { "success": true, "error": null, - "results": [ - { - "check": "erc721-interface", - "impact": "Medium", - "confidence": "High", - "description": "Token (tests/incorrect_erc721_interface.sol#6-16) has incorrect ERC721 function interface: supportsInterface (tests/incorrect_erc721_interface.sol#4)\n", - "elements": [ - { - "type": "function", - "name": "supportsInterface", - "source_mapping": { - "start": 50, - "length": 56, - "filename_used": "/home/travis/build/crytic/slither/tests/incorrect_erc721_interface.sol", - "filename_relative": "tests/incorrect_erc721_interface.sol", - "filename_absolute": "/home/travis/build/crytic/slither/tests/incorrect_erc721_interface.sol", - "filename_short": "tests/incorrect_erc721_interface.sol", - "lines": [ - 4 - ], - "starting_column": 5, - "ending_column": 61 - }, - "contract": { - "type": "contract", - "name": "IERC165", + "results": { + "detectors": [ + { + "check": "erc721-interface", + "impact": "Medium", + "confidence": "High", + "description": "Token (tests/incorrect_erc721_interface.sol#6-16) has incorrect ERC721 function interface: supportsInterface (tests/incorrect_erc721_interface.sol#4)\n", + "elements": [ + { + "type": "function", + "name": "supportsInterface", "source_mapping": { - "start": 26, - "length": 82, + "start": 50, + "length": 56, "filename_used": "/home/travis/build/crytic/slither/tests/incorrect_erc721_interface.sol", "filename_relative": "tests/incorrect_erc721_interface.sol", "filename_absolute": "/home/travis/build/crytic/slither/tests/incorrect_erc721_interface.sol", "filename_short": "tests/incorrect_erc721_interface.sol", "lines": [ - 3, - 4, - 5 + 4 ], - "starting_column": 1, - "ending_column": 2 + "starting_column": 5, + "ending_column": 61 + }, + "type_specific_fields": { + "parent": { + "type": "contract", + "name": "IERC165", + "source_mapping": { + "start": 26, + "length": 82, + "filename_used": "/home/travis/build/crytic/slither/tests/incorrect_erc721_interface.sol", + "filename_relative": "tests/incorrect_erc721_interface.sol", + "filename_absolute": "/home/travis/build/crytic/slither/tests/incorrect_erc721_interface.sol", + "filename_short": "tests/incorrect_erc721_interface.sol", + "lines": [ + 3, + 4, + 5 + ], + "starting_column": 1, + "ending_column": 2 + } + }, + "signature": "supportsInterface(bytes4)" } } - } - ] - }, - { - "check": "erc721-interface", - "impact": "Medium", - "confidence": "High", - "description": "Token (tests/incorrect_erc721_interface.sol#6-16) has incorrect ERC721 function interface: balanceOf (tests/incorrect_erc721_interface.sol#7)\n", - "elements": [ - { - "type": "function", - "name": "balanceOf", - "source_mapping": { - "start": 140, - "length": 44, - "filename_used": "/home/travis/build/crytic/slither/tests/incorrect_erc721_interface.sol", - "filename_relative": "tests/incorrect_erc721_interface.sol", - "filename_absolute": "/home/travis/build/crytic/slither/tests/incorrect_erc721_interface.sol", - "filename_short": "tests/incorrect_erc721_interface.sol", - "lines": [ - 7 - ], - "starting_column": 5, - "ending_column": 49 - }, - "contract": { - "type": "contract", - "name": "Token", + ] + }, + { + "check": "erc721-interface", + "impact": "Medium", + "confidence": "High", + "description": "Token (tests/incorrect_erc721_interface.sol#6-16) has incorrect ERC721 function interface: balanceOf (tests/incorrect_erc721_interface.sol#7)\n", + "elements": [ + { + "type": "function", + "name": "balanceOf", "source_mapping": { - "start": 109, - "length": 739, + "start": 140, + "length": 44, "filename_used": "/home/travis/build/crytic/slither/tests/incorrect_erc721_interface.sol", "filename_relative": "tests/incorrect_erc721_interface.sol", "filename_absolute": "/home/travis/build/crytic/slither/tests/incorrect_erc721_interface.sol", "filename_short": "tests/incorrect_erc721_interface.sol", "lines": [ - 6, - 7, - 8, - 9, - 10, - 11, - 12, - 13, - 14, - 15, - 16 + 7 ], - "starting_column": 1, - "ending_column": 2 + "starting_column": 5, + "ending_column": 49 + }, + "type_specific_fields": { + "parent": { + "type": "contract", + "name": "Token", + "source_mapping": { + "start": 109, + "length": 739, + "filename_used": "/home/travis/build/crytic/slither/tests/incorrect_erc721_interface.sol", + "filename_relative": "tests/incorrect_erc721_interface.sol", + "filename_absolute": "/home/travis/build/crytic/slither/tests/incorrect_erc721_interface.sol", + "filename_short": "tests/incorrect_erc721_interface.sol", + "lines": [ + 6, + 7, + 8, + 9, + 10, + 11, + 12, + 13, + 14, + 15, + 16 + ], + "starting_column": 1, + "ending_column": 2 + } + }, + "signature": "balanceOf(address)" } } - } - ] - }, - { - "check": "erc721-interface", - "impact": "Medium", - "confidence": "High", - "description": "Token (tests/incorrect_erc721_interface.sol#6-16) has incorrect ERC721 function interface: ownerOf (tests/incorrect_erc721_interface.sol#8)\n", - "elements": [ - { - "type": "function", - "name": "ownerOf", - "source_mapping": { - "start": 189, - "length": 44, - "filename_used": "/home/travis/build/crytic/slither/tests/incorrect_erc721_interface.sol", - "filename_relative": "tests/incorrect_erc721_interface.sol", - "filename_absolute": "/home/travis/build/crytic/slither/tests/incorrect_erc721_interface.sol", - "filename_short": "tests/incorrect_erc721_interface.sol", - "lines": [ - 8 - ], - "starting_column": 5, - "ending_column": 49 - }, - "contract": { - "type": "contract", - "name": "Token", + ] + }, + { + "check": "erc721-interface", + "impact": "Medium", + "confidence": "High", + "description": "Token (tests/incorrect_erc721_interface.sol#6-16) has incorrect ERC721 function interface: ownerOf (tests/incorrect_erc721_interface.sol#8)\n", + "elements": [ + { + "type": "function", + "name": "ownerOf", "source_mapping": { - "start": 109, - "length": 739, + "start": 189, + "length": 44, "filename_used": "/home/travis/build/crytic/slither/tests/incorrect_erc721_interface.sol", "filename_relative": "tests/incorrect_erc721_interface.sol", "filename_absolute": "/home/travis/build/crytic/slither/tests/incorrect_erc721_interface.sol", "filename_short": "tests/incorrect_erc721_interface.sol", "lines": [ - 6, - 7, - 8, - 9, - 10, - 11, - 12, - 13, - 14, - 15, - 16 + 8 ], - "starting_column": 1, - "ending_column": 2 + "starting_column": 5, + "ending_column": 49 + }, + "type_specific_fields": { + "parent": { + "type": "contract", + "name": "Token", + "source_mapping": { + "start": 109, + "length": 739, + "filename_used": "/home/travis/build/crytic/slither/tests/incorrect_erc721_interface.sol", + "filename_relative": "tests/incorrect_erc721_interface.sol", + "filename_absolute": "/home/travis/build/crytic/slither/tests/incorrect_erc721_interface.sol", + "filename_short": "tests/incorrect_erc721_interface.sol", + "lines": [ + 6, + 7, + 8, + 9, + 10, + 11, + 12, + 13, + 14, + 15, + 16 + ], + "starting_column": 1, + "ending_column": 2 + } + }, + "signature": "ownerOf(uint256)" } } - } - ] - }, - { - "check": "erc721-interface", - "impact": "Medium", - "confidence": "High", - "description": "Token (tests/incorrect_erc721_interface.sol#6-16) has incorrect ERC721 function interface: safeTransferFrom (tests/incorrect_erc721_interface.sol#9)\n", - "elements": [ - { - "type": "function", - "name": "safeTransferFrom", - "source_mapping": { - "start": 238, - "length": 108, - "filename_used": "/home/travis/build/crytic/slither/tests/incorrect_erc721_interface.sol", - "filename_relative": "tests/incorrect_erc721_interface.sol", - "filename_absolute": "/home/travis/build/crytic/slither/tests/incorrect_erc721_interface.sol", - "filename_short": "tests/incorrect_erc721_interface.sol", - "lines": [ - 9 - ], - "starting_column": 5, - "ending_column": 113 - }, - "contract": { - "type": "contract", - "name": "Token", + ] + }, + { + "check": "erc721-interface", + "impact": "Medium", + "confidence": "High", + "description": "Token (tests/incorrect_erc721_interface.sol#6-16) has incorrect ERC721 function interface: safeTransferFrom (tests/incorrect_erc721_interface.sol#9)\n", + "elements": [ + { + "type": "function", + "name": "safeTransferFrom", "source_mapping": { - "start": 109, - "length": 739, + "start": 238, + "length": 108, "filename_used": "/home/travis/build/crytic/slither/tests/incorrect_erc721_interface.sol", "filename_relative": "tests/incorrect_erc721_interface.sol", "filename_absolute": "/home/travis/build/crytic/slither/tests/incorrect_erc721_interface.sol", "filename_short": "tests/incorrect_erc721_interface.sol", "lines": [ - 6, - 7, - 8, - 9, - 10, - 11, - 12, - 13, - 14, - 15, - 16 + 9 ], - "starting_column": 1, - "ending_column": 2 + "starting_column": 5, + "ending_column": 113 + }, + "type_specific_fields": { + "parent": { + "type": "contract", + "name": "Token", + "source_mapping": { + "start": 109, + "length": 739, + "filename_used": "/home/travis/build/crytic/slither/tests/incorrect_erc721_interface.sol", + "filename_relative": "tests/incorrect_erc721_interface.sol", + "filename_absolute": "/home/travis/build/crytic/slither/tests/incorrect_erc721_interface.sol", + "filename_short": "tests/incorrect_erc721_interface.sol", + "lines": [ + 6, + 7, + 8, + 9, + 10, + 11, + 12, + 13, + 14, + 15, + 16 + ], + "starting_column": 1, + "ending_column": 2 + } + }, + "signature": "safeTransferFrom(address,address,uint256,bytes)" } } - } - ] - }, - { - "check": "erc721-interface", - "impact": "Medium", - "confidence": "High", - "description": "Token (tests/incorrect_erc721_interface.sol#6-16) has incorrect ERC721 function interface: safeTransferFrom (tests/incorrect_erc721_interface.sol#10)\n", - "elements": [ - { - "type": "function", - "name": "safeTransferFrom", - "source_mapping": { - "start": 351, - "length": 96, - "filename_used": "/home/travis/build/crytic/slither/tests/incorrect_erc721_interface.sol", - "filename_relative": "tests/incorrect_erc721_interface.sol", - "filename_absolute": "/home/travis/build/crytic/slither/tests/incorrect_erc721_interface.sol", - "filename_short": "tests/incorrect_erc721_interface.sol", - "lines": [ - 10 - ], - "starting_column": 5, - "ending_column": 101 - }, - "contract": { - "type": "contract", - "name": "Token", + ] + }, + { + "check": "erc721-interface", + "impact": "Medium", + "confidence": "High", + "description": "Token (tests/incorrect_erc721_interface.sol#6-16) has incorrect ERC721 function interface: safeTransferFrom (tests/incorrect_erc721_interface.sol#10)\n", + "elements": [ + { + "type": "function", + "name": "safeTransferFrom", "source_mapping": { - "start": 109, - "length": 739, + "start": 351, + "length": 96, "filename_used": "/home/travis/build/crytic/slither/tests/incorrect_erc721_interface.sol", "filename_relative": "tests/incorrect_erc721_interface.sol", "filename_absolute": "/home/travis/build/crytic/slither/tests/incorrect_erc721_interface.sol", "filename_short": "tests/incorrect_erc721_interface.sol", "lines": [ - 6, - 7, - 8, - 9, - 10, - 11, - 12, - 13, - 14, - 15, - 16 + 10 ], - "starting_column": 1, - "ending_column": 2 + "starting_column": 5, + "ending_column": 101 + }, + "type_specific_fields": { + "parent": { + "type": "contract", + "name": "Token", + "source_mapping": { + "start": 109, + "length": 739, + "filename_used": "/home/travis/build/crytic/slither/tests/incorrect_erc721_interface.sol", + "filename_relative": "tests/incorrect_erc721_interface.sol", + "filename_absolute": "/home/travis/build/crytic/slither/tests/incorrect_erc721_interface.sol", + "filename_short": "tests/incorrect_erc721_interface.sol", + "lines": [ + 6, + 7, + 8, + 9, + 10, + 11, + 12, + 13, + 14, + 15, + 16 + ], + "starting_column": 1, + "ending_column": 2 + } + }, + "signature": "safeTransferFrom(address,address,uint256)" } } - } - ] - }, - { - "check": "erc721-interface", - "impact": "Medium", - "confidence": "High", - "description": "Token (tests/incorrect_erc721_interface.sol#6-16) has incorrect ERC721 function interface: transferFrom (tests/incorrect_erc721_interface.sol#11)\n", - "elements": [ - { - "type": "function", - "name": "transferFrom", - "source_mapping": { - "start": 452, - "length": 92, - "filename_used": "/home/travis/build/crytic/slither/tests/incorrect_erc721_interface.sol", - "filename_relative": "tests/incorrect_erc721_interface.sol", - "filename_absolute": "/home/travis/build/crytic/slither/tests/incorrect_erc721_interface.sol", - "filename_short": "tests/incorrect_erc721_interface.sol", - "lines": [ - 11 - ], - "starting_column": 5, - "ending_column": 97 - }, - "contract": { - "type": "contract", - "name": "Token", + ] + }, + { + "check": "erc721-interface", + "impact": "Medium", + "confidence": "High", + "description": "Token (tests/incorrect_erc721_interface.sol#6-16) has incorrect ERC721 function interface: transferFrom (tests/incorrect_erc721_interface.sol#11)\n", + "elements": [ + { + "type": "function", + "name": "transferFrom", "source_mapping": { - "start": 109, - "length": 739, + "start": 452, + "length": 92, "filename_used": "/home/travis/build/crytic/slither/tests/incorrect_erc721_interface.sol", "filename_relative": "tests/incorrect_erc721_interface.sol", "filename_absolute": "/home/travis/build/crytic/slither/tests/incorrect_erc721_interface.sol", "filename_short": "tests/incorrect_erc721_interface.sol", "lines": [ - 6, - 7, - 8, - 9, - 10, - 11, - 12, - 13, - 14, - 15, - 16 + 11 ], - "starting_column": 1, - "ending_column": 2 + "starting_column": 5, + "ending_column": 97 + }, + "type_specific_fields": { + "parent": { + "type": "contract", + "name": "Token", + "source_mapping": { + "start": 109, + "length": 739, + "filename_used": "/home/travis/build/crytic/slither/tests/incorrect_erc721_interface.sol", + "filename_relative": "tests/incorrect_erc721_interface.sol", + "filename_absolute": "/home/travis/build/crytic/slither/tests/incorrect_erc721_interface.sol", + "filename_short": "tests/incorrect_erc721_interface.sol", + "lines": [ + 6, + 7, + 8, + 9, + 10, + 11, + 12, + 13, + 14, + 15, + 16 + ], + "starting_column": 1, + "ending_column": 2 + } + }, + "signature": "transferFrom(address,address,uint256)" } } - } - ] - }, - { - "check": "erc721-interface", - "impact": "Medium", - "confidence": "High", - "description": "Token (tests/incorrect_erc721_interface.sol#6-16) has incorrect ERC721 function interface: approve (tests/incorrect_erc721_interface.sol#12)\n", - "elements": [ - { - "type": "function", - "name": "approve", - "source_mapping": { - "start": 549, - "length": 78, - "filename_used": "/home/travis/build/crytic/slither/tests/incorrect_erc721_interface.sol", - "filename_relative": "tests/incorrect_erc721_interface.sol", - "filename_absolute": "/home/travis/build/crytic/slither/tests/incorrect_erc721_interface.sol", - "filename_short": "tests/incorrect_erc721_interface.sol", - "lines": [ - 12 - ], - "starting_column": 5, - "ending_column": 83 - }, - "contract": { - "type": "contract", - "name": "Token", + ] + }, + { + "check": "erc721-interface", + "impact": "Medium", + "confidence": "High", + "description": "Token (tests/incorrect_erc721_interface.sol#6-16) has incorrect ERC721 function interface: approve (tests/incorrect_erc721_interface.sol#12)\n", + "elements": [ + { + "type": "function", + "name": "approve", "source_mapping": { - "start": 109, - "length": 739, + "start": 549, + "length": 78, "filename_used": "/home/travis/build/crytic/slither/tests/incorrect_erc721_interface.sol", "filename_relative": "tests/incorrect_erc721_interface.sol", "filename_absolute": "/home/travis/build/crytic/slither/tests/incorrect_erc721_interface.sol", "filename_short": "tests/incorrect_erc721_interface.sol", "lines": [ - 6, - 7, - 8, - 9, - 10, - 11, - 12, - 13, - 14, - 15, - 16 + 12 ], - "starting_column": 1, - "ending_column": 2 + "starting_column": 5, + "ending_column": 83 + }, + "type_specific_fields": { + "parent": { + "type": "contract", + "name": "Token", + "source_mapping": { + "start": 109, + "length": 739, + "filename_used": "/home/travis/build/crytic/slither/tests/incorrect_erc721_interface.sol", + "filename_relative": "tests/incorrect_erc721_interface.sol", + "filename_absolute": "/home/travis/build/crytic/slither/tests/incorrect_erc721_interface.sol", + "filename_short": "tests/incorrect_erc721_interface.sol", + "lines": [ + 6, + 7, + 8, + 9, + 10, + 11, + 12, + 13, + 14, + 15, + 16 + ], + "starting_column": 1, + "ending_column": 2 + } + }, + "signature": "approve(address,uint256)" } } - } - ] - }, - { - "check": "erc721-interface", - "impact": "Medium", - "confidence": "High", - "description": "Token (tests/incorrect_erc721_interface.sol#6-16) has incorrect ERC721 function interface: setApprovalForAll (tests/incorrect_erc721_interface.sol#13)\n", - "elements": [ - { - "type": "function", - "name": "setApprovalForAll", - "source_mapping": { - "start": 632, - "length": 86, - "filename_used": "/home/travis/build/crytic/slither/tests/incorrect_erc721_interface.sol", - "filename_relative": "tests/incorrect_erc721_interface.sol", - "filename_absolute": "/home/travis/build/crytic/slither/tests/incorrect_erc721_interface.sol", - "filename_short": "tests/incorrect_erc721_interface.sol", - "lines": [ - 13 - ], - "starting_column": 5, - "ending_column": 91 - }, - "contract": { - "type": "contract", - "name": "Token", + ] + }, + { + "check": "erc721-interface", + "impact": "Medium", + "confidence": "High", + "description": "Token (tests/incorrect_erc721_interface.sol#6-16) has incorrect ERC721 function interface: setApprovalForAll (tests/incorrect_erc721_interface.sol#13)\n", + "elements": [ + { + "type": "function", + "name": "setApprovalForAll", "source_mapping": { - "start": 109, - "length": 739, + "start": 632, + "length": 86, "filename_used": "/home/travis/build/crytic/slither/tests/incorrect_erc721_interface.sol", "filename_relative": "tests/incorrect_erc721_interface.sol", "filename_absolute": "/home/travis/build/crytic/slither/tests/incorrect_erc721_interface.sol", "filename_short": "tests/incorrect_erc721_interface.sol", "lines": [ - 6, - 7, - 8, - 9, - 10, - 11, - 12, - 13, - 14, - 15, - 16 + 13 ], - "starting_column": 1, - "ending_column": 2 + "starting_column": 5, + "ending_column": 91 + }, + "type_specific_fields": { + "parent": { + "type": "contract", + "name": "Token", + "source_mapping": { + "start": 109, + "length": 739, + "filename_used": "/home/travis/build/crytic/slither/tests/incorrect_erc721_interface.sol", + "filename_relative": "tests/incorrect_erc721_interface.sol", + "filename_absolute": "/home/travis/build/crytic/slither/tests/incorrect_erc721_interface.sol", + "filename_short": "tests/incorrect_erc721_interface.sol", + "lines": [ + 6, + 7, + 8, + 9, + 10, + 11, + 12, + 13, + 14, + 15, + 16 + ], + "starting_column": 1, + "ending_column": 2 + } + }, + "signature": "setApprovalForAll(address,bool)" } } - } - ] - }, - { - "check": "erc721-interface", - "impact": "Medium", - "confidence": "High", - "description": "Token (tests/incorrect_erc721_interface.sol#6-16) has incorrect ERC721 function interface: getApproved (tests/incorrect_erc721_interface.sol#14)\n", - "elements": [ - { - "type": "function", - "name": "getApproved", - "source_mapping": { - "start": 723, - "length": 48, - "filename_used": "/home/travis/build/crytic/slither/tests/incorrect_erc721_interface.sol", - "filename_relative": "tests/incorrect_erc721_interface.sol", - "filename_absolute": "/home/travis/build/crytic/slither/tests/incorrect_erc721_interface.sol", - "filename_short": "tests/incorrect_erc721_interface.sol", - "lines": [ - 14 - ], - "starting_column": 5, - "ending_column": 53 - }, - "contract": { - "type": "contract", - "name": "Token", + ] + }, + { + "check": "erc721-interface", + "impact": "Medium", + "confidence": "High", + "description": "Token (tests/incorrect_erc721_interface.sol#6-16) has incorrect ERC721 function interface: getApproved (tests/incorrect_erc721_interface.sol#14)\n", + "elements": [ + { + "type": "function", + "name": "getApproved", "source_mapping": { - "start": 109, - "length": 739, + "start": 723, + "length": 48, "filename_used": "/home/travis/build/crytic/slither/tests/incorrect_erc721_interface.sol", "filename_relative": "tests/incorrect_erc721_interface.sol", "filename_absolute": "/home/travis/build/crytic/slither/tests/incorrect_erc721_interface.sol", "filename_short": "tests/incorrect_erc721_interface.sol", "lines": [ - 6, - 7, - 8, - 9, - 10, - 11, - 12, - 13, - 14, - 15, - 16 + 14 ], - "starting_column": 1, - "ending_column": 2 + "starting_column": 5, + "ending_column": 53 + }, + "type_specific_fields": { + "parent": { + "type": "contract", + "name": "Token", + "source_mapping": { + "start": 109, + "length": 739, + "filename_used": "/home/travis/build/crytic/slither/tests/incorrect_erc721_interface.sol", + "filename_relative": "tests/incorrect_erc721_interface.sol", + "filename_absolute": "/home/travis/build/crytic/slither/tests/incorrect_erc721_interface.sol", + "filename_short": "tests/incorrect_erc721_interface.sol", + "lines": [ + 6, + 7, + 8, + 9, + 10, + 11, + 12, + 13, + 14, + 15, + 16 + ], + "starting_column": 1, + "ending_column": 2 + } + }, + "signature": "getApproved(uint256)" } } - } - ] - }, - { - "check": "erc721-interface", - "impact": "Medium", - "confidence": "High", - "description": "Token (tests/incorrect_erc721_interface.sol#6-16) has incorrect ERC721 function interface: isApprovedForAll (tests/incorrect_erc721_interface.sol#15)\n", - "elements": [ - { - "type": "function", - "name": "isApprovedForAll", - "source_mapping": { - "start": 776, - "length": 70, - "filename_used": "/home/travis/build/crytic/slither/tests/incorrect_erc721_interface.sol", - "filename_relative": "tests/incorrect_erc721_interface.sol", - "filename_absolute": "/home/travis/build/crytic/slither/tests/incorrect_erc721_interface.sol", - "filename_short": "tests/incorrect_erc721_interface.sol", - "lines": [ - 15 - ], - "starting_column": 5, - "ending_column": 75 - }, - "contract": { - "type": "contract", - "name": "Token", + ] + }, + { + "check": "erc721-interface", + "impact": "Medium", + "confidence": "High", + "description": "Token (tests/incorrect_erc721_interface.sol#6-16) has incorrect ERC721 function interface: isApprovedForAll (tests/incorrect_erc721_interface.sol#15)\n", + "elements": [ + { + "type": "function", + "name": "isApprovedForAll", "source_mapping": { - "start": 109, - "length": 739, + "start": 776, + "length": 70, "filename_used": "/home/travis/build/crytic/slither/tests/incorrect_erc721_interface.sol", "filename_relative": "tests/incorrect_erc721_interface.sol", "filename_absolute": "/home/travis/build/crytic/slither/tests/incorrect_erc721_interface.sol", "filename_short": "tests/incorrect_erc721_interface.sol", "lines": [ - 6, - 7, - 8, - 9, - 10, - 11, - 12, - 13, - 14, - 15, - 16 + 15 ], - "starting_column": 1, - "ending_column": 2 + "starting_column": 5, + "ending_column": 75 + }, + "type_specific_fields": { + "parent": { + "type": "contract", + "name": "Token", + "source_mapping": { + "start": 109, + "length": 739, + "filename_used": "/home/travis/build/crytic/slither/tests/incorrect_erc721_interface.sol", + "filename_relative": "tests/incorrect_erc721_interface.sol", + "filename_absolute": "/home/travis/build/crytic/slither/tests/incorrect_erc721_interface.sol", + "filename_short": "tests/incorrect_erc721_interface.sol", + "lines": [ + 6, + 7, + 8, + 9, + 10, + 11, + 12, + 13, + 14, + 15, + 16 + ], + "starting_column": 1, + "ending_column": 2 + } + }, + "signature": "isApprovedForAll(address,address)" } } - } - ] - } - ] + ] + } + ] + } } \ No newline at end of file diff --git a/tests/expected_json/inline_assembly_contract-0.5.1.assembly.json b/tests/expected_json/inline_assembly_contract-0.5.1.assembly.json index aef099596..d48921b4d 100644 --- a/tests/expected_json/inline_assembly_contract-0.5.1.assembly.json +++ b/tests/expected_json/inline_assembly_contract-0.5.1.assembly.json @@ -1,55 +1,25 @@ { "success": true, "error": null, - "results": [ - { - "check": "assembly", - "impact": "Informational", - "confidence": "High", - "description": "GetCode.at uses assembly (tests/inline_assembly_contract-0.5.1.sol#6-20)\n\t- tests/inline_assembly_contract-0.5.1.sol#7-20\n", - "elements": [ - { - "type": "function", - "name": "at", - "source_mapping": { - "start": 119, - "length": 707, - "filename_used": "/home/travis/build/crytic/slither/tests/inline_assembly_contract-0.5.1.sol", - "filename_relative": "tests/inline_assembly_contract-0.5.1.sol", - "filename_absolute": "/home/travis/build/crytic/slither/tests/inline_assembly_contract-0.5.1.sol", - "filename_short": "tests/inline_assembly_contract-0.5.1.sol", - "lines": [ - 6, - 7, - 8, - 9, - 10, - 11, - 12, - 13, - 14, - 15, - 16, - 17, - 18, - 19, - 20 - ], - "starting_column": 5, - "ending_column": 6 - }, - "contract": { - "type": "contract", - "name": "GetCode", + "results": { + "detectors": [ + { + "check": "assembly", + "impact": "Informational", + "confidence": "High", + "description": "GetCode.at uses assembly (tests/inline_assembly_contract-0.5.1.sol#6-20)\n\t- tests/inline_assembly_contract-0.5.1.sol#7-20\n", + "elements": [ + { + "type": "function", + "name": "at", "source_mapping": { - "start": 97, - "length": 731, + "start": 119, + "length": 707, "filename_used": "/home/travis/build/crytic/slither/tests/inline_assembly_contract-0.5.1.sol", "filename_relative": "tests/inline_assembly_contract-0.5.1.sol", "filename_absolute": "/home/travis/build/crytic/slither/tests/inline_assembly_contract-0.5.1.sol", "filename_short": "tests/inline_assembly_contract-0.5.1.sol", "lines": [ - 5, 6, 7, 8, @@ -64,55 +34,59 @@ 17, 18, 19, - 20, - 21 + 20 ], - "starting_column": 1, - "ending_column": 2 + "starting_column": 5, + "ending_column": 6 + }, + "type_specific_fields": { + "parent": { + "type": "contract", + "name": "GetCode", + "source_mapping": { + "start": 97, + "length": 731, + "filename_used": "/home/travis/build/crytic/slither/tests/inline_assembly_contract-0.5.1.sol", + "filename_relative": "tests/inline_assembly_contract-0.5.1.sol", + "filename_absolute": "/home/travis/build/crytic/slither/tests/inline_assembly_contract-0.5.1.sol", + "filename_short": "tests/inline_assembly_contract-0.5.1.sol", + "lines": [ + 5, + 6, + 7, + 8, + 9, + 10, + 11, + 12, + 13, + 14, + 15, + 16, + 17, + 18, + 19, + 20, + 21 + ], + "starting_column": 1, + "ending_column": 2 + } + }, + "signature": "at(address)" } - } - }, - { - "type": "node", - "name": "", - "source_mapping": { - "start": 198, - "length": 628, - "filename_used": "/home/travis/build/crytic/slither/tests/inline_assembly_contract-0.5.1.sol", - "filename_relative": "tests/inline_assembly_contract-0.5.1.sol", - "filename_absolute": "/home/travis/build/crytic/slither/tests/inline_assembly_contract-0.5.1.sol", - "filename_short": "tests/inline_assembly_contract-0.5.1.sol", - "lines": [ - 7, - 8, - 9, - 10, - 11, - 12, - 13, - 14, - 15, - 16, - 17, - 18, - 19, - 20 - ], - "starting_column": 9, - "ending_column": 6 }, - "function": { - "type": "function", - "name": "at", + { + "type": "node", + "name": "", "source_mapping": { - "start": 119, - "length": 707, + "start": 198, + "length": 628, "filename_used": "/home/travis/build/crytic/slither/tests/inline_assembly_contract-0.5.1.sol", "filename_relative": "tests/inline_assembly_contract-0.5.1.sol", "filename_absolute": "/home/travis/build/crytic/slither/tests/inline_assembly_contract-0.5.1.sol", "filename_short": "tests/inline_assembly_contract-0.5.1.sol", "lines": [ - 6, 7, 8, 9, @@ -128,45 +102,81 @@ 19, 20 ], - "starting_column": 5, + "starting_column": 9, "ending_column": 6 }, - "contract": { - "type": "contract", - "name": "GetCode", - "source_mapping": { - "start": 97, - "length": 731, - "filename_used": "/home/travis/build/crytic/slither/tests/inline_assembly_contract-0.5.1.sol", - "filename_relative": "tests/inline_assembly_contract-0.5.1.sol", - "filename_absolute": "/home/travis/build/crytic/slither/tests/inline_assembly_contract-0.5.1.sol", - "filename_short": "tests/inline_assembly_contract-0.5.1.sol", - "lines": [ - 5, - 6, - 7, - 8, - 9, - 10, - 11, - 12, - 13, - 14, - 15, - 16, - 17, - 18, - 19, - 20, - 21 - ], - "starting_column": 1, - "ending_column": 2 + "type_specific_fields": { + "parent": { + "type": "function", + "name": "at", + "source_mapping": { + "start": 119, + "length": 707, + "filename_used": "/home/travis/build/crytic/slither/tests/inline_assembly_contract-0.5.1.sol", + "filename_relative": "tests/inline_assembly_contract-0.5.1.sol", + "filename_absolute": "/home/travis/build/crytic/slither/tests/inline_assembly_contract-0.5.1.sol", + "filename_short": "tests/inline_assembly_contract-0.5.1.sol", + "lines": [ + 6, + 7, + 8, + 9, + 10, + 11, + 12, + 13, + 14, + 15, + 16, + 17, + 18, + 19, + 20 + ], + "starting_column": 5, + "ending_column": 6 + }, + "type_specific_fields": { + "parent": { + "type": "contract", + "name": "GetCode", + "source_mapping": { + "start": 97, + "length": 731, + "filename_used": "/home/travis/build/crytic/slither/tests/inline_assembly_contract-0.5.1.sol", + "filename_relative": "tests/inline_assembly_contract-0.5.1.sol", + "filename_absolute": "/home/travis/build/crytic/slither/tests/inline_assembly_contract-0.5.1.sol", + "filename_short": "tests/inline_assembly_contract-0.5.1.sol", + "lines": [ + 5, + 6, + 7, + 8, + 9, + 10, + 11, + 12, + 13, + 14, + 15, + 16, + 17, + 18, + 19, + 20, + 21 + ], + "starting_column": 1, + "ending_column": 2 + } + }, + "signature": "at(address)" + } } } } - } - ] - } - ] + ] + } + ] + } } \ No newline at end of file diff --git a/tests/expected_json/inline_assembly_contract.assembly.json b/tests/expected_json/inline_assembly_contract.assembly.json index bc28bce11..4dda29a5b 100644 --- a/tests/expected_json/inline_assembly_contract.assembly.json +++ b/tests/expected_json/inline_assembly_contract.assembly.json @@ -1,55 +1,25 @@ { "success": true, "error": null, - "results": [ - { - "check": "assembly", - "impact": "Informational", - "confidence": "High", - "description": "GetCode.at uses assembly (tests/inline_assembly_contract.sol#6-20)\n\t- tests/inline_assembly_contract.sol#7-20\n", - "elements": [ - { - "type": "function", - "name": "at", - "source_mapping": { - "start": 119, - "length": 700, - "filename_used": "/home/travis/build/crytic/slither/tests/inline_assembly_contract.sol", - "filename_relative": "tests/inline_assembly_contract.sol", - "filename_absolute": "/home/travis/build/crytic/slither/tests/inline_assembly_contract.sol", - "filename_short": "tests/inline_assembly_contract.sol", - "lines": [ - 6, - 7, - 8, - 9, - 10, - 11, - 12, - 13, - 14, - 15, - 16, - 17, - 18, - 19, - 20 - ], - "starting_column": 5, - "ending_column": 6 - }, - "contract": { - "type": "contract", - "name": "GetCode", + "results": { + "detectors": [ + { + "check": "assembly", + "impact": "Informational", + "confidence": "High", + "description": "GetCode.at uses assembly (tests/inline_assembly_contract.sol#6-20)\n\t- tests/inline_assembly_contract.sol#7-20\n", + "elements": [ + { + "type": "function", + "name": "at", "source_mapping": { - "start": 97, - "length": 724, + "start": 119, + "length": 700, "filename_used": "/home/travis/build/crytic/slither/tests/inline_assembly_contract.sol", "filename_relative": "tests/inline_assembly_contract.sol", "filename_absolute": "/home/travis/build/crytic/slither/tests/inline_assembly_contract.sol", "filename_short": "tests/inline_assembly_contract.sol", "lines": [ - 5, 6, 7, 8, @@ -64,55 +34,59 @@ 17, 18, 19, - 20, - 21 + 20 ], - "starting_column": 1, - "ending_column": 2 + "starting_column": 5, + "ending_column": 6 + }, + "type_specific_fields": { + "parent": { + "type": "contract", + "name": "GetCode", + "source_mapping": { + "start": 97, + "length": 724, + "filename_used": "/home/travis/build/crytic/slither/tests/inline_assembly_contract.sol", + "filename_relative": "tests/inline_assembly_contract.sol", + "filename_absolute": "/home/travis/build/crytic/slither/tests/inline_assembly_contract.sol", + "filename_short": "tests/inline_assembly_contract.sol", + "lines": [ + 5, + 6, + 7, + 8, + 9, + 10, + 11, + 12, + 13, + 14, + 15, + 16, + 17, + 18, + 19, + 20, + 21 + ], + "starting_column": 1, + "ending_column": 2 + } + }, + "signature": "at(address)" } - } - }, - { - "type": "node", - "name": "", - "source_mapping": { - "start": 191, - "length": 628, - "filename_used": "/home/travis/build/crytic/slither/tests/inline_assembly_contract.sol", - "filename_relative": "tests/inline_assembly_contract.sol", - "filename_absolute": "/home/travis/build/crytic/slither/tests/inline_assembly_contract.sol", - "filename_short": "tests/inline_assembly_contract.sol", - "lines": [ - 7, - 8, - 9, - 10, - 11, - 12, - 13, - 14, - 15, - 16, - 17, - 18, - 19, - 20 - ], - "starting_column": 9, - "ending_column": 6 }, - "function": { - "type": "function", - "name": "at", + { + "type": "node", + "name": "", "source_mapping": { - "start": 119, - "length": 700, + "start": 191, + "length": 628, "filename_used": "/home/travis/build/crytic/slither/tests/inline_assembly_contract.sol", "filename_relative": "tests/inline_assembly_contract.sol", "filename_absolute": "/home/travis/build/crytic/slither/tests/inline_assembly_contract.sol", "filename_short": "tests/inline_assembly_contract.sol", "lines": [ - 6, 7, 8, 9, @@ -128,45 +102,81 @@ 19, 20 ], - "starting_column": 5, + "starting_column": 9, "ending_column": 6 }, - "contract": { - "type": "contract", - "name": "GetCode", - "source_mapping": { - "start": 97, - "length": 724, - "filename_used": "/home/travis/build/crytic/slither/tests/inline_assembly_contract.sol", - "filename_relative": "tests/inline_assembly_contract.sol", - "filename_absolute": "/home/travis/build/crytic/slither/tests/inline_assembly_contract.sol", - "filename_short": "tests/inline_assembly_contract.sol", - "lines": [ - 5, - 6, - 7, - 8, - 9, - 10, - 11, - 12, - 13, - 14, - 15, - 16, - 17, - 18, - 19, - 20, - 21 - ], - "starting_column": 1, - "ending_column": 2 + "type_specific_fields": { + "parent": { + "type": "function", + "name": "at", + "source_mapping": { + "start": 119, + "length": 700, + "filename_used": "/home/travis/build/crytic/slither/tests/inline_assembly_contract.sol", + "filename_relative": "tests/inline_assembly_contract.sol", + "filename_absolute": "/home/travis/build/crytic/slither/tests/inline_assembly_contract.sol", + "filename_short": "tests/inline_assembly_contract.sol", + "lines": [ + 6, + 7, + 8, + 9, + 10, + 11, + 12, + 13, + 14, + 15, + 16, + 17, + 18, + 19, + 20 + ], + "starting_column": 5, + "ending_column": 6 + }, + "type_specific_fields": { + "parent": { + "type": "contract", + "name": "GetCode", + "source_mapping": { + "start": 97, + "length": 724, + "filename_used": "/home/travis/build/crytic/slither/tests/inline_assembly_contract.sol", + "filename_relative": "tests/inline_assembly_contract.sol", + "filename_absolute": "/home/travis/build/crytic/slither/tests/inline_assembly_contract.sol", + "filename_short": "tests/inline_assembly_contract.sol", + "lines": [ + 5, + 6, + 7, + 8, + 9, + 10, + 11, + 12, + 13, + 14, + 15, + 16, + 17, + 18, + 19, + 20, + 21 + ], + "starting_column": 1, + "ending_column": 2 + } + }, + "signature": "at(address)" + } } } } - } - ] - } - ] + ] + } + ] + } } \ No newline at end of file diff --git a/tests/expected_json/inline_assembly_library-0.5.1.assembly.json b/tests/expected_json/inline_assembly_library-0.5.1.assembly.json index f0afdb643..c75e719b1 100644 --- a/tests/expected_json/inline_assembly_library-0.5.1.assembly.json +++ b/tests/expected_json/inline_assembly_library-0.5.1.assembly.json @@ -1,276 +1,227 @@ { "success": true, "error": null, - "results": [ - { - "check": "assembly", - "impact": "Informational", - "confidence": "High", - "description": "VectorSum.sumAsm uses assembly (tests/inline_assembly_library-0.5.1.sol#16-22)\n\t- tests/inline_assembly_library-0.5.1.sol#18-21\n", - "elements": [ - { - "type": "function", - "name": "sumAsm", - "source_mapping": { - "start": 599, - "length": 254, - "filename_used": "/home/travis/build/crytic/slither/tests/inline_assembly_library-0.5.1.sol", - "filename_relative": "tests/inline_assembly_library-0.5.1.sol", - "filename_absolute": "/home/travis/build/crytic/slither/tests/inline_assembly_library-0.5.1.sol", - "filename_short": "tests/inline_assembly_library-0.5.1.sol", - "lines": [ - 16, - 17, - 18, - 19, - 20, - 21, - 22 - ], - "starting_column": 5, - "ending_column": 6 - }, - "contract": { - "type": "contract", - "name": "VectorSum", + "results": { + "detectors": [ + { + "check": "assembly", + "impact": "Informational", + "confidence": "High", + "description": "VectorSum.sumAsm uses assembly (tests/inline_assembly_library-0.5.1.sol#16-22)\n\t- tests/inline_assembly_library-0.5.1.sol#18-21\n", + "elements": [ + { + "type": "function", + "name": "sumAsm", "source_mapping": { - "start": 97, - "length": 1602, + "start": 599, + "length": 254, "filename_used": "/home/travis/build/crytic/slither/tests/inline_assembly_library-0.5.1.sol", "filename_relative": "tests/inline_assembly_library-0.5.1.sol", "filename_absolute": "/home/travis/build/crytic/slither/tests/inline_assembly_library-0.5.1.sol", "filename_short": "tests/inline_assembly_library-0.5.1.sol", "lines": [ - 5, - 6, - 7, - 8, - 9, - 10, - 11, - 12, - 13, - 14, - 15, 16, 17, 18, 19, 20, 21, - 22, - 23, - 24, - 25, - 26, - 27, - 28, - 29, - 30, - 31, - 32, - 33, - 34, - 35, - 36, - 37, - 38, - 39, - 40, - 41, - 42, - 43, - 44, - 45, - 46, - 47, - 48 + 22 ], - "starting_column": 1, - "ending_column": 2 + "starting_column": 5, + "ending_column": 6 + }, + "type_specific_fields": { + "parent": { + "type": "contract", + "name": "VectorSum", + "source_mapping": { + "start": 97, + "length": 1602, + "filename_used": "/home/travis/build/crytic/slither/tests/inline_assembly_library-0.5.1.sol", + "filename_relative": "tests/inline_assembly_library-0.5.1.sol", + "filename_absolute": "/home/travis/build/crytic/slither/tests/inline_assembly_library-0.5.1.sol", + "filename_short": "tests/inline_assembly_library-0.5.1.sol", + "lines": [ + 5, + 6, + 7, + 8, + 9, + 10, + 11, + 12, + 13, + 14, + 15, + 16, + 17, + 18, + 19, + 20, + 21, + 22, + 23, + 24, + 25, + 26, + 27, + 28, + 29, + 30, + 31, + 32, + 33, + 34, + 35, + 36, + 37, + 38, + 39, + 40, + 41, + 42, + 43, + 44, + 45, + 46, + 47, + 48 + ], + "starting_column": 1, + "ending_column": 2 + } + }, + "signature": "sumAsm(uint256[])" } - } - }, - { - "type": "node", - "name": "", - "source_mapping": { - "start": 733, - "length": 114, - "filename_used": "/home/travis/build/crytic/slither/tests/inline_assembly_library-0.5.1.sol", - "filename_relative": "tests/inline_assembly_library-0.5.1.sol", - "filename_absolute": "/home/travis/build/crytic/slither/tests/inline_assembly_library-0.5.1.sol", - "filename_short": "tests/inline_assembly_library-0.5.1.sol", - "lines": [ - 18, - 19, - 20, - 21 - ], - "starting_column": 13, - "ending_column": 10 }, - "function": { - "type": "function", - "name": "sumAsm", + { + "type": "node", + "name": "", "source_mapping": { - "start": 599, - "length": 254, + "start": 733, + "length": 114, "filename_used": "/home/travis/build/crytic/slither/tests/inline_assembly_library-0.5.1.sol", "filename_relative": "tests/inline_assembly_library-0.5.1.sol", "filename_absolute": "/home/travis/build/crytic/slither/tests/inline_assembly_library-0.5.1.sol", "filename_short": "tests/inline_assembly_library-0.5.1.sol", "lines": [ - 16, - 17, 18, 19, 20, - 21, - 22 + 21 ], - "starting_column": 5, - "ending_column": 6 + "starting_column": 13, + "ending_column": 10 }, - "contract": { - "type": "contract", - "name": "VectorSum", - "source_mapping": { - "start": 97, - "length": 1602, - "filename_used": "/home/travis/build/crytic/slither/tests/inline_assembly_library-0.5.1.sol", - "filename_relative": "tests/inline_assembly_library-0.5.1.sol", - "filename_absolute": "/home/travis/build/crytic/slither/tests/inline_assembly_library-0.5.1.sol", - "filename_short": "tests/inline_assembly_library-0.5.1.sol", - "lines": [ - 5, - 6, - 7, - 8, - 9, - 10, - 11, - 12, - 13, - 14, - 15, - 16, - 17, - 18, - 19, - 20, - 21, - 22, - 23, - 24, - 25, - 26, - 27, - 28, - 29, - 30, - 31, - 32, - 33, - 34, - 35, - 36, - 37, - 38, - 39, - 40, - 41, - 42, - 43, - 44, - 45, - 46, - 47, - 48 - ], - "starting_column": 1, - "ending_column": 2 + "type_specific_fields": { + "parent": { + "type": "function", + "name": "sumAsm", + "source_mapping": { + "start": 599, + "length": 254, + "filename_used": "/home/travis/build/crytic/slither/tests/inline_assembly_library-0.5.1.sol", + "filename_relative": "tests/inline_assembly_library-0.5.1.sol", + "filename_absolute": "/home/travis/build/crytic/slither/tests/inline_assembly_library-0.5.1.sol", + "filename_short": "tests/inline_assembly_library-0.5.1.sol", + "lines": [ + 16, + 17, + 18, + 19, + 20, + 21, + 22 + ], + "starting_column": 5, + "ending_column": 6 + }, + "type_specific_fields": { + "parent": { + "type": "contract", + "name": "VectorSum", + "source_mapping": { + "start": 97, + "length": 1602, + "filename_used": "/home/travis/build/crytic/slither/tests/inline_assembly_library-0.5.1.sol", + "filename_relative": "tests/inline_assembly_library-0.5.1.sol", + "filename_absolute": "/home/travis/build/crytic/slither/tests/inline_assembly_library-0.5.1.sol", + "filename_short": "tests/inline_assembly_library-0.5.1.sol", + "lines": [ + 5, + 6, + 7, + 8, + 9, + 10, + 11, + 12, + 13, + 14, + 15, + 16, + 17, + 18, + 19, + 20, + 21, + 22, + 23, + 24, + 25, + 26, + 27, + 28, + 29, + 30, + 31, + 32, + 33, + 34, + 35, + 36, + 37, + 38, + 39, + 40, + 41, + 42, + 43, + 44, + 45, + 46, + 47, + 48 + ], + "starting_column": 1, + "ending_column": 2 + } + }, + "signature": "sumAsm(uint256[])" + } } } } - } - ] - }, - { - "check": "assembly", - "impact": "Informational", - "confidence": "High", - "description": "VectorSum.sumPureAsm uses assembly (tests/inline_assembly_library-0.5.1.sol#25-47)\n\t- tests/inline_assembly_library-0.5.1.sol#26-47\n", - "elements": [ - { - "type": "function", - "name": "sumPureAsm", - "source_mapping": { - "start": 936, - "length": 761, - "filename_used": "/home/travis/build/crytic/slither/tests/inline_assembly_library-0.5.1.sol", - "filename_relative": "tests/inline_assembly_library-0.5.1.sol", - "filename_absolute": "/home/travis/build/crytic/slither/tests/inline_assembly_library-0.5.1.sol", - "filename_short": "tests/inline_assembly_library-0.5.1.sol", - "lines": [ - 25, - 26, - 27, - 28, - 29, - 30, - 31, - 32, - 33, - 34, - 35, - 36, - 37, - 38, - 39, - 40, - 41, - 42, - 43, - 44, - 45, - 46, - 47 - ], - "starting_column": 5, - "ending_column": 6 - }, - "contract": { - "type": "contract", - "name": "VectorSum", + ] + }, + { + "check": "assembly", + "impact": "Informational", + "confidence": "High", + "description": "VectorSum.sumPureAsm uses assembly (tests/inline_assembly_library-0.5.1.sol#25-47)\n\t- tests/inline_assembly_library-0.5.1.sol#26-47\n", + "elements": [ + { + "type": "function", + "name": "sumPureAsm", "source_mapping": { - "start": 97, - "length": 1602, + "start": 936, + "length": 761, "filename_used": "/home/travis/build/crytic/slither/tests/inline_assembly_library-0.5.1.sol", "filename_relative": "tests/inline_assembly_library-0.5.1.sol", "filename_absolute": "/home/travis/build/crytic/slither/tests/inline_assembly_library-0.5.1.sol", "filename_short": "tests/inline_assembly_library-0.5.1.sol", "lines": [ - 5, - 6, - 7, - 8, - 9, - 10, - 11, - 12, - 13, - 14, - 15, - 16, - 17, - 18, - 19, - 20, - 21, - 22, - 23, - 24, 25, 26, 27, @@ -293,63 +244,86 @@ 44, 45, 46, - 47, - 48 + 47 ], - "starting_column": 1, - "ending_column": 2 + "starting_column": 5, + "ending_column": 6 + }, + "type_specific_fields": { + "parent": { + "type": "contract", + "name": "VectorSum", + "source_mapping": { + "start": 97, + "length": 1602, + "filename_used": "/home/travis/build/crytic/slither/tests/inline_assembly_library-0.5.1.sol", + "filename_relative": "tests/inline_assembly_library-0.5.1.sol", + "filename_absolute": "/home/travis/build/crytic/slither/tests/inline_assembly_library-0.5.1.sol", + "filename_short": "tests/inline_assembly_library-0.5.1.sol", + "lines": [ + 5, + 6, + 7, + 8, + 9, + 10, + 11, + 12, + 13, + 14, + 15, + 16, + 17, + 18, + 19, + 20, + 21, + 22, + 23, + 24, + 25, + 26, + 27, + 28, + 29, + 30, + 31, + 32, + 33, + 34, + 35, + 36, + 37, + 38, + 39, + 40, + 41, + 42, + 43, + 44, + 45, + 46, + 47, + 48 + ], + "starting_column": 1, + "ending_column": 2 + } + }, + "signature": "sumPureAsm(uint256[])" } - } - }, - { - "type": "node", - "name": "", - "source_mapping": { - "start": 1020, - "length": 677, - "filename_used": "/home/travis/build/crytic/slither/tests/inline_assembly_library-0.5.1.sol", - "filename_relative": "tests/inline_assembly_library-0.5.1.sol", - "filename_absolute": "/home/travis/build/crytic/slither/tests/inline_assembly_library-0.5.1.sol", - "filename_short": "tests/inline_assembly_library-0.5.1.sol", - "lines": [ - 26, - 27, - 28, - 29, - 30, - 31, - 32, - 33, - 34, - 35, - 36, - 37, - 38, - 39, - 40, - 41, - 42, - 43, - 44, - 45, - 46, - 47 - ], - "starting_column": 9, - "ending_column": 6 }, - "function": { - "type": "function", - "name": "sumPureAsm", + { + "type": "node", + "name": "", "source_mapping": { - "start": 936, - "length": 761, + "start": 1020, + "length": 677, "filename_used": "/home/travis/build/crytic/slither/tests/inline_assembly_library-0.5.1.sol", "filename_relative": "tests/inline_assembly_library-0.5.1.sol", "filename_absolute": "/home/travis/build/crytic/slither/tests/inline_assembly_library-0.5.1.sol", "filename_short": "tests/inline_assembly_library-0.5.1.sol", "lines": [ - 25, 26, 27, 28, @@ -373,72 +347,116 @@ 46, 47 ], - "starting_column": 5, + "starting_column": 9, "ending_column": 6 }, - "contract": { - "type": "contract", - "name": "VectorSum", - "source_mapping": { - "start": 97, - "length": 1602, - "filename_used": "/home/travis/build/crytic/slither/tests/inline_assembly_library-0.5.1.sol", - "filename_relative": "tests/inline_assembly_library-0.5.1.sol", - "filename_absolute": "/home/travis/build/crytic/slither/tests/inline_assembly_library-0.5.1.sol", - "filename_short": "tests/inline_assembly_library-0.5.1.sol", - "lines": [ - 5, - 6, - 7, - 8, - 9, - 10, - 11, - 12, - 13, - 14, - 15, - 16, - 17, - 18, - 19, - 20, - 21, - 22, - 23, - 24, - 25, - 26, - 27, - 28, - 29, - 30, - 31, - 32, - 33, - 34, - 35, - 36, - 37, - 38, - 39, - 40, - 41, - 42, - 43, - 44, - 45, - 46, - 47, - 48 - ], - "starting_column": 1, - "ending_column": 2 + "type_specific_fields": { + "parent": { + "type": "function", + "name": "sumPureAsm", + "source_mapping": { + "start": 936, + "length": 761, + "filename_used": "/home/travis/build/crytic/slither/tests/inline_assembly_library-0.5.1.sol", + "filename_relative": "tests/inline_assembly_library-0.5.1.sol", + "filename_absolute": "/home/travis/build/crytic/slither/tests/inline_assembly_library-0.5.1.sol", + "filename_short": "tests/inline_assembly_library-0.5.1.sol", + "lines": [ + 25, + 26, + 27, + 28, + 29, + 30, + 31, + 32, + 33, + 34, + 35, + 36, + 37, + 38, + 39, + 40, + 41, + 42, + 43, + 44, + 45, + 46, + 47 + ], + "starting_column": 5, + "ending_column": 6 + }, + "type_specific_fields": { + "parent": { + "type": "contract", + "name": "VectorSum", + "source_mapping": { + "start": 97, + "length": 1602, + "filename_used": "/home/travis/build/crytic/slither/tests/inline_assembly_library-0.5.1.sol", + "filename_relative": "tests/inline_assembly_library-0.5.1.sol", + "filename_absolute": "/home/travis/build/crytic/slither/tests/inline_assembly_library-0.5.1.sol", + "filename_short": "tests/inline_assembly_library-0.5.1.sol", + "lines": [ + 5, + 6, + 7, + 8, + 9, + 10, + 11, + 12, + 13, + 14, + 15, + 16, + 17, + 18, + 19, + 20, + 21, + 22, + 23, + 24, + 25, + 26, + 27, + 28, + 29, + 30, + 31, + 32, + 33, + 34, + 35, + 36, + 37, + 38, + 39, + 40, + 41, + 42, + 43, + 44, + 45, + 46, + 47, + 48 + ], + "starting_column": 1, + "ending_column": 2 + } + }, + "signature": "sumPureAsm(uint256[])" + } } } } - } - ] - } - ] + ] + } + ] + } } \ No newline at end of file diff --git a/tests/expected_json/inline_assembly_library.assembly.json b/tests/expected_json/inline_assembly_library.assembly.json index 0ea78cc6f..04c388ea3 100644 --- a/tests/expected_json/inline_assembly_library.assembly.json +++ b/tests/expected_json/inline_assembly_library.assembly.json @@ -1,276 +1,227 @@ { "success": true, "error": null, - "results": [ - { - "check": "assembly", - "impact": "Informational", - "confidence": "High", - "description": "VectorSum.sumAsm uses assembly (tests/inline_assembly_library.sol#16-22)\n\t- tests/inline_assembly_library.sol#18-21\n", - "elements": [ - { - "type": "function", - "name": "sumAsm", - "source_mapping": { - "start": 593, - "length": 247, - "filename_used": "/home/travis/build/crytic/slither/tests/inline_assembly_library.sol", - "filename_relative": "tests/inline_assembly_library.sol", - "filename_absolute": "/home/travis/build/crytic/slither/tests/inline_assembly_library.sol", - "filename_short": "tests/inline_assembly_library.sol", - "lines": [ - 16, - 17, - 18, - 19, - 20, - 21, - 22 - ], - "starting_column": 5, - "ending_column": 6 - }, - "contract": { - "type": "contract", - "name": "VectorSum", + "results": { + "detectors": [ + { + "check": "assembly", + "impact": "Informational", + "confidence": "High", + "description": "VectorSum.sumAsm uses assembly (tests/inline_assembly_library.sol#16-22)\n\t- tests/inline_assembly_library.sol#18-21\n", + "elements": [ + { + "type": "function", + "name": "sumAsm", "source_mapping": { - "start": 98, - "length": 1581, + "start": 593, + "length": 247, "filename_used": "/home/travis/build/crytic/slither/tests/inline_assembly_library.sol", "filename_relative": "tests/inline_assembly_library.sol", "filename_absolute": "/home/travis/build/crytic/slither/tests/inline_assembly_library.sol", "filename_short": "tests/inline_assembly_library.sol", "lines": [ - 5, - 6, - 7, - 8, - 9, - 10, - 11, - 12, - 13, - 14, - 15, 16, 17, 18, 19, 20, 21, - 22, - 23, - 24, - 25, - 26, - 27, - 28, - 29, - 30, - 31, - 32, - 33, - 34, - 35, - 36, - 37, - 38, - 39, - 40, - 41, - 42, - 43, - 44, - 45, - 46, - 47, - 48 + 22 ], - "starting_column": 1, - "ending_column": 2 + "starting_column": 5, + "ending_column": 6 + }, + "type_specific_fields": { + "parent": { + "type": "contract", + "name": "VectorSum", + "source_mapping": { + "start": 98, + "length": 1581, + "filename_used": "/home/travis/build/crytic/slither/tests/inline_assembly_library.sol", + "filename_relative": "tests/inline_assembly_library.sol", + "filename_absolute": "/home/travis/build/crytic/slither/tests/inline_assembly_library.sol", + "filename_short": "tests/inline_assembly_library.sol", + "lines": [ + 5, + 6, + 7, + 8, + 9, + 10, + 11, + 12, + 13, + 14, + 15, + 16, + 17, + 18, + 19, + 20, + 21, + 22, + 23, + 24, + 25, + 26, + 27, + 28, + 29, + 30, + 31, + 32, + 33, + 34, + 35, + 36, + 37, + 38, + 39, + 40, + 41, + 42, + 43, + 44, + 45, + 46, + 47, + 48 + ], + "starting_column": 1, + "ending_column": 2 + } + }, + "signature": "sumAsm(uint256[])" } - } - }, - { - "type": "node", - "name": "", - "source_mapping": { - "start": 720, - "length": 114, - "filename_used": "/home/travis/build/crytic/slither/tests/inline_assembly_library.sol", - "filename_relative": "tests/inline_assembly_library.sol", - "filename_absolute": "/home/travis/build/crytic/slither/tests/inline_assembly_library.sol", - "filename_short": "tests/inline_assembly_library.sol", - "lines": [ - 18, - 19, - 20, - 21 - ], - "starting_column": 13, - "ending_column": 10 }, - "function": { - "type": "function", - "name": "sumAsm", + { + "type": "node", + "name": "", "source_mapping": { - "start": 593, - "length": 247, + "start": 720, + "length": 114, "filename_used": "/home/travis/build/crytic/slither/tests/inline_assembly_library.sol", "filename_relative": "tests/inline_assembly_library.sol", "filename_absolute": "/home/travis/build/crytic/slither/tests/inline_assembly_library.sol", "filename_short": "tests/inline_assembly_library.sol", "lines": [ - 16, - 17, 18, 19, 20, - 21, - 22 + 21 ], - "starting_column": 5, - "ending_column": 6 + "starting_column": 13, + "ending_column": 10 }, - "contract": { - "type": "contract", - "name": "VectorSum", - "source_mapping": { - "start": 98, - "length": 1581, - "filename_used": "/home/travis/build/crytic/slither/tests/inline_assembly_library.sol", - "filename_relative": "tests/inline_assembly_library.sol", - "filename_absolute": "/home/travis/build/crytic/slither/tests/inline_assembly_library.sol", - "filename_short": "tests/inline_assembly_library.sol", - "lines": [ - 5, - 6, - 7, - 8, - 9, - 10, - 11, - 12, - 13, - 14, - 15, - 16, - 17, - 18, - 19, - 20, - 21, - 22, - 23, - 24, - 25, - 26, - 27, - 28, - 29, - 30, - 31, - 32, - 33, - 34, - 35, - 36, - 37, - 38, - 39, - 40, - 41, - 42, - 43, - 44, - 45, - 46, - 47, - 48 - ], - "starting_column": 1, - "ending_column": 2 + "type_specific_fields": { + "parent": { + "type": "function", + "name": "sumAsm", + "source_mapping": { + "start": 593, + "length": 247, + "filename_used": "/home/travis/build/crytic/slither/tests/inline_assembly_library.sol", + "filename_relative": "tests/inline_assembly_library.sol", + "filename_absolute": "/home/travis/build/crytic/slither/tests/inline_assembly_library.sol", + "filename_short": "tests/inline_assembly_library.sol", + "lines": [ + 16, + 17, + 18, + 19, + 20, + 21, + 22 + ], + "starting_column": 5, + "ending_column": 6 + }, + "type_specific_fields": { + "parent": { + "type": "contract", + "name": "VectorSum", + "source_mapping": { + "start": 98, + "length": 1581, + "filename_used": "/home/travis/build/crytic/slither/tests/inline_assembly_library.sol", + "filename_relative": "tests/inline_assembly_library.sol", + "filename_absolute": "/home/travis/build/crytic/slither/tests/inline_assembly_library.sol", + "filename_short": "tests/inline_assembly_library.sol", + "lines": [ + 5, + 6, + 7, + 8, + 9, + 10, + 11, + 12, + 13, + 14, + 15, + 16, + 17, + 18, + 19, + 20, + 21, + 22, + 23, + 24, + 25, + 26, + 27, + 28, + 29, + 30, + 31, + 32, + 33, + 34, + 35, + 36, + 37, + 38, + 39, + 40, + 41, + 42, + 43, + 44, + 45, + 46, + 47, + 48 + ], + "starting_column": 1, + "ending_column": 2 + } + }, + "signature": "sumAsm(uint256[])" + } } } } - } - ] - }, - { - "check": "assembly", - "impact": "Informational", - "confidence": "High", - "description": "VectorSum.sumPureAsm uses assembly (tests/inline_assembly_library.sol#25-47)\n\t- tests/inline_assembly_library.sol#26-47\n", - "elements": [ - { - "type": "function", - "name": "sumPureAsm", - "source_mapping": { - "start": 923, - "length": 754, - "filename_used": "/home/travis/build/crytic/slither/tests/inline_assembly_library.sol", - "filename_relative": "tests/inline_assembly_library.sol", - "filename_absolute": "/home/travis/build/crytic/slither/tests/inline_assembly_library.sol", - "filename_short": "tests/inline_assembly_library.sol", - "lines": [ - 25, - 26, - 27, - 28, - 29, - 30, - 31, - 32, - 33, - 34, - 35, - 36, - 37, - 38, - 39, - 40, - 41, - 42, - 43, - 44, - 45, - 46, - 47 - ], - "starting_column": 5, - "ending_column": 6 - }, - "contract": { - "type": "contract", - "name": "VectorSum", + ] + }, + { + "check": "assembly", + "impact": "Informational", + "confidence": "High", + "description": "VectorSum.sumPureAsm uses assembly (tests/inline_assembly_library.sol#25-47)\n\t- tests/inline_assembly_library.sol#26-47\n", + "elements": [ + { + "type": "function", + "name": "sumPureAsm", "source_mapping": { - "start": 98, - "length": 1581, + "start": 923, + "length": 754, "filename_used": "/home/travis/build/crytic/slither/tests/inline_assembly_library.sol", "filename_relative": "tests/inline_assembly_library.sol", "filename_absolute": "/home/travis/build/crytic/slither/tests/inline_assembly_library.sol", "filename_short": "tests/inline_assembly_library.sol", "lines": [ - 5, - 6, - 7, - 8, - 9, - 10, - 11, - 12, - 13, - 14, - 15, - 16, - 17, - 18, - 19, - 20, - 21, - 22, - 23, - 24, 25, 26, 27, @@ -293,63 +244,86 @@ 44, 45, 46, - 47, - 48 + 47 ], - "starting_column": 1, - "ending_column": 2 + "starting_column": 5, + "ending_column": 6 + }, + "type_specific_fields": { + "parent": { + "type": "contract", + "name": "VectorSum", + "source_mapping": { + "start": 98, + "length": 1581, + "filename_used": "/home/travis/build/crytic/slither/tests/inline_assembly_library.sol", + "filename_relative": "tests/inline_assembly_library.sol", + "filename_absolute": "/home/travis/build/crytic/slither/tests/inline_assembly_library.sol", + "filename_short": "tests/inline_assembly_library.sol", + "lines": [ + 5, + 6, + 7, + 8, + 9, + 10, + 11, + 12, + 13, + 14, + 15, + 16, + 17, + 18, + 19, + 20, + 21, + 22, + 23, + 24, + 25, + 26, + 27, + 28, + 29, + 30, + 31, + 32, + 33, + 34, + 35, + 36, + 37, + 38, + 39, + 40, + 41, + 42, + 43, + 44, + 45, + 46, + 47, + 48 + ], + "starting_column": 1, + "ending_column": 2 + } + }, + "signature": "sumPureAsm(uint256[])" } - } - }, - { - "type": "node", - "name": "", - "source_mapping": { - "start": 1000, - "length": 677, - "filename_used": "/home/travis/build/crytic/slither/tests/inline_assembly_library.sol", - "filename_relative": "tests/inline_assembly_library.sol", - "filename_absolute": "/home/travis/build/crytic/slither/tests/inline_assembly_library.sol", - "filename_short": "tests/inline_assembly_library.sol", - "lines": [ - 26, - 27, - 28, - 29, - 30, - 31, - 32, - 33, - 34, - 35, - 36, - 37, - 38, - 39, - 40, - 41, - 42, - 43, - 44, - 45, - 46, - 47 - ], - "starting_column": 9, - "ending_column": 6 }, - "function": { - "type": "function", - "name": "sumPureAsm", + { + "type": "node", + "name": "", "source_mapping": { - "start": 923, - "length": 754, + "start": 1000, + "length": 677, "filename_used": "/home/travis/build/crytic/slither/tests/inline_assembly_library.sol", "filename_relative": "tests/inline_assembly_library.sol", "filename_absolute": "/home/travis/build/crytic/slither/tests/inline_assembly_library.sol", "filename_short": "tests/inline_assembly_library.sol", "lines": [ - 25, 26, 27, 28, @@ -373,72 +347,116 @@ 46, 47 ], - "starting_column": 5, + "starting_column": 9, "ending_column": 6 }, - "contract": { - "type": "contract", - "name": "VectorSum", - "source_mapping": { - "start": 98, - "length": 1581, - "filename_used": "/home/travis/build/crytic/slither/tests/inline_assembly_library.sol", - "filename_relative": "tests/inline_assembly_library.sol", - "filename_absolute": "/home/travis/build/crytic/slither/tests/inline_assembly_library.sol", - "filename_short": "tests/inline_assembly_library.sol", - "lines": [ - 5, - 6, - 7, - 8, - 9, - 10, - 11, - 12, - 13, - 14, - 15, - 16, - 17, - 18, - 19, - 20, - 21, - 22, - 23, - 24, - 25, - 26, - 27, - 28, - 29, - 30, - 31, - 32, - 33, - 34, - 35, - 36, - 37, - 38, - 39, - 40, - 41, - 42, - 43, - 44, - 45, - 46, - 47, - 48 - ], - "starting_column": 1, - "ending_column": 2 + "type_specific_fields": { + "parent": { + "type": "function", + "name": "sumPureAsm", + "source_mapping": { + "start": 923, + "length": 754, + "filename_used": "/home/travis/build/crytic/slither/tests/inline_assembly_library.sol", + "filename_relative": "tests/inline_assembly_library.sol", + "filename_absolute": "/home/travis/build/crytic/slither/tests/inline_assembly_library.sol", + "filename_short": "tests/inline_assembly_library.sol", + "lines": [ + 25, + 26, + 27, + 28, + 29, + 30, + 31, + 32, + 33, + 34, + 35, + 36, + 37, + 38, + 39, + 40, + 41, + 42, + 43, + 44, + 45, + 46, + 47 + ], + "starting_column": 5, + "ending_column": 6 + }, + "type_specific_fields": { + "parent": { + "type": "contract", + "name": "VectorSum", + "source_mapping": { + "start": 98, + "length": 1581, + "filename_used": "/home/travis/build/crytic/slither/tests/inline_assembly_library.sol", + "filename_relative": "tests/inline_assembly_library.sol", + "filename_absolute": "/home/travis/build/crytic/slither/tests/inline_assembly_library.sol", + "filename_short": "tests/inline_assembly_library.sol", + "lines": [ + 5, + 6, + 7, + 8, + 9, + 10, + 11, + 12, + 13, + 14, + 15, + 16, + 17, + 18, + 19, + 20, + 21, + 22, + 23, + 24, + 25, + 26, + 27, + 28, + 29, + 30, + 31, + 32, + 33, + 34, + 35, + 36, + 37, + 38, + 39, + 40, + 41, + 42, + 43, + 44, + 45, + 46, + 47, + 48 + ], + "starting_column": 1, + "ending_column": 2 + } + }, + "signature": "sumPureAsm(uint256[])" + } } } } - } - ] - } - ] + ] + } + ] + } } \ No newline at end of file diff --git a/tests/expected_json/locked_ether-0.5.1.locked-ether.json b/tests/expected_json/locked_ether-0.5.1.locked-ether.json index ba3815c28..7d05ff3f8 100644 --- a/tests/expected_json/locked_ether-0.5.1.locked-ether.json +++ b/tests/expected_json/locked_ether-0.5.1.locked-ether.json @@ -1,73 +1,78 @@ { "success": true, "error": null, - "results": [ - { - "check": "locked-ether", - "impact": "Medium", - "confidence": "High", - "description": "Contract locking ether found in :\n\tContract OnlyLocked has payable functions:\n\t - receive (tests/locked_ether-0.5.1.sol#4-6)\n\tBut does not have a function to withdraw the ether\n", - "elements": [ - { - "type": "contract", - "name": "OnlyLocked", - "source_mapping": { - "start": 375, - "length": 32, - "filename_used": "/home/travis/build/crytic/slither/tests/locked_ether-0.5.1.sol", - "filename_relative": "tests/locked_ether-0.5.1.sol", - "filename_absolute": "/home/travis/build/crytic/slither/tests/locked_ether-0.5.1.sol", - "filename_short": "tests/locked_ether-0.5.1.sol", - "lines": [ - 26 - ], - "starting_column": 1, - "ending_column": 33 - } - }, - { - "type": "function", - "name": "receive", - "source_mapping": { - "start": 46, - "length": 72, - "filename_used": "/home/travis/build/crytic/slither/tests/locked_ether-0.5.1.sol", - "filename_relative": "tests/locked_ether-0.5.1.sol", - "filename_absolute": "/home/travis/build/crytic/slither/tests/locked_ether-0.5.1.sol", - "filename_short": "tests/locked_ether-0.5.1.sol", - "lines": [ - 4, - 5, - 6 - ], - "starting_column": 5, - "ending_column": 6 - }, - "contract": { + "results": { + "detectors": [ + { + "check": "locked-ether", + "impact": "Medium", + "confidence": "High", + "description": "Contract locking ether found in :\n\tContract OnlyLocked has payable functions:\n\t - receive (tests/locked_ether-0.5.1.sol#4-6)\n\tBut does not have a function to withdraw the ether\n", + "elements": [ + { "type": "contract", - "name": "Locked", + "name": "OnlyLocked", "source_mapping": { - "start": 24, - "length": 97, + "start": 375, + "length": 32, + "filename_used": "/home/travis/build/crytic/slither/tests/locked_ether-0.5.1.sol", + "filename_relative": "tests/locked_ether-0.5.1.sol", + "filename_absolute": "/home/travis/build/crytic/slither/tests/locked_ether-0.5.1.sol", + "filename_short": "tests/locked_ether-0.5.1.sol", + "lines": [ + 26 + ], + "starting_column": 1, + "ending_column": 33 + } + }, + { + "type": "function", + "name": "receive", + "source_mapping": { + "start": 46, + "length": 72, "filename_used": "/home/travis/build/crytic/slither/tests/locked_ether-0.5.1.sol", "filename_relative": "tests/locked_ether-0.5.1.sol", "filename_absolute": "/home/travis/build/crytic/slither/tests/locked_ether-0.5.1.sol", "filename_short": "tests/locked_ether-0.5.1.sol", "lines": [ - 2, - 3, 4, 5, - 6, - 7, - 8 + 6 ], - "starting_column": 1, - "ending_column": 2 + "starting_column": 5, + "ending_column": 6 + }, + "type_specific_fields": { + "parent": { + "type": "contract", + "name": "Locked", + "source_mapping": { + "start": 24, + "length": 97, + "filename_used": "/home/travis/build/crytic/slither/tests/locked_ether-0.5.1.sol", + "filename_relative": "tests/locked_ether-0.5.1.sol", + "filename_absolute": "/home/travis/build/crytic/slither/tests/locked_ether-0.5.1.sol", + "filename_short": "tests/locked_ether-0.5.1.sol", + "lines": [ + 2, + 3, + 4, + 5, + 6, + 7, + 8 + ], + "starting_column": 1, + "ending_column": 2 + } + }, + "signature": "receive()" } } - } - ] - } - ] + ] + } + ] + } } \ No newline at end of file diff --git a/tests/expected_json/locked_ether.locked-ether.json b/tests/expected_json/locked_ether.locked-ether.json index 92f5794e7..3412efa8e 100644 --- a/tests/expected_json/locked_ether.locked-ether.json +++ b/tests/expected_json/locked_ether.locked-ether.json @@ -1,73 +1,78 @@ { "success": true, "error": null, - "results": [ - { - "check": "locked-ether", - "impact": "Medium", - "confidence": "High", - "description": "Contract locking ether found in :\n\tContract OnlyLocked has payable functions:\n\t - receive (tests/locked_ether.sol#4-6)\n\tBut does not have a function to withdraw the ether\n", - "elements": [ - { - "type": "contract", - "name": "OnlyLocked", - "source_mapping": { - "start": 368, - "length": 32, - "filename_used": "/home/travis/build/crytic/slither/tests/locked_ether.sol", - "filename_relative": "tests/locked_ether.sol", - "filename_absolute": "/home/travis/build/crytic/slither/tests/locked_ether.sol", - "filename_short": "tests/locked_ether.sol", - "lines": [ - 26 - ], - "starting_column": 1, - "ending_column": 33 - } - }, - { - "type": "function", - "name": "receive", - "source_mapping": { - "start": 47, - "length": 72, - "filename_used": "/home/travis/build/crytic/slither/tests/locked_ether.sol", - "filename_relative": "tests/locked_ether.sol", - "filename_absolute": "/home/travis/build/crytic/slither/tests/locked_ether.sol", - "filename_short": "tests/locked_ether.sol", - "lines": [ - 4, - 5, - 6 - ], - "starting_column": 5, - "ending_column": 6 - }, - "contract": { + "results": { + "detectors": [ + { + "check": "locked-ether", + "impact": "Medium", + "confidence": "High", + "description": "Contract locking ether found in :\n\tContract OnlyLocked has payable functions:\n\t - receive (tests/locked_ether.sol#4-6)\n\tBut does not have a function to withdraw the ether\n", + "elements": [ + { "type": "contract", - "name": "Locked", + "name": "OnlyLocked", "source_mapping": { - "start": 25, - "length": 97, + "start": 368, + "length": 32, + "filename_used": "/home/travis/build/crytic/slither/tests/locked_ether.sol", + "filename_relative": "tests/locked_ether.sol", + "filename_absolute": "/home/travis/build/crytic/slither/tests/locked_ether.sol", + "filename_short": "tests/locked_ether.sol", + "lines": [ + 26 + ], + "starting_column": 1, + "ending_column": 33 + } + }, + { + "type": "function", + "name": "receive", + "source_mapping": { + "start": 47, + "length": 72, "filename_used": "/home/travis/build/crytic/slither/tests/locked_ether.sol", "filename_relative": "tests/locked_ether.sol", "filename_absolute": "/home/travis/build/crytic/slither/tests/locked_ether.sol", "filename_short": "tests/locked_ether.sol", "lines": [ - 2, - 3, 4, 5, - 6, - 7, - 8 + 6 ], - "starting_column": 1, - "ending_column": 2 + "starting_column": 5, + "ending_column": 6 + }, + "type_specific_fields": { + "parent": { + "type": "contract", + "name": "Locked", + "source_mapping": { + "start": 25, + "length": 97, + "filename_used": "/home/travis/build/crytic/slither/tests/locked_ether.sol", + "filename_relative": "tests/locked_ether.sol", + "filename_absolute": "/home/travis/build/crytic/slither/tests/locked_ether.sol", + "filename_short": "tests/locked_ether.sol", + "lines": [ + 2, + 3, + 4, + 5, + 6, + 7, + 8 + ], + "starting_column": 1, + "ending_column": 2 + } + }, + "signature": "receive()" } } - } - ] - } - ] + ] + } + ] + } } \ No newline at end of file diff --git a/tests/expected_json/low_level_calls.low-level-calls.json b/tests/expected_json/low_level_calls.low-level-calls.json index 15bd22263..1676df916 100644 --- a/tests/expected_json/low_level_calls.low-level-calls.json +++ b/tests/expected_json/low_level_calls.low-level-calls.json @@ -1,111 +1,121 @@ { "success": true, "error": null, - "results": [ - { - "check": "low-level-calls", - "impact": "Informational", - "confidence": "High", - "description": "Low level call in Sender.send (tests/low_level_calls.sol#5-7):\n\t-_receiver.call.value(msg.value).gas(7777)() tests/low_level_calls.sol#6\n", - "elements": [ - { - "type": "function", - "name": "send", - "source_mapping": { - "start": 51, - "length": 112, - "filename_used": "/home/travis/build/crytic/slither/tests/low_level_calls.sol", - "filename_relative": "tests/low_level_calls.sol", - "filename_absolute": "/home/travis/build/crytic/slither/tests/low_level_calls.sol", - "filename_short": "tests/low_level_calls.sol", - "lines": [ - 5, - 6, - 7 - ], - "starting_column": 5, - "ending_column": 6 - }, - "contract": { - "type": "contract", - "name": "Sender", + "results": { + "detectors": [ + { + "check": "low-level-calls", + "impact": "Informational", + "confidence": "High", + "description": "Low level call in Sender.send (tests/low_level_calls.sol#5-7):\n\t-_receiver.call.value(msg.value).gas(7777)() tests/low_level_calls.sol#6\n", + "elements": [ + { + "type": "function", + "name": "send", "source_mapping": { - "start": 29, - "length": 136, + "start": 51, + "length": 112, "filename_used": "/home/travis/build/crytic/slither/tests/low_level_calls.sol", "filename_relative": "tests/low_level_calls.sol", "filename_absolute": "/home/travis/build/crytic/slither/tests/low_level_calls.sol", "filename_short": "tests/low_level_calls.sol", "lines": [ - 4, 5, 6, - 7, - 8 + 7 ], - "starting_column": 1, - "ending_column": 2 + "starting_column": 5, + "ending_column": 6 + }, + "type_specific_fields": { + "parent": { + "type": "contract", + "name": "Sender", + "source_mapping": { + "start": 29, + "length": 136, + "filename_used": "/home/travis/build/crytic/slither/tests/low_level_calls.sol", + "filename_relative": "tests/low_level_calls.sol", + "filename_absolute": "/home/travis/build/crytic/slither/tests/low_level_calls.sol", + "filename_short": "tests/low_level_calls.sol", + "lines": [ + 4, + 5, + 6, + 7, + 8 + ], + "starting_column": 1, + "ending_column": 2 + } + }, + "signature": "send(address)" } - } - }, - { - "type": "node", - "name": "_receiver.call.value(msg.value).gas(7777)()", - "source_mapping": { - "start": 111, - "length": 45, - "filename_used": "/home/travis/build/crytic/slither/tests/low_level_calls.sol", - "filename_relative": "tests/low_level_calls.sol", - "filename_absolute": "/home/travis/build/crytic/slither/tests/low_level_calls.sol", - "filename_short": "tests/low_level_calls.sol", - "lines": [ - 6 - ], - "starting_column": 9, - "ending_column": 54 }, - "function": { - "type": "function", - "name": "send", + { + "type": "node", + "name": "_receiver.call.value(msg.value).gas(7777)()", "source_mapping": { - "start": 51, - "length": 112, + "start": 111, + "length": 45, "filename_used": "/home/travis/build/crytic/slither/tests/low_level_calls.sol", "filename_relative": "tests/low_level_calls.sol", "filename_absolute": "/home/travis/build/crytic/slither/tests/low_level_calls.sol", "filename_short": "tests/low_level_calls.sol", "lines": [ - 5, - 6, - 7 + 6 ], - "starting_column": 5, - "ending_column": 6 + "starting_column": 9, + "ending_column": 54 }, - "contract": { - "type": "contract", - "name": "Sender", - "source_mapping": { - "start": 29, - "length": 136, - "filename_used": "/home/travis/build/crytic/slither/tests/low_level_calls.sol", - "filename_relative": "tests/low_level_calls.sol", - "filename_absolute": "/home/travis/build/crytic/slither/tests/low_level_calls.sol", - "filename_short": "tests/low_level_calls.sol", - "lines": [ - 4, - 5, - 6, - 7, - 8 - ], - "starting_column": 1, - "ending_column": 2 + "type_specific_fields": { + "parent": { + "type": "function", + "name": "send", + "source_mapping": { + "start": 51, + "length": 112, + "filename_used": "/home/travis/build/crytic/slither/tests/low_level_calls.sol", + "filename_relative": "tests/low_level_calls.sol", + "filename_absolute": "/home/travis/build/crytic/slither/tests/low_level_calls.sol", + "filename_short": "tests/low_level_calls.sol", + "lines": [ + 5, + 6, + 7 + ], + "starting_column": 5, + "ending_column": 6 + }, + "type_specific_fields": { + "parent": { + "type": "contract", + "name": "Sender", + "source_mapping": { + "start": 29, + "length": 136, + "filename_used": "/home/travis/build/crytic/slither/tests/low_level_calls.sol", + "filename_relative": "tests/low_level_calls.sol", + "filename_absolute": "/home/travis/build/crytic/slither/tests/low_level_calls.sol", + "filename_short": "tests/low_level_calls.sol", + "lines": [ + 4, + 5, + 6, + 7, + 8 + ], + "starting_column": 1, + "ending_column": 2 + } + }, + "signature": "send(address)" + } } } } - } - ] - } - ] + ] + } + ] + } } \ No newline at end of file diff --git a/tests/expected_json/multiple_calls_in_loop.calls-loop.json b/tests/expected_json/multiple_calls_in_loop.calls-loop.json index 2fa37ce72..26875d7a5 100644 --- a/tests/expected_json/multiple_calls_in_loop.calls-loop.json +++ b/tests/expected_json/multiple_calls_in_loop.calls-loop.json @@ -1,83 +1,90 @@ { "success": true, "error": null, - "results": [ - { - "check": "calls-loop", - "impact": "Low", - "confidence": "Medium", - "description": "CallInLoop.bad has external calls inside a loop: \"destinations[i].transfer(i)\" (tests/multiple_calls_in_loop.sol#11)\n", - "elements": [ - { - "type": "node", - "name": "destinations[i].transfer(i)", - "source_mapping": { - "start": 244, - "length": 27, - "filename_used": "/home/travis/build/crytic/slither/tests/multiple_calls_in_loop.sol", - "filename_relative": "tests/multiple_calls_in_loop.sol", - "filename_absolute": "/home/travis/build/crytic/slither/tests/multiple_calls_in_loop.sol", - "filename_short": "tests/multiple_calls_in_loop.sol", - "lines": [ - 11 - ], - "starting_column": 13, - "ending_column": 40 - }, - "function": { - "type": "function", - "name": "bad", + "results": { + "detectors": [ + { + "check": "calls-loop", + "impact": "Low", + "confidence": "Medium", + "description": "CallInLoop.bad has external calls inside a loop: \"destinations[i].transfer(i)\" (tests/multiple_calls_in_loop.sol#11)\n", + "elements": [ + { + "type": "node", + "name": "destinations[i].transfer(i)", "source_mapping": { - "start": 153, - "length": 135, + "start": 244, + "length": 27, "filename_used": "/home/travis/build/crytic/slither/tests/multiple_calls_in_loop.sol", "filename_relative": "tests/multiple_calls_in_loop.sol", "filename_absolute": "/home/travis/build/crytic/slither/tests/multiple_calls_in_loop.sol", "filename_short": "tests/multiple_calls_in_loop.sol", "lines": [ - 9, - 10, - 11, - 12, - 13 + 11 ], - "starting_column": 5, - "ending_column": 6 + "starting_column": 13, + "ending_column": 40 }, - "contract": { - "type": "contract", - "name": "CallInLoop", - "source_mapping": { - "start": 0, - "length": 291, - "filename_used": "/home/travis/build/crytic/slither/tests/multiple_calls_in_loop.sol", - "filename_relative": "tests/multiple_calls_in_loop.sol", - "filename_absolute": "/home/travis/build/crytic/slither/tests/multiple_calls_in_loop.sol", - "filename_short": "tests/multiple_calls_in_loop.sol", - "lines": [ - 1, - 2, - 3, - 4, - 5, - 6, - 7, - 8, - 9, - 10, - 11, - 12, - 13, - 14, - 15 - ], - "starting_column": 1, - "ending_column": 2 + "type_specific_fields": { + "parent": { + "type": "function", + "name": "bad", + "source_mapping": { + "start": 153, + "length": 135, + "filename_used": "/home/travis/build/crytic/slither/tests/multiple_calls_in_loop.sol", + "filename_relative": "tests/multiple_calls_in_loop.sol", + "filename_absolute": "/home/travis/build/crytic/slither/tests/multiple_calls_in_loop.sol", + "filename_short": "tests/multiple_calls_in_loop.sol", + "lines": [ + 9, + 10, + 11, + 12, + 13 + ], + "starting_column": 5, + "ending_column": 6 + }, + "type_specific_fields": { + "parent": { + "type": "contract", + "name": "CallInLoop", + "source_mapping": { + "start": 0, + "length": 291, + "filename_used": "/home/travis/build/crytic/slither/tests/multiple_calls_in_loop.sol", + "filename_relative": "tests/multiple_calls_in_loop.sol", + "filename_absolute": "/home/travis/build/crytic/slither/tests/multiple_calls_in_loop.sol", + "filename_short": "tests/multiple_calls_in_loop.sol", + "lines": [ + 1, + 2, + 3, + 4, + 5, + 6, + 7, + 8, + 9, + 10, + 11, + 12, + 13, + 14, + 15 + ], + "starting_column": 1, + "ending_column": 2 + } + }, + "signature": "bad()" + } } } } - } - ] - } - ] + ] + } + ] + } } \ No newline at end of file diff --git a/tests/expected_json/naming_convention.naming-convention.json b/tests/expected_json/naming_convention.naming-convention.json index 83c41db6f..18fdb44d4 100644 --- a/tests/expected_json/naming_convention.naming-convention.json +++ b/tests/expected_json/naming_convention.naming-convention.json @@ -1,110 +1,15 @@ { "success": true, "error": null, - "results": [ - { - "check": "naming-convention", - "impact": "Informational", - "confidence": "High", - "description": "Contract 'naming' (tests/naming_convention.sol#3-48) is not in CapWords\n", - "elements": [ - { - "type": "contract", - "name": "naming", - "source_mapping": { - "start": 28, - "length": 642, - "filename_used": "/home/travis/build/crytic/slither/tests/naming_convention.sol", - "filename_relative": "tests/naming_convention.sol", - "filename_absolute": "/home/travis/build/crytic/slither/tests/naming_convention.sol", - "filename_short": "tests/naming_convention.sol", - "lines": [ - 3, - 4, - 5, - 6, - 7, - 8, - 9, - 10, - 11, - 12, - 13, - 14, - 15, - 16, - 17, - 18, - 19, - 20, - 21, - 22, - 23, - 24, - 25, - 26, - 27, - 28, - 29, - 30, - 31, - 32, - 33, - 34, - 35, - 36, - 37, - 38, - 39, - 40, - 41, - 42, - 43, - 44, - 45, - 46, - 47, - 48 - ], - "starting_column": 1, - "ending_column": 2 - }, - "additional_fields": { - "target": "contract", - "convention": "CapWords" - } - } - ] - }, - { - "check": "naming-convention", - "impact": "Informational", - "confidence": "High", - "description": "Struct 'naming.test' (tests/naming_convention.sol#14-16) is not in CapWords\n", - "elements": [ - { - "type": "struct", - "name": "test", - "source_mapping": { - "start": 229, - "length": 35, - "filename_used": "/home/travis/build/crytic/slither/tests/naming_convention.sol", - "filename_relative": "tests/naming_convention.sol", - "filename_absolute": "/home/travis/build/crytic/slither/tests/naming_convention.sol", - "filename_short": "tests/naming_convention.sol", - "lines": [ - 14, - 15, - 16 - ], - "starting_column": 5, - "ending_column": 6 - }, - "additional_fields": { - "target": "structure", - "convention": "CapWords" - }, - "contract": { + "results": { + "detectors": [ + { + "check": "naming-convention", + "impact": "Informational", + "confidence": "High", + "description": "Contract 'naming' (tests/naming_convention.sol#3-48) is not in CapWords\n", + "elements": [ + { "type": "contract", "name": "naming", "source_mapping": { @@ -164,870 +69,998 @@ ], "starting_column": 1, "ending_column": 2 + }, + "additional_fields": { + "target": "contract", + "convention": "CapWords" } } - } - ] - }, - { - "check": "naming-convention", - "impact": "Informational", - "confidence": "High", - "description": "Event 'naming.event_' (tests/naming_convention.sol#23) is not in CapWords\n", - "elements": [ - { - "type": "event", - "name": "event_", - "source_mapping": { - "start": 335, - "length": 19, - "filename_used": "/home/travis/build/crytic/slither/tests/naming_convention.sol", - "filename_relative": "tests/naming_convention.sol", - "filename_absolute": "/home/travis/build/crytic/slither/tests/naming_convention.sol", - "filename_short": "tests/naming_convention.sol", - "lines": [ - 23 - ], - "starting_column": 5, - "ending_column": 24 - }, - "additional_fields": { - "target": "event", - "convention": "CapWords" - }, - "contract": { - "type": "contract", - "name": "naming", + ] + }, + { + "check": "naming-convention", + "impact": "Informational", + "confidence": "High", + "description": "Struct 'naming.test' (tests/naming_convention.sol#14-16) is not in CapWords\n", + "elements": [ + { + "type": "struct", + "name": "test", "source_mapping": { - "start": 28, - "length": 642, + "start": 229, + "length": 35, "filename_used": "/home/travis/build/crytic/slither/tests/naming_convention.sol", "filename_relative": "tests/naming_convention.sol", "filename_absolute": "/home/travis/build/crytic/slither/tests/naming_convention.sol", "filename_short": "tests/naming_convention.sol", "lines": [ - 3, - 4, - 5, - 6, - 7, - 8, - 9, - 10, - 11, - 12, - 13, 14, 15, - 16, - 17, - 18, - 19, - 20, - 21, - 22, - 23, - 24, - 25, - 26, - 27, - 28, - 29, - 30, - 31, - 32, - 33, - 34, - 35, - 36, - 37, - 38, - 39, - 40, - 41, - 42, - 43, - 44, - 45, - 46, - 47, - 48 + 16 ], - "starting_column": 1, - "ending_column": 2 + "starting_column": 5, + "ending_column": 6 + }, + "type_specific_fields": { + "parent": { + "type": "contract", + "name": "naming", + "source_mapping": { + "start": 28, + "length": 642, + "filename_used": "/home/travis/build/crytic/slither/tests/naming_convention.sol", + "filename_relative": "tests/naming_convention.sol", + "filename_absolute": "/home/travis/build/crytic/slither/tests/naming_convention.sol", + "filename_short": "tests/naming_convention.sol", + "lines": [ + 3, + 4, + 5, + 6, + 7, + 8, + 9, + 10, + 11, + 12, + 13, + 14, + 15, + 16, + 17, + 18, + 19, + 20, + 21, + 22, + 23, + 24, + 25, + 26, + 27, + 28, + 29, + 30, + 31, + 32, + 33, + 34, + 35, + 36, + 37, + 38, + 39, + 40, + 41, + 42, + 43, + 44, + 45, + 46, + 47, + 48 + ], + "starting_column": 1, + "ending_column": 2 + } + } + }, + "additional_fields": { + "target": "structure", + "convention": "CapWords" } } - } - ] - }, - { - "check": "naming-convention", - "impact": "Informational", - "confidence": "High", - "description": "Function 'naming.GetOne' (tests/naming_convention.sol#30-33) is not in mixedCase\n", - "elements": [ - { - "type": "function", - "name": "GetOne", - "source_mapping": { - "start": 440, - "length": 75, - "filename_used": "/home/travis/build/crytic/slither/tests/naming_convention.sol", - "filename_relative": "tests/naming_convention.sol", - "filename_absolute": "/home/travis/build/crytic/slither/tests/naming_convention.sol", - "filename_short": "tests/naming_convention.sol", - "lines": [ - 30, - 31, - 32, - 33 - ], - "starting_column": 5, - "ending_column": 6 - }, - "additional_fields": { - "target": "function", - "convention": "mixedCase" - }, - "contract": { - "type": "contract", - "name": "naming", + ] + }, + { + "check": "naming-convention", + "impact": "Informational", + "confidence": "High", + "description": "Event 'naming.event_' (tests/naming_convention.sol#23) is not in CapWords\n", + "elements": [ + { + "type": "event", + "name": "event_", "source_mapping": { - "start": 28, - "length": 642, + "start": 335, + "length": 19, "filename_used": "/home/travis/build/crytic/slither/tests/naming_convention.sol", "filename_relative": "tests/naming_convention.sol", "filename_absolute": "/home/travis/build/crytic/slither/tests/naming_convention.sol", "filename_short": "tests/naming_convention.sol", "lines": [ - 3, - 4, - 5, - 6, - 7, - 8, - 9, - 10, - 11, - 12, - 13, - 14, - 15, - 16, - 17, - 18, - 19, - 20, - 21, - 22, - 23, - 24, - 25, - 26, - 27, - 28, - 29, - 30, - 31, - 32, - 33, - 34, - 35, - 36, - 37, - 38, - 39, - 40, - 41, - 42, - 43, - 44, - 45, - 46, - 47, - 48 + 23 ], - "starting_column": 1, - "ending_column": 2 + "starting_column": 5, + "ending_column": 24 + }, + "type_specific_fields": { + "parent": { + "type": "contract", + "name": "naming", + "source_mapping": { + "start": 28, + "length": 642, + "filename_used": "/home/travis/build/crytic/slither/tests/naming_convention.sol", + "filename_relative": "tests/naming_convention.sol", + "filename_absolute": "/home/travis/build/crytic/slither/tests/naming_convention.sol", + "filename_short": "tests/naming_convention.sol", + "lines": [ + 3, + 4, + 5, + 6, + 7, + 8, + 9, + 10, + 11, + 12, + 13, + 14, + 15, + 16, + 17, + 18, + 19, + 20, + 21, + 22, + 23, + 24, + 25, + 26, + 27, + 28, + 29, + 30, + 31, + 32, + 33, + 34, + 35, + 36, + 37, + 38, + 39, + 40, + 41, + 42, + 43, + 44, + 45, + 46, + 47, + 48 + ], + "starting_column": 1, + "ending_column": 2 + } + }, + "signature": "event_(uint256)" + }, + "additional_fields": { + "target": "event", + "convention": "CapWords" } } - } - ] - }, - { - "check": "naming-convention", - "impact": "Informational", - "confidence": "High", - "description": "Parameter 'Number2' of naming.setInt (tests/naming_convention.sol#35) is not in mixedCase\n", - "elements": [ - { - "type": "variable", - "name": "Number2", - "source_mapping": { - "start": 551, - "length": 12, - "filename_used": "/home/travis/build/crytic/slither/tests/naming_convention.sol", - "filename_relative": "tests/naming_convention.sol", - "filename_absolute": "/home/travis/build/crytic/slither/tests/naming_convention.sol", - "filename_short": "tests/naming_convention.sol", - "lines": [ - 35 - ], - "starting_column": 35, - "ending_column": 47 - }, - "additional_fields": { - "target": "parameter", - "convention": "mixedCase" - }, - "function": { + ] + }, + { + "check": "naming-convention", + "impact": "Informational", + "confidence": "High", + "description": "Function 'naming.GetOne' (tests/naming_convention.sol#30-33) is not in mixedCase\n", + "elements": [ + { "type": "function", - "name": "setInt", + "name": "GetOne", "source_mapping": { - "start": 521, - "length": 63, + "start": 440, + "length": 75, "filename_used": "/home/travis/build/crytic/slither/tests/naming_convention.sol", "filename_relative": "tests/naming_convention.sol", "filename_absolute": "/home/travis/build/crytic/slither/tests/naming_convention.sol", "filename_short": "tests/naming_convention.sol", "lines": [ - 35, - 36, - 37, - 38 + 30, + 31, + 32, + 33 ], "starting_column": 5, "ending_column": 6 }, - "contract": { - "type": "contract", - "name": "naming", - "source_mapping": { - "start": 28, - "length": 642, - "filename_used": "/home/travis/build/crytic/slither/tests/naming_convention.sol", - "filename_relative": "tests/naming_convention.sol", - "filename_absolute": "/home/travis/build/crytic/slither/tests/naming_convention.sol", - "filename_short": "tests/naming_convention.sol", - "lines": [ - 3, - 4, - 5, - 6, - 7, - 8, - 9, - 10, - 11, - 12, - 13, - 14, - 15, - 16, - 17, - 18, - 19, - 20, - 21, - 22, - 23, - 24, - 25, - 26, - 27, - 28, - 29, - 30, - 31, - 32, - 33, - 34, - 35, - 36, - 37, - 38, - 39, - 40, - 41, - 42, - 43, - 44, - 45, - 46, - 47, - 48 - ], - "starting_column": 1, - "ending_column": 2 + "type_specific_fields": { + "parent": { + "type": "contract", + "name": "naming", + "source_mapping": { + "start": 28, + "length": 642, + "filename_used": "/home/travis/build/crytic/slither/tests/naming_convention.sol", + "filename_relative": "tests/naming_convention.sol", + "filename_absolute": "/home/travis/build/crytic/slither/tests/naming_convention.sol", + "filename_short": "tests/naming_convention.sol", + "lines": [ + 3, + 4, + 5, + 6, + 7, + 8, + 9, + 10, + 11, + 12, + 13, + 14, + 15, + 16, + 17, + 18, + 19, + 20, + 21, + 22, + 23, + 24, + 25, + 26, + 27, + 28, + 29, + 30, + 31, + 32, + 33, + 34, + 35, + 36, + 37, + 38, + 39, + 40, + 41, + 42, + 43, + 44, + 45, + 46, + 47, + 48 + ], + "starting_column": 1, + "ending_column": 2 + } + }, + "signature": "GetOne()" + }, + "additional_fields": { + "target": "function", + "convention": "mixedCase" + } + } + ] + }, + { + "check": "naming-convention", + "impact": "Informational", + "confidence": "High", + "description": "Parameter 'Number2' of naming.setInt (tests/naming_convention.sol#35) is not in mixedCase\n", + "elements": [ + { + "type": "variable", + "name": "Number2", + "source_mapping": { + "start": 551, + "length": 12, + "filename_used": "/home/travis/build/crytic/slither/tests/naming_convention.sol", + "filename_relative": "tests/naming_convention.sol", + "filename_absolute": "/home/travis/build/crytic/slither/tests/naming_convention.sol", + "filename_short": "tests/naming_convention.sol", + "lines": [ + 35 + ], + "starting_column": 35, + "ending_column": 47 + }, + "type_specific_fields": { + "parent": { + "type": "function", + "name": "setInt", + "source_mapping": { + "start": 521, + "length": 63, + "filename_used": "/home/travis/build/crytic/slither/tests/naming_convention.sol", + "filename_relative": "tests/naming_convention.sol", + "filename_absolute": "/home/travis/build/crytic/slither/tests/naming_convention.sol", + "filename_short": "tests/naming_convention.sol", + "lines": [ + 35, + 36, + 37, + 38 + ], + "starting_column": 5, + "ending_column": 6 + }, + "type_specific_fields": { + "parent": { + "type": "contract", + "name": "naming", + "source_mapping": { + "start": 28, + "length": 642, + "filename_used": "/home/travis/build/crytic/slither/tests/naming_convention.sol", + "filename_relative": "tests/naming_convention.sol", + "filename_absolute": "/home/travis/build/crytic/slither/tests/naming_convention.sol", + "filename_short": "tests/naming_convention.sol", + "lines": [ + 3, + 4, + 5, + 6, + 7, + 8, + 9, + 10, + 11, + 12, + 13, + 14, + 15, + 16, + 17, + 18, + 19, + 20, + 21, + 22, + 23, + 24, + 25, + 26, + 27, + 28, + 29, + 30, + 31, + 32, + 33, + 34, + 35, + 36, + 37, + 38, + 39, + 40, + 41, + 42, + 43, + 44, + 45, + 46, + 47, + 48 + ], + "starting_column": 1, + "ending_column": 2 + } + }, + "signature": "setInt(uint256,uint256)" + } } + }, + "additional_fields": { + "target": "parameter", + "convention": "mixedCase" } } - } - ] - }, - { - "check": "naming-convention", - "impact": "Informational", - "confidence": "High", - "description": "Constant 'naming.MY_other_CONSTANT' (tests/naming_convention.sol#9) is not in UPPER_CASE_WITH_UNDERSCORES\n", - "elements": [ - { - "type": "variable", - "name": "MY_other_CONSTANT", - "source_mapping": { - "start": 143, - "length": 35, - "filename_used": "/home/travis/build/crytic/slither/tests/naming_convention.sol", - "filename_relative": "tests/naming_convention.sol", - "filename_absolute": "/home/travis/build/crytic/slither/tests/naming_convention.sol", - "filename_short": "tests/naming_convention.sol", - "lines": [ - 9 - ], - "starting_column": 5, - "ending_column": 40 - }, - "additional_fields": { - "target": "variable_constant", - "convention": "UPPER_CASE_WITH_UNDERSCORES" - }, - "contract": { - "type": "contract", - "name": "naming", + ] + }, + { + "check": "naming-convention", + "impact": "Informational", + "confidence": "High", + "description": "Constant 'naming.MY_other_CONSTANT' (tests/naming_convention.sol#9) is not in UPPER_CASE_WITH_UNDERSCORES\n", + "elements": [ + { + "type": "variable", + "name": "MY_other_CONSTANT", "source_mapping": { - "start": 28, - "length": 642, + "start": 143, + "length": 35, "filename_used": "/home/travis/build/crytic/slither/tests/naming_convention.sol", "filename_relative": "tests/naming_convention.sol", "filename_absolute": "/home/travis/build/crytic/slither/tests/naming_convention.sol", "filename_short": "tests/naming_convention.sol", "lines": [ - 3, - 4, - 5, - 6, - 7, - 8, - 9, - 10, - 11, - 12, - 13, - 14, - 15, - 16, - 17, - 18, - 19, - 20, - 21, - 22, - 23, - 24, - 25, - 26, - 27, - 28, - 29, - 30, - 31, - 32, - 33, - 34, - 35, - 36, - 37, - 38, - 39, - 40, - 41, - 42, - 43, - 44, - 45, - 46, - 47, - 48 + 9 ], - "starting_column": 1, - "ending_column": 2 + "starting_column": 5, + "ending_column": 40 + }, + "type_specific_fields": { + "parent": { + "type": "contract", + "name": "naming", + "source_mapping": { + "start": 28, + "length": 642, + "filename_used": "/home/travis/build/crytic/slither/tests/naming_convention.sol", + "filename_relative": "tests/naming_convention.sol", + "filename_absolute": "/home/travis/build/crytic/slither/tests/naming_convention.sol", + "filename_short": "tests/naming_convention.sol", + "lines": [ + 3, + 4, + 5, + 6, + 7, + 8, + 9, + 10, + 11, + 12, + 13, + 14, + 15, + 16, + 17, + 18, + 19, + 20, + 21, + 22, + 23, + 24, + 25, + 26, + 27, + 28, + 29, + 30, + 31, + 32, + 33, + 34, + 35, + 36, + 37, + 38, + 39, + 40, + 41, + 42, + 43, + 44, + 45, + 46, + 47, + 48 + ], + "starting_column": 1, + "ending_column": 2 + } + } + }, + "additional_fields": { + "target": "variable_constant", + "convention": "UPPER_CASE_WITH_UNDERSCORES" } } - } - ] - }, - { - "check": "naming-convention", - "impact": "Informational", - "confidence": "High", - "description": "Variable 'naming.Var_One' (tests/naming_convention.sol#11) is not in mixedCase\n", - "elements": [ - { - "type": "variable", - "name": "Var_One", - "source_mapping": { - "start": 185, - "length": 16, - "filename_used": "/home/travis/build/crytic/slither/tests/naming_convention.sol", - "filename_relative": "tests/naming_convention.sol", - "filename_absolute": "/home/travis/build/crytic/slither/tests/naming_convention.sol", - "filename_short": "tests/naming_convention.sol", - "lines": [ - 11 - ], - "starting_column": 5, - "ending_column": 21 - }, - "additional_fields": { - "target": "variable", - "convention": "mixedCase" - }, - "contract": { - "type": "contract", - "name": "naming", + ] + }, + { + "check": "naming-convention", + "impact": "Informational", + "confidence": "High", + "description": "Variable 'naming.Var_One' (tests/naming_convention.sol#11) is not in mixedCase\n", + "elements": [ + { + "type": "variable", + "name": "Var_One", "source_mapping": { - "start": 28, - "length": 642, + "start": 185, + "length": 16, "filename_used": "/home/travis/build/crytic/slither/tests/naming_convention.sol", "filename_relative": "tests/naming_convention.sol", "filename_absolute": "/home/travis/build/crytic/slither/tests/naming_convention.sol", "filename_short": "tests/naming_convention.sol", "lines": [ - 3, - 4, - 5, - 6, - 7, - 8, - 9, - 10, - 11, - 12, - 13, - 14, - 15, - 16, - 17, - 18, - 19, - 20, - 21, - 22, - 23, - 24, - 25, - 26, - 27, - 28, - 29, - 30, - 31, - 32, - 33, - 34, - 35, - 36, - 37, - 38, - 39, - 40, - 41, - 42, - 43, - 44, - 45, - 46, - 47, - 48 + 11 ], - "starting_column": 1, - "ending_column": 2 + "starting_column": 5, + "ending_column": 21 + }, + "type_specific_fields": { + "parent": { + "type": "contract", + "name": "naming", + "source_mapping": { + "start": 28, + "length": 642, + "filename_used": "/home/travis/build/crytic/slither/tests/naming_convention.sol", + "filename_relative": "tests/naming_convention.sol", + "filename_absolute": "/home/travis/build/crytic/slither/tests/naming_convention.sol", + "filename_short": "tests/naming_convention.sol", + "lines": [ + 3, + 4, + 5, + 6, + 7, + 8, + 9, + 10, + 11, + 12, + 13, + 14, + 15, + 16, + 17, + 18, + 19, + 20, + 21, + 22, + 23, + 24, + 25, + 26, + 27, + 28, + 29, + 30, + 31, + 32, + 33, + 34, + 35, + 36, + 37, + 38, + 39, + 40, + 41, + 42, + 43, + 44, + 45, + 46, + 47, + 48 + ], + "starting_column": 1, + "ending_column": 2 + } + } + }, + "additional_fields": { + "target": "variable", + "convention": "mixedCase" } } - } - ] - }, - { - "check": "naming-convention", - "impact": "Informational", - "confidence": "High", - "description": "Enum 'naming.numbers' (tests/naming_convention.sol#6) is not in CapWords\n", - "elements": [ - { - "type": "enum", - "name": "numbers", - "source_mapping": { - "start": 79, - "length": 23, - "filename_used": "/home/travis/build/crytic/slither/tests/naming_convention.sol", - "filename_relative": "tests/naming_convention.sol", - "filename_absolute": "/home/travis/build/crytic/slither/tests/naming_convention.sol", - "filename_short": "tests/naming_convention.sol", - "lines": [ - 6 - ], - "starting_column": 5, - "ending_column": 28 - }, - "additional_fields": { - "target": "enum", - "convention": "CapWords" - }, - "contract": { - "type": "contract", - "name": "naming", + ] + }, + { + "check": "naming-convention", + "impact": "Informational", + "confidence": "High", + "description": "Enum 'naming.numbers' (tests/naming_convention.sol#6) is not in CapWords\n", + "elements": [ + { + "type": "enum", + "name": "numbers", "source_mapping": { - "start": 28, - "length": 642, + "start": 79, + "length": 23, "filename_used": "/home/travis/build/crytic/slither/tests/naming_convention.sol", "filename_relative": "tests/naming_convention.sol", "filename_absolute": "/home/travis/build/crytic/slither/tests/naming_convention.sol", "filename_short": "tests/naming_convention.sol", "lines": [ - 3, - 4, - 5, - 6, - 7, - 8, - 9, - 10, - 11, - 12, - 13, - 14, - 15, - 16, - 17, - 18, - 19, - 20, - 21, - 22, - 23, - 24, - 25, - 26, - 27, - 28, - 29, - 30, - 31, - 32, - 33, - 34, - 35, - 36, - 37, - 38, - 39, - 40, - 41, - 42, - 43, - 44, - 45, - 46, - 47, - 48 + 6 ], - "starting_column": 1, - "ending_column": 2 + "starting_column": 5, + "ending_column": 28 + }, + "type_specific_fields": { + "parent": { + "type": "contract", + "name": "naming", + "source_mapping": { + "start": 28, + "length": 642, + "filename_used": "/home/travis/build/crytic/slither/tests/naming_convention.sol", + "filename_relative": "tests/naming_convention.sol", + "filename_absolute": "/home/travis/build/crytic/slither/tests/naming_convention.sol", + "filename_short": "tests/naming_convention.sol", + "lines": [ + 3, + 4, + 5, + 6, + 7, + 8, + 9, + 10, + 11, + 12, + 13, + 14, + 15, + 16, + 17, + 18, + 19, + 20, + 21, + 22, + 23, + 24, + 25, + 26, + 27, + 28, + 29, + 30, + 31, + 32, + 33, + 34, + 35, + 36, + 37, + 38, + 39, + 40, + 41, + 42, + 43, + 44, + 45, + 46, + 47, + 48 + ], + "starting_column": 1, + "ending_column": 2 + } + } + }, + "additional_fields": { + "target": "enum", + "convention": "CapWords" } } - } - ] - }, - { - "check": "naming-convention", - "impact": "Informational", - "confidence": "High", - "description": "Modifier 'naming.CantDo' (tests/naming_convention.sol#41-43) is not in mixedCase\n", - "elements": [ - { - "type": "function", - "name": "CantDo", - "source_mapping": { - "start": 591, - "length": 36, - "filename_used": "/home/travis/build/crytic/slither/tests/naming_convention.sol", - "filename_relative": "tests/naming_convention.sol", - "filename_absolute": "/home/travis/build/crytic/slither/tests/naming_convention.sol", - "filename_short": "tests/naming_convention.sol", - "lines": [ - 41, - 42, - 43 - ], - "starting_column": 5, - "ending_column": 6 - }, - "additional_fields": { - "target": "modifier", - "convention": "mixedCase" - }, - "contract": { - "type": "contract", - "name": "naming", + ] + }, + { + "check": "naming-convention", + "impact": "Informational", + "confidence": "High", + "description": "Modifier 'naming.CantDo' (tests/naming_convention.sol#41-43) is not in mixedCase\n", + "elements": [ + { + "type": "function", + "name": "CantDo", "source_mapping": { - "start": 28, - "length": 642, + "start": 591, + "length": 36, "filename_used": "/home/travis/build/crytic/slither/tests/naming_convention.sol", "filename_relative": "tests/naming_convention.sol", "filename_absolute": "/home/travis/build/crytic/slither/tests/naming_convention.sol", "filename_short": "tests/naming_convention.sol", "lines": [ - 3, - 4, - 5, - 6, - 7, - 8, - 9, - 10, - 11, - 12, - 13, - 14, - 15, - 16, - 17, - 18, - 19, - 20, - 21, - 22, - 23, - 24, - 25, - 26, - 27, - 28, - 29, - 30, - 31, - 32, - 33, - 34, - 35, - 36, - 37, - 38, - 39, - 40, 41, 42, - 43, - 44, - 45, - 46, - 47, - 48 + 43 ], - "starting_column": 1, - "ending_column": 2 + "starting_column": 5, + "ending_column": 6 + }, + "type_specific_fields": { + "parent": { + "type": "contract", + "name": "naming", + "source_mapping": { + "start": 28, + "length": 642, + "filename_used": "/home/travis/build/crytic/slither/tests/naming_convention.sol", + "filename_relative": "tests/naming_convention.sol", + "filename_absolute": "/home/travis/build/crytic/slither/tests/naming_convention.sol", + "filename_short": "tests/naming_convention.sol", + "lines": [ + 3, + 4, + 5, + 6, + 7, + 8, + 9, + 10, + 11, + 12, + 13, + 14, + 15, + 16, + 17, + 18, + 19, + 20, + 21, + 22, + 23, + 24, + 25, + 26, + 27, + 28, + 29, + 30, + 31, + 32, + 33, + 34, + 35, + 36, + 37, + 38, + 39, + 40, + 41, + 42, + 43, + 44, + 45, + 46, + 47, + 48 + ], + "starting_column": 1, + "ending_column": 2 + } + }, + "signature": "CantDo()" + }, + "additional_fields": { + "target": "modifier", + "convention": "mixedCase" } } - } - ] - }, - { - "check": "naming-convention", - "impact": "Informational", - "confidence": "High", - "description": "Parameter '_used' of T.test (tests/naming_convention.sol#59) is not in mixedCase\n", - "elements": [ - { - "type": "variable", - "name": "_used", - "source_mapping": { - "start": 794, - "length": 10, - "filename_used": "/home/travis/build/crytic/slither/tests/naming_convention.sol", - "filename_relative": "tests/naming_convention.sol", - "filename_absolute": "/home/travis/build/crytic/slither/tests/naming_convention.sol", - "filename_short": "tests/naming_convention.sol", - "lines": [ - 59 - ], - "starting_column": 33, - "ending_column": 43 - }, - "additional_fields": { - "target": "parameter", - "convention": "mixedCase" - }, - "function": { - "type": "function", - "name": "test", + ] + }, + { + "check": "naming-convention", + "impact": "Informational", + "confidence": "High", + "description": "Parameter '_used' of T.test (tests/naming_convention.sol#59) is not in mixedCase\n", + "elements": [ + { + "type": "variable", + "name": "_used", "source_mapping": { - "start": 766, - "length": 84, + "start": 794, + "length": 10, "filename_used": "/home/travis/build/crytic/slither/tests/naming_convention.sol", "filename_relative": "tests/naming_convention.sol", "filename_absolute": "/home/travis/build/crytic/slither/tests/naming_convention.sol", "filename_short": "tests/naming_convention.sol", "lines": [ - 59, - 60 + 59 ], - "starting_column": 5, - "ending_column": 23 + "starting_column": 33, + "ending_column": 43 }, - "contract": { - "type": "contract", - "name": "T", - "source_mapping": { - "start": 692, - "length": 221, - "filename_used": "/home/travis/build/crytic/slither/tests/naming_convention.sol", - "filename_relative": "tests/naming_convention.sol", - "filename_absolute": "/home/travis/build/crytic/slither/tests/naming_convention.sol", - "filename_short": "tests/naming_convention.sol", - "lines": [ - 54, - 55, - 56, - 57, - 58, - 59, - 60, - 61, - 62, - 63, - 64, - 65, - 66, - 67, - 68 - ], - "starting_column": 1, - "ending_column": 2 + "type_specific_fields": { + "parent": { + "type": "function", + "name": "test", + "source_mapping": { + "start": 766, + "length": 84, + "filename_used": "/home/travis/build/crytic/slither/tests/naming_convention.sol", + "filename_relative": "tests/naming_convention.sol", + "filename_absolute": "/home/travis/build/crytic/slither/tests/naming_convention.sol", + "filename_short": "tests/naming_convention.sol", + "lines": [ + 59, + 60 + ], + "starting_column": 5, + "ending_column": 23 + }, + "type_specific_fields": { + "parent": { + "type": "contract", + "name": "T", + "source_mapping": { + "start": 692, + "length": 221, + "filename_used": "/home/travis/build/crytic/slither/tests/naming_convention.sol", + "filename_relative": "tests/naming_convention.sol", + "filename_absolute": "/home/travis/build/crytic/slither/tests/naming_convention.sol", + "filename_short": "tests/naming_convention.sol", + "lines": [ + 54, + 55, + 56, + 57, + 58, + 59, + 60, + 61, + 62, + 63, + 64, + 65, + 66, + 67, + 68 + ], + "starting_column": 1, + "ending_column": 2 + } + }, + "signature": "test(uint256,uint256)" + } } + }, + "additional_fields": { + "target": "parameter", + "convention": "mixedCase" } } - } - ] - }, - { - "check": "naming-convention", - "impact": "Informational", - "confidence": "High", - "description": "Variable 'T._myPublicVar' (tests/naming_convention.sol#56) is not in mixedCase\n", - "elements": [ - { - "type": "variable", - "name": "_myPublicVar", - "source_mapping": { - "start": 741, - "length": 17, - "filename_used": "/home/travis/build/crytic/slither/tests/naming_convention.sol", - "filename_relative": "tests/naming_convention.sol", - "filename_absolute": "/home/travis/build/crytic/slither/tests/naming_convention.sol", - "filename_short": "tests/naming_convention.sol", - "lines": [ - 56 - ], - "starting_column": 5, - "ending_column": 22 - }, - "additional_fields": { - "target": "variable", - "convention": "mixedCase" - }, - "contract": { - "type": "contract", - "name": "T", + ] + }, + { + "check": "naming-convention", + "impact": "Informational", + "confidence": "High", + "description": "Variable 'T._myPublicVar' (tests/naming_convention.sol#56) is not in mixedCase\n", + "elements": [ + { + "type": "variable", + "name": "_myPublicVar", "source_mapping": { - "start": 692, - "length": 221, + "start": 741, + "length": 17, "filename_used": "/home/travis/build/crytic/slither/tests/naming_convention.sol", "filename_relative": "tests/naming_convention.sol", "filename_absolute": "/home/travis/build/crytic/slither/tests/naming_convention.sol", "filename_short": "tests/naming_convention.sol", "lines": [ - 54, - 55, - 56, - 57, - 58, - 59, - 60, - 61, - 62, - 63, - 64, - 65, - 66, - 67, - 68 + 56 ], - "starting_column": 1, - "ending_column": 2 + "starting_column": 5, + "ending_column": 22 + }, + "type_specific_fields": { + "parent": { + "type": "contract", + "name": "T", + "source_mapping": { + "start": 692, + "length": 221, + "filename_used": "/home/travis/build/crytic/slither/tests/naming_convention.sol", + "filename_relative": "tests/naming_convention.sol", + "filename_absolute": "/home/travis/build/crytic/slither/tests/naming_convention.sol", + "filename_short": "tests/naming_convention.sol", + "lines": [ + 54, + 55, + 56, + 57, + 58, + 59, + 60, + 61, + 62, + 63, + 64, + 65, + 66, + 67, + 68 + ], + "starting_column": 1, + "ending_column": 2 + } + } + }, + "additional_fields": { + "target": "variable", + "convention": "mixedCase" } } - } - ] - }, - { - "check": "naming-convention", - "impact": "Informational", - "confidence": "High", - "description": "Variable 'T.l' (tests/naming_convention.sol#67) used l, O, I, which should not be used\n", - "elements": [ - { - "type": "variable", - "name": "l", - "source_mapping": { - "start": 900, - "length": 10, - "filename_used": "/home/travis/build/crytic/slither/tests/naming_convention.sol", - "filename_relative": "tests/naming_convention.sol", - "filename_absolute": "/home/travis/build/crytic/slither/tests/naming_convention.sol", - "filename_short": "tests/naming_convention.sol", - "lines": [ - 67 - ], - "starting_column": 5, - "ending_column": 15 - }, - "additional_fields": { - "target": "variable", - "convention": "l_O_I_should_not_be_used" - }, - "contract": { - "type": "contract", - "name": "T", + ] + }, + { + "check": "naming-convention", + "impact": "Informational", + "confidence": "High", + "description": "Variable 'T.l' (tests/naming_convention.sol#67) used l, O, I, which should not be used\n", + "elements": [ + { + "type": "variable", + "name": "l", "source_mapping": { - "start": 692, - "length": 221, + "start": 900, + "length": 10, "filename_used": "/home/travis/build/crytic/slither/tests/naming_convention.sol", "filename_relative": "tests/naming_convention.sol", "filename_absolute": "/home/travis/build/crytic/slither/tests/naming_convention.sol", "filename_short": "tests/naming_convention.sol", "lines": [ - 54, - 55, - 56, - 57, - 58, - 59, - 60, - 61, - 62, - 63, - 64, - 65, - 66, - 67, - 68 + 67 ], - "starting_column": 1, - "ending_column": 2 + "starting_column": 5, + "ending_column": 15 + }, + "type_specific_fields": { + "parent": { + "type": "contract", + "name": "T", + "source_mapping": { + "start": 692, + "length": 221, + "filename_used": "/home/travis/build/crytic/slither/tests/naming_convention.sol", + "filename_relative": "tests/naming_convention.sol", + "filename_absolute": "/home/travis/build/crytic/slither/tests/naming_convention.sol", + "filename_short": "tests/naming_convention.sol", + "lines": [ + 54, + 55, + 56, + 57, + 58, + 59, + 60, + 61, + 62, + 63, + 64, + 65, + 66, + 67, + 68 + ], + "starting_column": 1, + "ending_column": 2 + } + } + }, + "additional_fields": { + "target": "variable", + "convention": "l_O_I_should_not_be_used" } } - } - ] - } - ] + ] + } + ] + } } \ No newline at end of file diff --git a/tests/expected_json/old_solc.sol.json.solc-version.json b/tests/expected_json/old_solc.sol.json.solc-version.json index c653aff11..83604420d 100644 --- a/tests/expected_json/old_solc.sol.json.solc-version.json +++ b/tests/expected_json/old_solc.sol.json.solc-version.json @@ -1,34 +1,38 @@ { "success": true, "error": null, - "results": [ - { - "check": "solc-version", - "impact": "Informational", - "confidence": "High", - "description": "Pragma version \"0.4.21\" allows old versions (None)\n", - "elements": [ - { - "type": "pragma", - "name": "0.4.21", - "source_mapping": { - "start": 0, - "length": 23, - "filename_used": "old_solc.sol", - "filename_relative": null, - "filename_absolute": null, - "filename_short": null, - "lines": [], - "starting_column": null, - "ending_column": null - }, - "directive": [ - "solidity", - "0.4", - ".21" - ] - } - ] - } - ] + "results": { + "detectors": [ + { + "check": "solc-version", + "impact": "Informational", + "confidence": "High", + "description": "Pragma version \"0.4.21\" allows old versions (None)\n", + "elements": [ + { + "type": "pragma", + "name": "0.4.21", + "source_mapping": { + "start": 0, + "length": 23, + "filename_used": "old_solc.sol", + "filename_relative": null, + "filename_absolute": null, + "filename_short": null, + "lines": [], + "starting_column": null, + "ending_column": null + }, + "type_specific_fields": { + "directive": [ + "solidity", + "0.4", + ".21" + ] + } + } + ] + } + ] + } } \ No newline at end of file diff --git a/tests/expected_json/old_solc.sol.json.solc-version.txt b/tests/expected_json/old_solc.sol.json.solc-version.txt index 92f5c7b09..547cbd3f2 100644 --- a/tests/expected_json/old_solc.sol.json.solc-version.txt +++ b/tests/expected_json/old_solc.sol.json.solc-version.txt @@ -1,4 +1,5 @@ INFO:Detectors: Pragma version "0.4.21" allows old versions (None) Reference: https://github.com/crytic/slither/wiki/Detector-Documentation#incorrect-version-of-solidity +INFO:Slither:/home/travis/build/crytic/slither/scripts/../tests/expected_json/old_solc.sol.json.solc-version.json exists already, the overwrite is prevented INFO:Slither:tests/old_solc.sol.json analyzed (1 contracts), 1 result(s) found diff --git a/tests/expected_json/pragma.0.4.24.pragma.json b/tests/expected_json/pragma.0.4.24.pragma.json index cfa7f995f..80e8de844 100644 --- a/tests/expected_json/pragma.0.4.24.pragma.json +++ b/tests/expected_json/pragma.0.4.24.pragma.json @@ -1,60 +1,66 @@ { "success": true, "error": null, - "results": [ - { - "check": "pragma", - "impact": "Informational", - "confidence": "High", - "description": "Different versions of Solidity is used in :\n\t- Version used: ['^0.4.23', '^0.4.24']\n\t- tests/pragma.0.4.23.sol#1 declares pragma solidity^0.4.23\n\t- tests/pragma.0.4.24.sol#1 declares pragma solidity^0.4.24\n", - "elements": [ - { - "type": "pragma", - "name": "^0.4.23", - "source_mapping": { - "start": 0, - "length": 24, - "filename_used": "/home/travis/build/crytic/slither/tests/pragma.0.4.23.sol", - "filename_relative": "tests/pragma.0.4.23.sol", - "filename_absolute": "/home/travis/build/crytic/slither/tests/pragma.0.4.23.sol", - "filename_short": "tests/pragma.0.4.23.sol", - "lines": [ - 1 - ], - "starting_column": 1, - "ending_column": 25 + "results": { + "detectors": [ + { + "check": "pragma", + "impact": "Informational", + "confidence": "High", + "description": "Different versions of Solidity is used in :\n\t- Version used: ['^0.4.23', '^0.4.24']\n\t- tests/pragma.0.4.23.sol#1 declares pragma solidity^0.4.23\n\t- tests/pragma.0.4.24.sol#1 declares pragma solidity^0.4.24\n", + "elements": [ + { + "type": "pragma", + "name": "^0.4.23", + "source_mapping": { + "start": 0, + "length": 24, + "filename_used": "/home/travis/build/crytic/slither/tests/pragma.0.4.23.sol", + "filename_relative": "tests/pragma.0.4.23.sol", + "filename_absolute": "/home/travis/build/crytic/slither/tests/pragma.0.4.23.sol", + "filename_short": "tests/pragma.0.4.23.sol", + "lines": [ + 1 + ], + "starting_column": 1, + "ending_column": 25 + }, + "type_specific_fields": { + "directive": [ + "solidity", + "^", + "0.4", + ".23" + ] + } }, - "directive": [ - "solidity", - "^", - "0.4", - ".23" - ] - }, - { - "type": "pragma", - "name": "^0.4.24", - "source_mapping": { - "start": 0, - "length": 24, - "filename_used": "/home/travis/build/crytic/slither/tests/pragma.0.4.24.sol", - "filename_relative": "tests/pragma.0.4.24.sol", - "filename_absolute": "/home/travis/build/crytic/slither/tests/pragma.0.4.24.sol", - "filename_short": "tests/pragma.0.4.24.sol", - "lines": [ - 1 - ], - "starting_column": 1, - "ending_column": 25 - }, - "directive": [ - "solidity", - "^", - "0.4", - ".24" - ] - } - ] - } - ] + { + "type": "pragma", + "name": "^0.4.24", + "source_mapping": { + "start": 0, + "length": 24, + "filename_used": "/home/travis/build/crytic/slither/tests/pragma.0.4.24.sol", + "filename_relative": "tests/pragma.0.4.24.sol", + "filename_absolute": "/home/travis/build/crytic/slither/tests/pragma.0.4.24.sol", + "filename_short": "tests/pragma.0.4.24.sol", + "lines": [ + 1 + ], + "starting_column": 1, + "ending_column": 25 + }, + "type_specific_fields": { + "directive": [ + "solidity", + "^", + "0.4", + ".24" + ] + } + } + ] + } + ] + } } \ No newline at end of file diff --git a/tests/expected_json/reentrancy-0.5.1.reentrancy-eth.json b/tests/expected_json/reentrancy-0.5.1.reentrancy-eth.json index 480dd0df9..df690d7c7 100644 --- a/tests/expected_json/reentrancy-0.5.1.reentrancy-eth.json +++ b/tests/expected_json/reentrancy-0.5.1.reentrancy-eth.json @@ -1,126 +1,15 @@ { "success": true, "error": null, - "results": [ - { - "check": "reentrancy-eth", - "impact": "High", - "confidence": "Medium", - "description": "Reentrancy in Reentrancy.withdrawBalance (tests/reentrancy-0.5.1.sol#14-22):\n\tExternal calls:\n\t- (ret,mem) = msg.sender.call.value(userBalance[msg.sender])() (tests/reentrancy-0.5.1.sol#17)\n\tState variables written after the call(s):\n\t- userBalance (tests/reentrancy-0.5.1.sol#21)\n", - "elements": [ - { - "type": "function", - "name": "withdrawBalance", - "source_mapping": { - "start": 298, - "length": 357, - "filename_used": "/home/travis/build/crytic/slither/tests/reentrancy-0.5.1.sol", - "filename_relative": "tests/reentrancy-0.5.1.sol", - "filename_absolute": "/home/travis/build/crytic/slither/tests/reentrancy-0.5.1.sol", - "filename_short": "tests/reentrancy-0.5.1.sol", - "lines": [ - 14, - 15, - 16, - 17, - 18, - 19, - 20, - 21, - 22 - ], - "starting_column": 5, - "ending_column": 6 - }, - "contract": { - "type": "contract", - "name": "Reentrancy", - "source_mapping": { - "start": 25, - "length": 1807, - "filename_used": "/home/travis/build/crytic/slither/tests/reentrancy-0.5.1.sol", - "filename_relative": "tests/reentrancy-0.5.1.sol", - "filename_absolute": "/home/travis/build/crytic/slither/tests/reentrancy-0.5.1.sol", - "filename_short": "tests/reentrancy-0.5.1.sol", - "lines": [ - 3, - 4, - 5, - 6, - 7, - 8, - 9, - 10, - 11, - 12, - 13, - 14, - 15, - 16, - 17, - 18, - 19, - 20, - 21, - 22, - 23, - 24, - 25, - 26, - 27, - 28, - 29, - 30, - 31, - 32, - 33, - 34, - 35, - 36, - 37, - 38, - 39, - 40, - 41, - 42, - 43, - 44, - 45, - 46, - 47, - 48, - 49, - 50, - 51, - 52, - 53, - 54 - ], - "starting_column": 1, - "ending_column": 2 - } - } - }, - { - "type": "node", - "name": "(ret,mem) = msg.sender.call.value(userBalance[msg.sender])()", - "source_mapping": { - "start": 477, - "length": 81, - "filename_used": "/home/travis/build/crytic/slither/tests/reentrancy-0.5.1.sol", - "filename_relative": "tests/reentrancy-0.5.1.sol", - "filename_absolute": "/home/travis/build/crytic/slither/tests/reentrancy-0.5.1.sol", - "filename_short": "tests/reentrancy-0.5.1.sol", - "lines": [ - 17 - ], - "starting_column": 9, - "ending_column": 90 - }, - "additional_fields": { - "underlying_type": "external_calls" - }, - "function": { + "results": { + "detectors": [ + { + "check": "reentrancy-eth", + "impact": "High", + "confidence": "Medium", + "description": "Reentrancy in Reentrancy.withdrawBalance (tests/reentrancy-0.5.1.sol#14-22):\n\tExternal calls:\n\t- (ret,mem) = msg.sender.call.value(userBalance[msg.sender])() (tests/reentrancy-0.5.1.sol#17)\n\tState variables written after the call(s):\n\t- userBalance (tests/reentrancy-0.5.1.sol#21)\n", + "elements": [ + { "type": "function", "name": "withdrawBalance", "source_mapping": { @@ -144,312 +33,324 @@ "starting_column": 5, "ending_column": 6 }, - "contract": { - "type": "contract", - "name": "Reentrancy", - "source_mapping": { - "start": 25, - "length": 1807, - "filename_used": "/home/travis/build/crytic/slither/tests/reentrancy-0.5.1.sol", - "filename_relative": "tests/reentrancy-0.5.1.sol", - "filename_absolute": "/home/travis/build/crytic/slither/tests/reentrancy-0.5.1.sol", - "filename_short": "tests/reentrancy-0.5.1.sol", - "lines": [ - 3, - 4, - 5, - 6, - 7, - 8, - 9, - 10, - 11, - 12, - 13, - 14, - 15, - 16, - 17, - 18, - 19, - 20, - 21, - 22, - 23, - 24, - 25, - 26, - 27, - 28, - 29, - 30, - 31, - 32, - 33, - 34, - 35, - 36, - 37, - 38, - 39, - 40, - 41, - 42, - 43, - 44, - 45, - 46, - 47, - 48, - 49, - 50, - 51, - 52, - 53, - 54 - ], - "starting_column": 1, - "ending_column": 2 - } + "type_specific_fields": { + "parent": { + "type": "contract", + "name": "Reentrancy", + "source_mapping": { + "start": 25, + "length": 1807, + "filename_used": "/home/travis/build/crytic/slither/tests/reentrancy-0.5.1.sol", + "filename_relative": "tests/reentrancy-0.5.1.sol", + "filename_absolute": "/home/travis/build/crytic/slither/tests/reentrancy-0.5.1.sol", + "filename_short": "tests/reentrancy-0.5.1.sol", + "lines": [ + 3, + 4, + 5, + 6, + 7, + 8, + 9, + 10, + 11, + 12, + 13, + 14, + 15, + 16, + 17, + 18, + 19, + 20, + 21, + 22, + 23, + 24, + 25, + 26, + 27, + 28, + 29, + 30, + 31, + 32, + 33, + 34, + 35, + 36, + 37, + 38, + 39, + 40, + 41, + 42, + 43, + 44, + 45, + 46, + 47, + 48, + 49, + 50, + 51, + 52, + 53, + 54 + ], + "starting_column": 1, + "ending_column": 2 + } + }, + "signature": "withdrawBalance()" } - } - }, - { - "type": "node", - "name": "userBalance[msg.sender] = 0", - "source_mapping": { - "start": 621, - "length": 27, - "filename_used": "/home/travis/build/crytic/slither/tests/reentrancy-0.5.1.sol", - "filename_relative": "tests/reentrancy-0.5.1.sol", - "filename_absolute": "/home/travis/build/crytic/slither/tests/reentrancy-0.5.1.sol", - "filename_short": "tests/reentrancy-0.5.1.sol", - "lines": [ - 21 - ], - "starting_column": 9, - "ending_column": 36 - }, - "additional_fields": { - "underlying_type": "variables_written", - "variable_name": "userBalance" }, - "function": { - "type": "function", - "name": "withdrawBalance", + { + "type": "node", + "name": "(ret,mem) = msg.sender.call.value(userBalance[msg.sender])()", "source_mapping": { - "start": 298, - "length": 357, + "start": 477, + "length": 81, "filename_used": "/home/travis/build/crytic/slither/tests/reentrancy-0.5.1.sol", "filename_relative": "tests/reentrancy-0.5.1.sol", "filename_absolute": "/home/travis/build/crytic/slither/tests/reentrancy-0.5.1.sol", "filename_short": "tests/reentrancy-0.5.1.sol", "lines": [ - 14, - 15, - 16, - 17, - 18, - 19, - 20, - 21, - 22 + 17 ], - "starting_column": 5, - "ending_column": 6 + "starting_column": 9, + "ending_column": 90 }, - "contract": { - "type": "contract", - "name": "Reentrancy", - "source_mapping": { - "start": 25, - "length": 1807, - "filename_used": "/home/travis/build/crytic/slither/tests/reentrancy-0.5.1.sol", - "filename_relative": "tests/reentrancy-0.5.1.sol", - "filename_absolute": "/home/travis/build/crytic/slither/tests/reentrancy-0.5.1.sol", - "filename_short": "tests/reentrancy-0.5.1.sol", - "lines": [ - 3, - 4, - 5, - 6, - 7, - 8, - 9, - 10, - 11, - 12, - 13, - 14, - 15, - 16, - 17, - 18, - 19, - 20, - 21, - 22, - 23, - 24, - 25, - 26, - 27, - 28, - 29, - 30, - 31, - 32, - 33, - 34, - 35, - 36, - 37, - 38, - 39, - 40, - 41, - 42, - 43, - 44, - 45, - 46, - 47, - 48, - 49, - 50, - 51, - 52, - 53, - 54 - ], - "starting_column": 1, - "ending_column": 2 + "type_specific_fields": { + "parent": { + "type": "function", + "name": "withdrawBalance", + "source_mapping": { + "start": 298, + "length": 357, + "filename_used": "/home/travis/build/crytic/slither/tests/reentrancy-0.5.1.sol", + "filename_relative": "tests/reentrancy-0.5.1.sol", + "filename_absolute": "/home/travis/build/crytic/slither/tests/reentrancy-0.5.1.sol", + "filename_short": "tests/reentrancy-0.5.1.sol", + "lines": [ + 14, + 15, + 16, + 17, + 18, + 19, + 20, + 21, + 22 + ], + "starting_column": 5, + "ending_column": 6 + }, + "type_specific_fields": { + "parent": { + "type": "contract", + "name": "Reentrancy", + "source_mapping": { + "start": 25, + "length": 1807, + "filename_used": "/home/travis/build/crytic/slither/tests/reentrancy-0.5.1.sol", + "filename_relative": "tests/reentrancy-0.5.1.sol", + "filename_absolute": "/home/travis/build/crytic/slither/tests/reentrancy-0.5.1.sol", + "filename_short": "tests/reentrancy-0.5.1.sol", + "lines": [ + 3, + 4, + 5, + 6, + 7, + 8, + 9, + 10, + 11, + 12, + 13, + 14, + 15, + 16, + 17, + 18, + 19, + 20, + 21, + 22, + 23, + 24, + 25, + 26, + 27, + 28, + 29, + 30, + 31, + 32, + 33, + 34, + 35, + 36, + 37, + 38, + 39, + 40, + 41, + 42, + 43, + 44, + 45, + 46, + 47, + 48, + 49, + 50, + 51, + 52, + 53, + 54 + ], + "starting_column": 1, + "ending_column": 2 + } + }, + "signature": "withdrawBalance()" + } } + }, + "additional_fields": { + "underlying_type": "external_calls" } - } - } - ] - }, - { - "check": "reentrancy-eth", - "impact": "High", - "confidence": "Medium", - "description": "Reentrancy in Reentrancy.withdrawBalance_fixed_3 (tests/reentrancy-0.5.1.sol#44-53):\n\tExternal calls:\n\t- (ret,mem) = msg.sender.call.value(amount)() (tests/reentrancy-0.5.1.sol#49)\n\tState variables written after the call(s):\n\t- userBalance (tests/reentrancy-0.5.1.sol#51)\n", - "elements": [ - { - "type": "function", - "name": "withdrawBalance_fixed_3", - "source_mapping": { - "start": 1434, - "length": 393, - "filename_used": "/home/travis/build/crytic/slither/tests/reentrancy-0.5.1.sol", - "filename_relative": "tests/reentrancy-0.5.1.sol", - "filename_absolute": "/home/travis/build/crytic/slither/tests/reentrancy-0.5.1.sol", - "filename_short": "tests/reentrancy-0.5.1.sol", - "lines": [ - 44, - 45, - 46, - 47, - 48, - 49, - 50, - 51, - 52, - 53 - ], - "starting_column": 5, - "ending_column": 6 }, - "contract": { - "type": "contract", - "name": "Reentrancy", + { + "type": "node", + "name": "userBalance[msg.sender] = 0", "source_mapping": { - "start": 25, - "length": 1807, + "start": 621, + "length": 27, "filename_used": "/home/travis/build/crytic/slither/tests/reentrancy-0.5.1.sol", "filename_relative": "tests/reentrancy-0.5.1.sol", "filename_absolute": "/home/travis/build/crytic/slither/tests/reentrancy-0.5.1.sol", "filename_short": "tests/reentrancy-0.5.1.sol", "lines": [ - 3, - 4, - 5, - 6, - 7, - 8, - 9, - 10, - 11, - 12, - 13, - 14, - 15, - 16, - 17, - 18, - 19, - 20, - 21, - 22, - 23, - 24, - 25, - 26, - 27, - 28, - 29, - 30, - 31, - 32, - 33, - 34, - 35, - 36, - 37, - 38, - 39, - 40, - 41, - 42, - 43, - 44, - 45, - 46, - 47, - 48, - 49, - 50, - 51, - 52, - 53, - 54 + 21 ], - "starting_column": 1, - "ending_column": 2 + "starting_column": 9, + "ending_column": 36 + }, + "type_specific_fields": { + "parent": { + "type": "function", + "name": "withdrawBalance", + "source_mapping": { + "start": 298, + "length": 357, + "filename_used": "/home/travis/build/crytic/slither/tests/reentrancy-0.5.1.sol", + "filename_relative": "tests/reentrancy-0.5.1.sol", + "filename_absolute": "/home/travis/build/crytic/slither/tests/reentrancy-0.5.1.sol", + "filename_short": "tests/reentrancy-0.5.1.sol", + "lines": [ + 14, + 15, + 16, + 17, + 18, + 19, + 20, + 21, + 22 + ], + "starting_column": 5, + "ending_column": 6 + }, + "type_specific_fields": { + "parent": { + "type": "contract", + "name": "Reentrancy", + "source_mapping": { + "start": 25, + "length": 1807, + "filename_used": "/home/travis/build/crytic/slither/tests/reentrancy-0.5.1.sol", + "filename_relative": "tests/reentrancy-0.5.1.sol", + "filename_absolute": "/home/travis/build/crytic/slither/tests/reentrancy-0.5.1.sol", + "filename_short": "tests/reentrancy-0.5.1.sol", + "lines": [ + 3, + 4, + 5, + 6, + 7, + 8, + 9, + 10, + 11, + 12, + 13, + 14, + 15, + 16, + 17, + 18, + 19, + 20, + 21, + 22, + 23, + 24, + 25, + 26, + 27, + 28, + 29, + 30, + 31, + 32, + 33, + 34, + 35, + 36, + 37, + 38, + 39, + 40, + 41, + 42, + 43, + 44, + 45, + 46, + 47, + 48, + 49, + 50, + 51, + 52, + 53, + 54 + ], + "starting_column": 1, + "ending_column": 2 + } + }, + "signature": "withdrawBalance()" + } + } + }, + "additional_fields": { + "underlying_type": "variables_written", + "variable_name": "userBalance" } } - }, - { - "type": "node", - "name": "(ret,mem) = msg.sender.call.value(amount)()", - "source_mapping": { - "start": 1679, - "length": 64, - "filename_used": "/home/travis/build/crytic/slither/tests/reentrancy-0.5.1.sol", - "filename_relative": "tests/reentrancy-0.5.1.sol", - "filename_absolute": "/home/travis/build/crytic/slither/tests/reentrancy-0.5.1.sol", - "filename_short": "tests/reentrancy-0.5.1.sol", - "lines": [ - 49 - ], - "starting_column": 9, - "ending_column": 73 - }, - "additional_fields": { - "underlying_type": "external_calls" - }, - "function": { + ] + }, + { + "check": "reentrancy-eth", + "impact": "High", + "confidence": "Medium", + "description": "Reentrancy in Reentrancy.withdrawBalance_fixed_3 (tests/reentrancy-0.5.1.sol#44-53):\n\tExternal calls:\n\t- (ret,mem) = msg.sender.call.value(amount)() (tests/reentrancy-0.5.1.sol#49)\n\tState variables written after the call(s):\n\t- userBalance (tests/reentrancy-0.5.1.sol#51)\n", + "elements": [ + { "type": "function", "name": "withdrawBalance_fixed_3", "source_mapping": { @@ -474,192 +375,319 @@ "starting_column": 5, "ending_column": 6 }, - "contract": { - "type": "contract", - "name": "Reentrancy", - "source_mapping": { - "start": 25, - "length": 1807, - "filename_used": "/home/travis/build/crytic/slither/tests/reentrancy-0.5.1.sol", - "filename_relative": "tests/reentrancy-0.5.1.sol", - "filename_absolute": "/home/travis/build/crytic/slither/tests/reentrancy-0.5.1.sol", - "filename_short": "tests/reentrancy-0.5.1.sol", - "lines": [ - 3, - 4, - 5, - 6, - 7, - 8, - 9, - 10, - 11, - 12, - 13, - 14, - 15, - 16, - 17, - 18, - 19, - 20, - 21, - 22, - 23, - 24, - 25, - 26, - 27, - 28, - 29, - 30, - 31, - 32, - 33, - 34, - 35, - 36, - 37, - 38, - 39, - 40, - 41, - 42, - 43, - 44, - 45, - 46, - 47, - 48, - 49, - 50, - 51, - 52, - 53, - 54 - ], - "starting_column": 1, - "ending_column": 2 - } + "type_specific_fields": { + "parent": { + "type": "contract", + "name": "Reentrancy", + "source_mapping": { + "start": 25, + "length": 1807, + "filename_used": "/home/travis/build/crytic/slither/tests/reentrancy-0.5.1.sol", + "filename_relative": "tests/reentrancy-0.5.1.sol", + "filename_absolute": "/home/travis/build/crytic/slither/tests/reentrancy-0.5.1.sol", + "filename_short": "tests/reentrancy-0.5.1.sol", + "lines": [ + 3, + 4, + 5, + 6, + 7, + 8, + 9, + 10, + 11, + 12, + 13, + 14, + 15, + 16, + 17, + 18, + 19, + 20, + 21, + 22, + 23, + 24, + 25, + 26, + 27, + 28, + 29, + 30, + 31, + 32, + 33, + 34, + 35, + 36, + 37, + 38, + 39, + 40, + 41, + 42, + 43, + 44, + 45, + 46, + 47, + 48, + 49, + 50, + 51, + 52, + 53, + 54 + ], + "starting_column": 1, + "ending_column": 2 + } + }, + "signature": "withdrawBalance_fixed_3()" } - } - }, - { - "type": "node", - "name": "userBalance[msg.sender] = amount", - "source_mapping": { - "start": 1778, - "length": 32, - "filename_used": "/home/travis/build/crytic/slither/tests/reentrancy-0.5.1.sol", - "filename_relative": "tests/reentrancy-0.5.1.sol", - "filename_absolute": "/home/travis/build/crytic/slither/tests/reentrancy-0.5.1.sol", - "filename_short": "tests/reentrancy-0.5.1.sol", - "lines": [ - 51 - ], - "starting_column": 13, - "ending_column": 45 }, - "additional_fields": { - "underlying_type": "variables_written", - "variable_name": "userBalance" + { + "type": "node", + "name": "(ret,mem) = msg.sender.call.value(amount)()", + "source_mapping": { + "start": 1679, + "length": 64, + "filename_used": "/home/travis/build/crytic/slither/tests/reentrancy-0.5.1.sol", + "filename_relative": "tests/reentrancy-0.5.1.sol", + "filename_absolute": "/home/travis/build/crytic/slither/tests/reentrancy-0.5.1.sol", + "filename_short": "tests/reentrancy-0.5.1.sol", + "lines": [ + 49 + ], + "starting_column": 9, + "ending_column": 73 + }, + "type_specific_fields": { + "parent": { + "type": "function", + "name": "withdrawBalance_fixed_3", + "source_mapping": { + "start": 1434, + "length": 393, + "filename_used": "/home/travis/build/crytic/slither/tests/reentrancy-0.5.1.sol", + "filename_relative": "tests/reentrancy-0.5.1.sol", + "filename_absolute": "/home/travis/build/crytic/slither/tests/reentrancy-0.5.1.sol", + "filename_short": "tests/reentrancy-0.5.1.sol", + "lines": [ + 44, + 45, + 46, + 47, + 48, + 49, + 50, + 51, + 52, + 53 + ], + "starting_column": 5, + "ending_column": 6 + }, + "type_specific_fields": { + "parent": { + "type": "contract", + "name": "Reentrancy", + "source_mapping": { + "start": 25, + "length": 1807, + "filename_used": "/home/travis/build/crytic/slither/tests/reentrancy-0.5.1.sol", + "filename_relative": "tests/reentrancy-0.5.1.sol", + "filename_absolute": "/home/travis/build/crytic/slither/tests/reentrancy-0.5.1.sol", + "filename_short": "tests/reentrancy-0.5.1.sol", + "lines": [ + 3, + 4, + 5, + 6, + 7, + 8, + 9, + 10, + 11, + 12, + 13, + 14, + 15, + 16, + 17, + 18, + 19, + 20, + 21, + 22, + 23, + 24, + 25, + 26, + 27, + 28, + 29, + 30, + 31, + 32, + 33, + 34, + 35, + 36, + 37, + 38, + 39, + 40, + 41, + 42, + 43, + 44, + 45, + 46, + 47, + 48, + 49, + 50, + 51, + 52, + 53, + 54 + ], + "starting_column": 1, + "ending_column": 2 + } + }, + "signature": "withdrawBalance_fixed_3()" + } + } + }, + "additional_fields": { + "underlying_type": "external_calls" + } }, - "function": { - "type": "function", - "name": "withdrawBalance_fixed_3", + { + "type": "node", + "name": "userBalance[msg.sender] = amount", "source_mapping": { - "start": 1434, - "length": 393, + "start": 1778, + "length": 32, "filename_used": "/home/travis/build/crytic/slither/tests/reentrancy-0.5.1.sol", "filename_relative": "tests/reentrancy-0.5.1.sol", "filename_absolute": "/home/travis/build/crytic/slither/tests/reentrancy-0.5.1.sol", "filename_short": "tests/reentrancy-0.5.1.sol", "lines": [ - 44, - 45, - 46, - 47, - 48, - 49, - 50, - 51, - 52, - 53 + 51 ], - "starting_column": 5, - "ending_column": 6 + "starting_column": 13, + "ending_column": 45 }, - "contract": { - "type": "contract", - "name": "Reentrancy", - "source_mapping": { - "start": 25, - "length": 1807, - "filename_used": "/home/travis/build/crytic/slither/tests/reentrancy-0.5.1.sol", - "filename_relative": "tests/reentrancy-0.5.1.sol", - "filename_absolute": "/home/travis/build/crytic/slither/tests/reentrancy-0.5.1.sol", - "filename_short": "tests/reentrancy-0.5.1.sol", - "lines": [ - 3, - 4, - 5, - 6, - 7, - 8, - 9, - 10, - 11, - 12, - 13, - 14, - 15, - 16, - 17, - 18, - 19, - 20, - 21, - 22, - 23, - 24, - 25, - 26, - 27, - 28, - 29, - 30, - 31, - 32, - 33, - 34, - 35, - 36, - 37, - 38, - 39, - 40, - 41, - 42, - 43, - 44, - 45, - 46, - 47, - 48, - 49, - 50, - 51, - 52, - 53, - 54 - ], - "starting_column": 1, - "ending_column": 2 + "type_specific_fields": { + "parent": { + "type": "function", + "name": "withdrawBalance_fixed_3", + "source_mapping": { + "start": 1434, + "length": 393, + "filename_used": "/home/travis/build/crytic/slither/tests/reentrancy-0.5.1.sol", + "filename_relative": "tests/reentrancy-0.5.1.sol", + "filename_absolute": "/home/travis/build/crytic/slither/tests/reentrancy-0.5.1.sol", + "filename_short": "tests/reentrancy-0.5.1.sol", + "lines": [ + 44, + 45, + 46, + 47, + 48, + 49, + 50, + 51, + 52, + 53 + ], + "starting_column": 5, + "ending_column": 6 + }, + "type_specific_fields": { + "parent": { + "type": "contract", + "name": "Reentrancy", + "source_mapping": { + "start": 25, + "length": 1807, + "filename_used": "/home/travis/build/crytic/slither/tests/reentrancy-0.5.1.sol", + "filename_relative": "tests/reentrancy-0.5.1.sol", + "filename_absolute": "/home/travis/build/crytic/slither/tests/reentrancy-0.5.1.sol", + "filename_short": "tests/reentrancy-0.5.1.sol", + "lines": [ + 3, + 4, + 5, + 6, + 7, + 8, + 9, + 10, + 11, + 12, + 13, + 14, + 15, + 16, + 17, + 18, + 19, + 20, + 21, + 22, + 23, + 24, + 25, + 26, + 27, + 28, + 29, + 30, + 31, + 32, + 33, + 34, + 35, + 36, + 37, + 38, + 39, + 40, + 41, + 42, + 43, + 44, + 45, + 46, + 47, + 48, + 49, + 50, + 51, + 52, + 53, + 54 + ], + "starting_column": 1, + "ending_column": 2 + } + }, + "signature": "withdrawBalance_fixed_3()" + } } + }, + "additional_fields": { + "underlying_type": "variables_written", + "variable_name": "userBalance" } } - } - ] - } - ] + ] + } + ] + } } \ No newline at end of file diff --git a/tests/expected_json/reentrancy.reentrancy-eth.json b/tests/expected_json/reentrancy.reentrancy-eth.json index 9f56f9d99..4ffb63851 100644 --- a/tests/expected_json/reentrancy.reentrancy-eth.json +++ b/tests/expected_json/reentrancy.reentrancy-eth.json @@ -1,145 +1,15 @@ { "success": true, "error": null, - "results": [ - { - "check": "reentrancy-eth", - "impact": "High", - "confidence": "Medium", - "description": "Reentrancy in Reentrancy.withdrawBalance (tests/reentrancy.sol#14-21):\n\tExternal calls:\n\t- ! (msg.sender.call.value(userBalance[msg.sender])()) (tests/reentrancy.sol#17-19)\n\tState variables written after the call(s):\n\t- userBalance (tests/reentrancy.sol#20)\n", - "elements": [ - { - "type": "function", - "name": "withdrawBalance", - "source_mapping": { - "start": 299, - "length": 314, - "filename_used": "/home/travis/build/crytic/slither/tests/reentrancy.sol", - "filename_relative": "tests/reentrancy.sol", - "filename_absolute": "/home/travis/build/crytic/slither/tests/reentrancy.sol", - "filename_short": "tests/reentrancy.sol", - "lines": [ - 14, - 15, - 16, - 17, - 18, - 19, - 20, - 21 - ], - "starting_column": 5, - "ending_column": 6 - }, - "contract": { - "type": "contract", - "name": "Reentrancy", - "source_mapping": { - "start": 26, - "length": 2334, - "filename_used": "/home/travis/build/crytic/slither/tests/reentrancy.sol", - "filename_relative": "tests/reentrancy.sol", - "filename_absolute": "/home/travis/build/crytic/slither/tests/reentrancy.sol", - "filename_short": "tests/reentrancy.sol", - "lines": [ - 3, - 4, - 5, - 6, - 7, - 8, - 9, - 10, - 11, - 12, - 13, - 14, - 15, - 16, - 17, - 18, - 19, - 20, - 21, - 22, - 23, - 24, - 25, - 26, - 27, - 28, - 29, - 30, - 31, - 32, - 33, - 34, - 35, - 36, - 37, - 38, - 39, - 40, - 41, - 42, - 43, - 44, - 45, - 46, - 47, - 48, - 49, - 50, - 51, - 52, - 53, - 54, - 55, - 56, - 57, - 58, - 59, - 60, - 61, - 62, - 63, - 64, - 65, - 66, - 67, - 68, - 69, - 70, - 71, - 72 - ], - "starting_column": 1, - "ending_column": 2 - } - } - }, - { - "type": "node", - "name": "! (msg.sender.call.value(userBalance[msg.sender])())", - "source_mapping": { - "start": 478, - "length": 92, - "filename_used": "/home/travis/build/crytic/slither/tests/reentrancy.sol", - "filename_relative": "tests/reentrancy.sol", - "filename_absolute": "/home/travis/build/crytic/slither/tests/reentrancy.sol", - "filename_short": "tests/reentrancy.sol", - "lines": [ - 17, - 18, - 19 - ], - "starting_column": 9, - "ending_column": 10 - }, - "additional_fields": { - "underlying_type": "external_calls" - }, - "function": { + "results": { + "detectors": [ + { + "check": "reentrancy-eth", + "impact": "High", + "confidence": "Medium", + "description": "Reentrancy in Reentrancy.withdrawBalance (tests/reentrancy.sol#14-21):\n\tExternal calls:\n\t- ! (msg.sender.call.value(userBalance[msg.sender])()) (tests/reentrancy.sol#17-19)\n\tState variables written after the call(s):\n\t- userBalance (tests/reentrancy.sol#20)\n", + "elements": [ + { "type": "function", "name": "withdrawBalance", "source_mapping": { @@ -162,362 +32,378 @@ "starting_column": 5, "ending_column": 6 }, - "contract": { - "type": "contract", - "name": "Reentrancy", - "source_mapping": { - "start": 26, - "length": 2334, - "filename_used": "/home/travis/build/crytic/slither/tests/reentrancy.sol", - "filename_relative": "tests/reentrancy.sol", - "filename_absolute": "/home/travis/build/crytic/slither/tests/reentrancy.sol", - "filename_short": "tests/reentrancy.sol", - "lines": [ - 3, - 4, - 5, - 6, - 7, - 8, - 9, - 10, - 11, - 12, - 13, - 14, - 15, - 16, - 17, - 18, - 19, - 20, - 21, - 22, - 23, - 24, - 25, - 26, - 27, - 28, - 29, - 30, - 31, - 32, - 33, - 34, - 35, - 36, - 37, - 38, - 39, - 40, - 41, - 42, - 43, - 44, - 45, - 46, - 47, - 48, - 49, - 50, - 51, - 52, - 53, - 54, - 55, - 56, - 57, - 58, - 59, - 60, - 61, - 62, - 63, - 64, - 65, - 66, - 67, - 68, - 69, - 70, - 71, - 72 - ], - "starting_column": 1, - "ending_column": 2 - } + "type_specific_fields": { + "parent": { + "type": "contract", + "name": "Reentrancy", + "source_mapping": { + "start": 26, + "length": 2334, + "filename_used": "/home/travis/build/crytic/slither/tests/reentrancy.sol", + "filename_relative": "tests/reentrancy.sol", + "filename_absolute": "/home/travis/build/crytic/slither/tests/reentrancy.sol", + "filename_short": "tests/reentrancy.sol", + "lines": [ + 3, + 4, + 5, + 6, + 7, + 8, + 9, + 10, + 11, + 12, + 13, + 14, + 15, + 16, + 17, + 18, + 19, + 20, + 21, + 22, + 23, + 24, + 25, + 26, + 27, + 28, + 29, + 30, + 31, + 32, + 33, + 34, + 35, + 36, + 37, + 38, + 39, + 40, + 41, + 42, + 43, + 44, + 45, + 46, + 47, + 48, + 49, + 50, + 51, + 52, + 53, + 54, + 55, + 56, + 57, + 58, + 59, + 60, + 61, + 62, + 63, + 64, + 65, + 66, + 67, + 68, + 69, + 70, + 71, + 72 + ], + "starting_column": 1, + "ending_column": 2 + } + }, + "signature": "withdrawBalance()" } - } - }, - { - "type": "node", - "name": "userBalance[msg.sender] = 0", - "source_mapping": { - "start": 579, - "length": 27, - "filename_used": "/home/travis/build/crytic/slither/tests/reentrancy.sol", - "filename_relative": "tests/reentrancy.sol", - "filename_absolute": "/home/travis/build/crytic/slither/tests/reentrancy.sol", - "filename_short": "tests/reentrancy.sol", - "lines": [ - 20 - ], - "starting_column": 9, - "ending_column": 36 - }, - "additional_fields": { - "underlying_type": "variables_written", - "variable_name": "userBalance" }, - "function": { - "type": "function", - "name": "withdrawBalance", + { + "type": "node", + "name": "! (msg.sender.call.value(userBalance[msg.sender])())", "source_mapping": { - "start": 299, - "length": 314, + "start": 478, + "length": 92, "filename_used": "/home/travis/build/crytic/slither/tests/reentrancy.sol", "filename_relative": "tests/reentrancy.sol", "filename_absolute": "/home/travis/build/crytic/slither/tests/reentrancy.sol", "filename_short": "tests/reentrancy.sol", "lines": [ - 14, - 15, - 16, 17, 18, - 19, - 20, - 21 + 19 ], - "starting_column": 5, - "ending_column": 6 + "starting_column": 9, + "ending_column": 10 }, - "contract": { - "type": "contract", - "name": "Reentrancy", - "source_mapping": { - "start": 26, - "length": 2334, - "filename_used": "/home/travis/build/crytic/slither/tests/reentrancy.sol", - "filename_relative": "tests/reentrancy.sol", - "filename_absolute": "/home/travis/build/crytic/slither/tests/reentrancy.sol", - "filename_short": "tests/reentrancy.sol", - "lines": [ - 3, - 4, - 5, - 6, - 7, - 8, - 9, - 10, - 11, - 12, - 13, - 14, - 15, - 16, - 17, - 18, - 19, - 20, - 21, - 22, - 23, - 24, - 25, - 26, - 27, - 28, - 29, - 30, - 31, - 32, - 33, - 34, - 35, - 36, - 37, - 38, - 39, - 40, - 41, - 42, - 43, - 44, - 45, - 46, - 47, - 48, - 49, - 50, - 51, - 52, - 53, - 54, - 55, - 56, - 57, - 58, - 59, - 60, - 61, - 62, - 63, - 64, - 65, - 66, - 67, - 68, - 69, - 70, - 71, - 72 - ], - "starting_column": 1, - "ending_column": 2 + "type_specific_fields": { + "parent": { + "type": "function", + "name": "withdrawBalance", + "source_mapping": { + "start": 299, + "length": 314, + "filename_used": "/home/travis/build/crytic/slither/tests/reentrancy.sol", + "filename_relative": "tests/reentrancy.sol", + "filename_absolute": "/home/travis/build/crytic/slither/tests/reentrancy.sol", + "filename_short": "tests/reentrancy.sol", + "lines": [ + 14, + 15, + 16, + 17, + 18, + 19, + 20, + 21 + ], + "starting_column": 5, + "ending_column": 6 + }, + "type_specific_fields": { + "parent": { + "type": "contract", + "name": "Reentrancy", + "source_mapping": { + "start": 26, + "length": 2334, + "filename_used": "/home/travis/build/crytic/slither/tests/reentrancy.sol", + "filename_relative": "tests/reentrancy.sol", + "filename_absolute": "/home/travis/build/crytic/slither/tests/reentrancy.sol", + "filename_short": "tests/reentrancy.sol", + "lines": [ + 3, + 4, + 5, + 6, + 7, + 8, + 9, + 10, + 11, + 12, + 13, + 14, + 15, + 16, + 17, + 18, + 19, + 20, + 21, + 22, + 23, + 24, + 25, + 26, + 27, + 28, + 29, + 30, + 31, + 32, + 33, + 34, + 35, + 36, + 37, + 38, + 39, + 40, + 41, + 42, + 43, + 44, + 45, + 46, + 47, + 48, + 49, + 50, + 51, + 52, + 53, + 54, + 55, + 56, + 57, + 58, + 59, + 60, + 61, + 62, + 63, + 64, + 65, + 66, + 67, + 68, + 69, + 70, + 71, + 72 + ], + "starting_column": 1, + "ending_column": 2 + } + }, + "signature": "withdrawBalance()" + } } + }, + "additional_fields": { + "underlying_type": "external_calls" } - } - } - ] - }, - { - "check": "reentrancy-eth", - "impact": "High", - "confidence": "Medium", - "description": "Reentrancy in Reentrancy.withdrawBalance_nested (tests/reentrancy.sol#64-70):\n\tExternal calls:\n\t- msg.sender.call.value(amount / 2)() (tests/reentrancy.sol#67)\n\tState variables written after the call(s):\n\t- userBalance (tests/reentrancy.sol#68)\n", - "elements": [ - { - "type": "function", - "name": "withdrawBalance_nested", - "source_mapping": { - "start": 2108, - "length": 246, - "filename_used": "/home/travis/build/crytic/slither/tests/reentrancy.sol", - "filename_relative": "tests/reentrancy.sol", - "filename_absolute": "/home/travis/build/crytic/slither/tests/reentrancy.sol", - "filename_short": "tests/reentrancy.sol", - "lines": [ - 64, - 65, - 66, - 67, - 68, - 69, - 70 - ], - "starting_column": 5, - "ending_column": 6 }, - "contract": { - "type": "contract", - "name": "Reentrancy", + { + "type": "node", + "name": "userBalance[msg.sender] = 0", "source_mapping": { - "start": 26, - "length": 2334, + "start": 579, + "length": 27, "filename_used": "/home/travis/build/crytic/slither/tests/reentrancy.sol", "filename_relative": "tests/reentrancy.sol", "filename_absolute": "/home/travis/build/crytic/slither/tests/reentrancy.sol", "filename_short": "tests/reentrancy.sol", "lines": [ - 3, - 4, - 5, - 6, - 7, - 8, - 9, - 10, - 11, - 12, - 13, - 14, - 15, - 16, - 17, - 18, - 19, - 20, - 21, - 22, - 23, - 24, - 25, - 26, - 27, - 28, - 29, - 30, - 31, - 32, - 33, - 34, - 35, - 36, - 37, - 38, - 39, - 40, - 41, - 42, - 43, - 44, - 45, - 46, - 47, - 48, - 49, - 50, - 51, - 52, - 53, - 54, - 55, - 56, - 57, - 58, - 59, - 60, - 61, - 62, - 63, - 64, - 65, - 66, - 67, - 68, - 69, - 70, - 71, - 72 + 20 ], - "starting_column": 1, - "ending_column": 2 + "starting_column": 9, + "ending_column": 36 + }, + "type_specific_fields": { + "parent": { + "type": "function", + "name": "withdrawBalance", + "source_mapping": { + "start": 299, + "length": 314, + "filename_used": "/home/travis/build/crytic/slither/tests/reentrancy.sol", + "filename_relative": "tests/reentrancy.sol", + "filename_absolute": "/home/travis/build/crytic/slither/tests/reentrancy.sol", + "filename_short": "tests/reentrancy.sol", + "lines": [ + 14, + 15, + 16, + 17, + 18, + 19, + 20, + 21 + ], + "starting_column": 5, + "ending_column": 6 + }, + "type_specific_fields": { + "parent": { + "type": "contract", + "name": "Reentrancy", + "source_mapping": { + "start": 26, + "length": 2334, + "filename_used": "/home/travis/build/crytic/slither/tests/reentrancy.sol", + "filename_relative": "tests/reentrancy.sol", + "filename_absolute": "/home/travis/build/crytic/slither/tests/reentrancy.sol", + "filename_short": "tests/reentrancy.sol", + "lines": [ + 3, + 4, + 5, + 6, + 7, + 8, + 9, + 10, + 11, + 12, + 13, + 14, + 15, + 16, + 17, + 18, + 19, + 20, + 21, + 22, + 23, + 24, + 25, + 26, + 27, + 28, + 29, + 30, + 31, + 32, + 33, + 34, + 35, + 36, + 37, + 38, + 39, + 40, + 41, + 42, + 43, + 44, + 45, + 46, + 47, + 48, + 49, + 50, + 51, + 52, + 53, + 54, + 55, + 56, + 57, + 58, + 59, + 60, + 61, + 62, + 63, + 64, + 65, + 66, + 67, + 68, + 69, + 70, + 71, + 72 + ], + "starting_column": 1, + "ending_column": 2 + } + }, + "signature": "withdrawBalance()" + } + } + }, + "additional_fields": { + "underlying_type": "variables_written", + "variable_name": "userBalance" } } - }, - { - "type": "node", - "name": "msg.sender.call.value(amount / 2)()", - "source_mapping": { - "start": 2263, - "length": 33, - "filename_used": "/home/travis/build/crytic/slither/tests/reentrancy.sol", - "filename_relative": "tests/reentrancy.sol", - "filename_absolute": "/home/travis/build/crytic/slither/tests/reentrancy.sol", - "filename_short": "tests/reentrancy.sol", - "lines": [ - 67 - ], - "starting_column": 13, - "ending_column": 46 - }, - "additional_fields": { - "underlying_type": "external_calls" - }, - "function": { + ] + }, + { + "check": "reentrancy-eth", + "impact": "High", + "confidence": "Medium", + "description": "Reentrancy in Reentrancy.withdrawBalance_nested (tests/reentrancy.sol#64-70):\n\tExternal calls:\n\t- msg.sender.call.value(amount / 2)() (tests/reentrancy.sol#67)\n\tState variables written after the call(s):\n\t- userBalance (tests/reentrancy.sol#68)\n", + "elements": [ + { "type": "function", "name": "withdrawBalance_nested", "source_mapping": { @@ -539,225 +425,367 @@ "starting_column": 5, "ending_column": 6 }, - "contract": { - "type": "contract", - "name": "Reentrancy", - "source_mapping": { - "start": 26, - "length": 2334, - "filename_used": "/home/travis/build/crytic/slither/tests/reentrancy.sol", - "filename_relative": "tests/reentrancy.sol", - "filename_absolute": "/home/travis/build/crytic/slither/tests/reentrancy.sol", - "filename_short": "tests/reentrancy.sol", - "lines": [ - 3, - 4, - 5, - 6, - 7, - 8, - 9, - 10, - 11, - 12, - 13, - 14, - 15, - 16, - 17, - 18, - 19, - 20, - 21, - 22, - 23, - 24, - 25, - 26, - 27, - 28, - 29, - 30, - 31, - 32, - 33, - 34, - 35, - 36, - 37, - 38, - 39, - 40, - 41, - 42, - 43, - 44, - 45, - 46, - 47, - 48, - 49, - 50, - 51, - 52, - 53, - 54, - 55, - 56, - 57, - 58, - 59, - 60, - 61, - 62, - 63, - 64, - 65, - 66, - 67, - 68, - 69, - 70, - 71, - 72 - ], - "starting_column": 1, - "ending_column": 2 - } + "type_specific_fields": { + "parent": { + "type": "contract", + "name": "Reentrancy", + "source_mapping": { + "start": 26, + "length": 2334, + "filename_used": "/home/travis/build/crytic/slither/tests/reentrancy.sol", + "filename_relative": "tests/reentrancy.sol", + "filename_absolute": "/home/travis/build/crytic/slither/tests/reentrancy.sol", + "filename_short": "tests/reentrancy.sol", + "lines": [ + 3, + 4, + 5, + 6, + 7, + 8, + 9, + 10, + 11, + 12, + 13, + 14, + 15, + 16, + 17, + 18, + 19, + 20, + 21, + 22, + 23, + 24, + 25, + 26, + 27, + 28, + 29, + 30, + 31, + 32, + 33, + 34, + 35, + 36, + 37, + 38, + 39, + 40, + 41, + 42, + 43, + 44, + 45, + 46, + 47, + 48, + 49, + 50, + 51, + 52, + 53, + 54, + 55, + 56, + 57, + 58, + 59, + 60, + 61, + 62, + 63, + 64, + 65, + 66, + 67, + 68, + 69, + 70, + 71, + 72 + ], + "starting_column": 1, + "ending_column": 2 + } + }, + "signature": "withdrawBalance_nested()" } - } - }, - { - "type": "node", - "name": "userBalance[msg.sender] = 0", - "source_mapping": { - "start": 2310, - "length": 27, - "filename_used": "/home/travis/build/crytic/slither/tests/reentrancy.sol", - "filename_relative": "tests/reentrancy.sol", - "filename_absolute": "/home/travis/build/crytic/slither/tests/reentrancy.sol", - "filename_short": "tests/reentrancy.sol", - "lines": [ - 68 - ], - "starting_column": 13, - "ending_column": 40 }, - "additional_fields": { - "underlying_type": "variables_written", - "variable_name": "userBalance" + { + "type": "node", + "name": "msg.sender.call.value(amount / 2)()", + "source_mapping": { + "start": 2263, + "length": 33, + "filename_used": "/home/travis/build/crytic/slither/tests/reentrancy.sol", + "filename_relative": "tests/reentrancy.sol", + "filename_absolute": "/home/travis/build/crytic/slither/tests/reentrancy.sol", + "filename_short": "tests/reentrancy.sol", + "lines": [ + 67 + ], + "starting_column": 13, + "ending_column": 46 + }, + "type_specific_fields": { + "parent": { + "type": "function", + "name": "withdrawBalance_nested", + "source_mapping": { + "start": 2108, + "length": 246, + "filename_used": "/home/travis/build/crytic/slither/tests/reentrancy.sol", + "filename_relative": "tests/reentrancy.sol", + "filename_absolute": "/home/travis/build/crytic/slither/tests/reentrancy.sol", + "filename_short": "tests/reentrancy.sol", + "lines": [ + 64, + 65, + 66, + 67, + 68, + 69, + 70 + ], + "starting_column": 5, + "ending_column": 6 + }, + "type_specific_fields": { + "parent": { + "type": "contract", + "name": "Reentrancy", + "source_mapping": { + "start": 26, + "length": 2334, + "filename_used": "/home/travis/build/crytic/slither/tests/reentrancy.sol", + "filename_relative": "tests/reentrancy.sol", + "filename_absolute": "/home/travis/build/crytic/slither/tests/reentrancy.sol", + "filename_short": "tests/reentrancy.sol", + "lines": [ + 3, + 4, + 5, + 6, + 7, + 8, + 9, + 10, + 11, + 12, + 13, + 14, + 15, + 16, + 17, + 18, + 19, + 20, + 21, + 22, + 23, + 24, + 25, + 26, + 27, + 28, + 29, + 30, + 31, + 32, + 33, + 34, + 35, + 36, + 37, + 38, + 39, + 40, + 41, + 42, + 43, + 44, + 45, + 46, + 47, + 48, + 49, + 50, + 51, + 52, + 53, + 54, + 55, + 56, + 57, + 58, + 59, + 60, + 61, + 62, + 63, + 64, + 65, + 66, + 67, + 68, + 69, + 70, + 71, + 72 + ], + "starting_column": 1, + "ending_column": 2 + } + }, + "signature": "withdrawBalance_nested()" + } + } + }, + "additional_fields": { + "underlying_type": "external_calls" + } }, - "function": { - "type": "function", - "name": "withdrawBalance_nested", + { + "type": "node", + "name": "userBalance[msg.sender] = 0", "source_mapping": { - "start": 2108, - "length": 246, + "start": 2310, + "length": 27, "filename_used": "/home/travis/build/crytic/slither/tests/reentrancy.sol", "filename_relative": "tests/reentrancy.sol", "filename_absolute": "/home/travis/build/crytic/slither/tests/reentrancy.sol", "filename_short": "tests/reentrancy.sol", "lines": [ - 64, - 65, - 66, - 67, - 68, - 69, - 70 + 68 ], - "starting_column": 5, - "ending_column": 6 + "starting_column": 13, + "ending_column": 40 }, - "contract": { - "type": "contract", - "name": "Reentrancy", - "source_mapping": { - "start": 26, - "length": 2334, - "filename_used": "/home/travis/build/crytic/slither/tests/reentrancy.sol", - "filename_relative": "tests/reentrancy.sol", - "filename_absolute": "/home/travis/build/crytic/slither/tests/reentrancy.sol", - "filename_short": "tests/reentrancy.sol", - "lines": [ - 3, - 4, - 5, - 6, - 7, - 8, - 9, - 10, - 11, - 12, - 13, - 14, - 15, - 16, - 17, - 18, - 19, - 20, - 21, - 22, - 23, - 24, - 25, - 26, - 27, - 28, - 29, - 30, - 31, - 32, - 33, - 34, - 35, - 36, - 37, - 38, - 39, - 40, - 41, - 42, - 43, - 44, - 45, - 46, - 47, - 48, - 49, - 50, - 51, - 52, - 53, - 54, - 55, - 56, - 57, - 58, - 59, - 60, - 61, - 62, - 63, - 64, - 65, - 66, - 67, - 68, - 69, - 70, - 71, - 72 - ], - "starting_column": 1, - "ending_column": 2 + "type_specific_fields": { + "parent": { + "type": "function", + "name": "withdrawBalance_nested", + "source_mapping": { + "start": 2108, + "length": 246, + "filename_used": "/home/travis/build/crytic/slither/tests/reentrancy.sol", + "filename_relative": "tests/reentrancy.sol", + "filename_absolute": "/home/travis/build/crytic/slither/tests/reentrancy.sol", + "filename_short": "tests/reentrancy.sol", + "lines": [ + 64, + 65, + 66, + 67, + 68, + 69, + 70 + ], + "starting_column": 5, + "ending_column": 6 + }, + "type_specific_fields": { + "parent": { + "type": "contract", + "name": "Reentrancy", + "source_mapping": { + "start": 26, + "length": 2334, + "filename_used": "/home/travis/build/crytic/slither/tests/reentrancy.sol", + "filename_relative": "tests/reentrancy.sol", + "filename_absolute": "/home/travis/build/crytic/slither/tests/reentrancy.sol", + "filename_short": "tests/reentrancy.sol", + "lines": [ + 3, + 4, + 5, + 6, + 7, + 8, + 9, + 10, + 11, + 12, + 13, + 14, + 15, + 16, + 17, + 18, + 19, + 20, + 21, + 22, + 23, + 24, + 25, + 26, + 27, + 28, + 29, + 30, + 31, + 32, + 33, + 34, + 35, + 36, + 37, + 38, + 39, + 40, + 41, + 42, + 43, + 44, + 45, + 46, + 47, + 48, + 49, + 50, + 51, + 52, + 53, + 54, + 55, + 56, + 57, + 58, + 59, + 60, + 61, + 62, + 63, + 64, + 65, + 66, + 67, + 68, + 69, + 70, + 71, + 72 + ], + "starting_column": 1, + "ending_column": 2 + } + }, + "signature": "withdrawBalance_nested()" + } } + }, + "additional_fields": { + "underlying_type": "variables_written", + "variable_name": "userBalance" } } - } - ] - } - ] + ] + } + ] + } } \ No newline at end of file diff --git a/tests/expected_json/right_to_left_override.rtlo.json b/tests/expected_json/right_to_left_override.rtlo.json index 931026f53..adccb6cb2 100644 --- a/tests/expected_json/right_to_left_override.rtlo.json +++ b/tests/expected_json/right_to_left_override.rtlo.json @@ -1,13 +1,15 @@ { "success": true, "error": null, - "results": [ - { - "check": "rtlo", - "impact": "High", - "confidence": "High", - "description": "/home/travis/build/crytic/slither/tests/right_to_left_override.sol contains a unicode right-to-left-override character:\n\t- test1(/*A\u202e/*B*/2 , 1/*\u202d\n", - "elements": [] - } - ] + "results": { + "detectors": [ + { + "check": "rtlo", + "impact": "High", + "confidence": "High", + "description": "/home/travis/build/crytic/slither/tests/right_to_left_override.sol contains a unicode right-to-left-override character:\n\t- test1(/*A\u202e/*B*/2 , 1/*\u202d\n", + "elements": [] + } + ] + } } \ No newline at end of file diff --git a/tests/expected_json/shadowing_abstract.shadowing-abstract.json b/tests/expected_json/shadowing_abstract.shadowing-abstract.json index 207f61e6a..2b51a80cf 100644 --- a/tests/expected_json/shadowing_abstract.shadowing-abstract.json +++ b/tests/expected_json/shadowing_abstract.shadowing-abstract.json @@ -1,88 +1,94 @@ { "success": true, "error": null, - "results": [ - { - "check": "shadowing-abstract", - "impact": "Medium", - "confidence": "High", - "description": "DerivedContract.owner (tests/shadowing_abstract.sol#7) shadows:\n\t- BaseContract.owner (tests/shadowing_abstract.sol#2)\n", - "elements": [ - { - "type": "variable", - "name": "owner", - "source_mapping": { - "start": 92, - "length": 13, - "filename_used": "/home/travis/build/crytic/slither/tests/shadowing_abstract.sol", - "filename_relative": "tests/shadowing_abstract.sol", - "filename_absolute": "/home/travis/build/crytic/slither/tests/shadowing_abstract.sol", - "filename_short": "tests/shadowing_abstract.sol", - "lines": [ - 7 - ], - "starting_column": 5, - "ending_column": 18 - }, - "contract": { - "type": "contract", - "name": "DerivedContract", + "results": { + "detectors": [ + { + "check": "shadowing-abstract", + "impact": "Medium", + "confidence": "High", + "description": "DerivedContract.owner (tests/shadowing_abstract.sol#7) shadows:\n\t- BaseContract.owner (tests/shadowing_abstract.sol#2)\n", + "elements": [ + { + "type": "variable", + "name": "owner", "source_mapping": { - "start": 46, - "length": 63, + "start": 92, + "length": 13, "filename_used": "/home/travis/build/crytic/slither/tests/shadowing_abstract.sol", "filename_relative": "tests/shadowing_abstract.sol", "filename_absolute": "/home/travis/build/crytic/slither/tests/shadowing_abstract.sol", "filename_short": "tests/shadowing_abstract.sol", "lines": [ - 6, - 7, - 8, - 9 + 7 ], - "starting_column": 1, - "ending_column": 2 + "starting_column": 5, + "ending_column": 18 + }, + "type_specific_fields": { + "parent": { + "type": "contract", + "name": "DerivedContract", + "source_mapping": { + "start": 46, + "length": 63, + "filename_used": "/home/travis/build/crytic/slither/tests/shadowing_abstract.sol", + "filename_relative": "tests/shadowing_abstract.sol", + "filename_absolute": "/home/travis/build/crytic/slither/tests/shadowing_abstract.sol", + "filename_short": "tests/shadowing_abstract.sol", + "lines": [ + 6, + 7, + 8, + 9 + ], + "starting_column": 1, + "ending_column": 2 + } + } } - } - }, - { - "type": "variable", - "name": "owner", - "source_mapping": { - "start": 27, - "length": 13, - "filename_used": "/home/travis/build/crytic/slither/tests/shadowing_abstract.sol", - "filename_relative": "tests/shadowing_abstract.sol", - "filename_absolute": "/home/travis/build/crytic/slither/tests/shadowing_abstract.sol", - "filename_short": "tests/shadowing_abstract.sol", - "lines": [ - 2 - ], - "starting_column": 5, - "ending_column": 18 }, - "contract": { - "type": "contract", - "name": "BaseContract", + { + "type": "variable", + "name": "owner", "source_mapping": { - "start": 0, - "length": 44, + "start": 27, + "length": 13, "filename_used": "/home/travis/build/crytic/slither/tests/shadowing_abstract.sol", "filename_relative": "tests/shadowing_abstract.sol", "filename_absolute": "/home/travis/build/crytic/slither/tests/shadowing_abstract.sol", "filename_short": "tests/shadowing_abstract.sol", "lines": [ - 1, - 2, - 3, - 4 + 2 ], - "starting_column": 1, - "ending_column": 2 + "starting_column": 5, + "ending_column": 18 + }, + "type_specific_fields": { + "parent": { + "type": "contract", + "name": "BaseContract", + "source_mapping": { + "start": 0, + "length": 44, + "filename_used": "/home/travis/build/crytic/slither/tests/shadowing_abstract.sol", + "filename_relative": "tests/shadowing_abstract.sol", + "filename_absolute": "/home/travis/build/crytic/slither/tests/shadowing_abstract.sol", + "filename_short": "tests/shadowing_abstract.sol", + "lines": [ + 1, + 2, + 3, + 4 + ], + "starting_column": 1, + "ending_column": 2 + } + } } } - } - ] - } - ] + ] + } + ] + } } \ No newline at end of file diff --git a/tests/expected_json/shadowing_builtin_symbols.shadowing-builtin.json b/tests/expected_json/shadowing_builtin_symbols.shadowing-builtin.json index 4ca841e2f..38562f9df 100644 --- a/tests/expected_json/shadowing_builtin_symbols.shadowing-builtin.json +++ b/tests/expected_json/shadowing_builtin_symbols.shadowing-builtin.json @@ -1,221 +1,163 @@ { "success": true, "error": null, - "results": [ - { - "check": "shadowing-builtin", - "impact": "Low", - "confidence": "High", - "description": "BaseContract.blockhash (state variable @ tests/shadowing_builtin_symbols.sol#4) shadows built-in symbol \"blockhash\"\n", - "elements": [ - { - "type": "variable", - "name": "blockhash", - "source_mapping": { - "start": 54, - "length": 14, - "filename_used": "/home/travis/build/crytic/slither/tests/shadowing_builtin_symbols.sol", - "filename_relative": "tests/shadowing_builtin_symbols.sol", - "filename_absolute": "/home/travis/build/crytic/slither/tests/shadowing_builtin_symbols.sol", - "filename_short": "tests/shadowing_builtin_symbols.sol", - "lines": [ - 4 - ], - "starting_column": 5, - "ending_column": 19 - }, - "contract": { - "type": "contract", - "name": "BaseContract", + "results": { + "detectors": [ + { + "check": "shadowing-builtin", + "impact": "Low", + "confidence": "High", + "description": "BaseContract.blockhash (state variable @ tests/shadowing_builtin_symbols.sol#4) shadows built-in symbol \"blockhash\"\n", + "elements": [ + { + "type": "variable", + "name": "blockhash", "source_mapping": { - "start": 26, - "length": 94, + "start": 54, + "length": 14, "filename_used": "/home/travis/build/crytic/slither/tests/shadowing_builtin_symbols.sol", "filename_relative": "tests/shadowing_builtin_symbols.sol", "filename_absolute": "/home/travis/build/crytic/slither/tests/shadowing_builtin_symbols.sol", "filename_short": "tests/shadowing_builtin_symbols.sol", "lines": [ - 3, - 4, - 5, - 6, - 7, - 8 + 4 ], - "starting_column": 1, - "ending_column": 2 - } - } - } - ] - }, - { - "check": "shadowing-builtin", - "impact": "Low", - "confidence": "High", - "description": "BaseContract.now (state variable @ tests/shadowing_builtin_symbols.sol#5) shadows built-in symbol \"now\"\n", - "elements": [ - { - "type": "variable", - "name": "now", - "source_mapping": { - "start": 74, - "length": 8, - "filename_used": "/home/travis/build/crytic/slither/tests/shadowing_builtin_symbols.sol", - "filename_relative": "tests/shadowing_builtin_symbols.sol", - "filename_absolute": "/home/travis/build/crytic/slither/tests/shadowing_builtin_symbols.sol", - "filename_short": "tests/shadowing_builtin_symbols.sol", - "lines": [ - 5 - ], - "starting_column": 5, - "ending_column": 13 - }, - "contract": { - "type": "contract", - "name": "BaseContract", - "source_mapping": { - "start": 26, - "length": 94, - "filename_used": "/home/travis/build/crytic/slither/tests/shadowing_builtin_symbols.sol", - "filename_relative": "tests/shadowing_builtin_symbols.sol", - "filename_absolute": "/home/travis/build/crytic/slither/tests/shadowing_builtin_symbols.sol", - "filename_short": "tests/shadowing_builtin_symbols.sol", - "lines": [ - 3, - 4, - 5, - 6, - 7, - 8 - ], - "starting_column": 1, - "ending_column": 2 + "starting_column": 5, + "ending_column": 19 + }, + "type_specific_fields": { + "parent": { + "type": "contract", + "name": "BaseContract", + "source_mapping": { + "start": 26, + "length": 94, + "filename_used": "/home/travis/build/crytic/slither/tests/shadowing_builtin_symbols.sol", + "filename_relative": "tests/shadowing_builtin_symbols.sol", + "filename_absolute": "/home/travis/build/crytic/slither/tests/shadowing_builtin_symbols.sol", + "filename_short": "tests/shadowing_builtin_symbols.sol", + "lines": [ + 3, + 4, + 5, + 6, + 7, + 8 + ], + "starting_column": 1, + "ending_column": 2 + } + } } } - } - ] - }, - { - "check": "shadowing-builtin", - "impact": "Low", - "confidence": "High", - "description": "BaseContract.revert (event @ tests/shadowing_builtin_symbols.sol#7) shadows built-in symbol \"revert\"\n", - "elements": [ - { - "type": "event", - "name": "revert", - "source_mapping": { - "start": 89, - "length": 29, - "filename_used": "/home/travis/build/crytic/slither/tests/shadowing_builtin_symbols.sol", - "filename_relative": "tests/shadowing_builtin_symbols.sol", - "filename_absolute": "/home/travis/build/crytic/slither/tests/shadowing_builtin_symbols.sol", - "filename_short": "tests/shadowing_builtin_symbols.sol", - "lines": [ - 7 - ], - "starting_column": 5, - "ending_column": 34 - }, - "contract": { - "type": "contract", - "name": "BaseContract", + ] + }, + { + "check": "shadowing-builtin", + "impact": "Low", + "confidence": "High", + "description": "BaseContract.now (state variable @ tests/shadowing_builtin_symbols.sol#5) shadows built-in symbol \"now\"\n", + "elements": [ + { + "type": "variable", + "name": "now", "source_mapping": { - "start": 26, - "length": 94, + "start": 74, + "length": 8, "filename_used": "/home/travis/build/crytic/slither/tests/shadowing_builtin_symbols.sol", "filename_relative": "tests/shadowing_builtin_symbols.sol", "filename_absolute": "/home/travis/build/crytic/slither/tests/shadowing_builtin_symbols.sol", "filename_short": "tests/shadowing_builtin_symbols.sol", "lines": [ - 3, - 4, - 5, - 6, - 7, - 8 + 5 ], - "starting_column": 1, - "ending_column": 2 + "starting_column": 5, + "ending_column": 13 + }, + "type_specific_fields": { + "parent": { + "type": "contract", + "name": "BaseContract", + "source_mapping": { + "start": 26, + "length": 94, + "filename_used": "/home/travis/build/crytic/slither/tests/shadowing_builtin_symbols.sol", + "filename_relative": "tests/shadowing_builtin_symbols.sol", + "filename_absolute": "/home/travis/build/crytic/slither/tests/shadowing_builtin_symbols.sol", + "filename_short": "tests/shadowing_builtin_symbols.sol", + "lines": [ + 3, + 4, + 5, + 6, + 7, + 8 + ], + "starting_column": 1, + "ending_column": 2 + } + } } } - } - ] - }, - { - "check": "shadowing-builtin", - "impact": "Low", - "confidence": "High", - "description": "ExtendedContract.assert (function @ tests/shadowing_builtin_symbols.sol#13-15) shadows built-in symbol \"assert\"\n", - "elements": [ - { - "type": "function", - "name": "assert", - "source_mapping": { - "start": 195, - "length": 64, - "filename_used": "/home/travis/build/crytic/slither/tests/shadowing_builtin_symbols.sol", - "filename_relative": "tests/shadowing_builtin_symbols.sol", - "filename_absolute": "/home/travis/build/crytic/slither/tests/shadowing_builtin_symbols.sol", - "filename_short": "tests/shadowing_builtin_symbols.sol", - "lines": [ - 13, - 14, - 15 - ], - "starting_column": 5, - "ending_column": 6 - }, - "contract": { - "type": "contract", - "name": "ExtendedContract", + ] + }, + { + "check": "shadowing-builtin", + "impact": "Low", + "confidence": "High", + "description": "BaseContract.revert (event @ tests/shadowing_builtin_symbols.sol#7) shadows built-in symbol \"revert\"\n", + "elements": [ + { + "type": "event", + "name": "revert", "source_mapping": { - "start": 122, - "length": 139, + "start": 89, + "length": 29, "filename_used": "/home/travis/build/crytic/slither/tests/shadowing_builtin_symbols.sol", "filename_relative": "tests/shadowing_builtin_symbols.sol", "filename_absolute": "/home/travis/build/crytic/slither/tests/shadowing_builtin_symbols.sol", "filename_short": "tests/shadowing_builtin_symbols.sol", "lines": [ - 10, - 11, - 12, - 13, - 14, - 15, - 16 + 7 ], - "starting_column": 1, - "ending_column": 2 + "starting_column": 5, + "ending_column": 34 + }, + "type_specific_fields": { + "parent": { + "type": "contract", + "name": "BaseContract", + "source_mapping": { + "start": 26, + "length": 94, + "filename_used": "/home/travis/build/crytic/slither/tests/shadowing_builtin_symbols.sol", + "filename_relative": "tests/shadowing_builtin_symbols.sol", + "filename_absolute": "/home/travis/build/crytic/slither/tests/shadowing_builtin_symbols.sol", + "filename_short": "tests/shadowing_builtin_symbols.sol", + "lines": [ + 3, + 4, + 5, + 6, + 7, + 8 + ], + "starting_column": 1, + "ending_column": 2 + } + }, + "signature": "revert(bool)" } } - } - ] - }, - { - "check": "shadowing-builtin", - "impact": "Low", - "confidence": "High", - "description": "ExtendedContract.assert.msg (local variable @ tests/shadowing_builtin_symbols.sol#14) shadows built-in symbol \"msg\"\n", - "elements": [ - { - "type": "variable", - "name": "msg", - "source_mapping": { - "start": 244, - "length": 8, - "filename_used": "/home/travis/build/crytic/slither/tests/shadowing_builtin_symbols.sol", - "filename_relative": "tests/shadowing_builtin_symbols.sol", - "filename_absolute": "/home/travis/build/crytic/slither/tests/shadowing_builtin_symbols.sol", - "filename_short": "tests/shadowing_builtin_symbols.sol", - "lines": [ - 14 - ], - "starting_column": 9, - "ending_column": 17 - }, - "function": { + ] + }, + { + "check": "shadowing-builtin", + "impact": "Low", + "confidence": "High", + "description": "ExtendedContract.assert (function @ tests/shadowing_builtin_symbols.sol#13-15) shadows built-in symbol \"assert\"\n", + "elements": [ + { "type": "function", "name": "assert", "source_mapping": { @@ -233,162 +175,164 @@ "starting_column": 5, "ending_column": 6 }, - "contract": { - "type": "contract", - "name": "ExtendedContract", - "source_mapping": { - "start": 122, - "length": 139, - "filename_used": "/home/travis/build/crytic/slither/tests/shadowing_builtin_symbols.sol", - "filename_relative": "tests/shadowing_builtin_symbols.sol", - "filename_absolute": "/home/travis/build/crytic/slither/tests/shadowing_builtin_symbols.sol", - "filename_short": "tests/shadowing_builtin_symbols.sol", - "lines": [ - 10, - 11, - 12, - 13, - 14, - 15, - 16 - ], - "starting_column": 1, - "ending_column": 2 - } + "type_specific_fields": { + "parent": { + "type": "contract", + "name": "ExtendedContract", + "source_mapping": { + "start": 122, + "length": 139, + "filename_used": "/home/travis/build/crytic/slither/tests/shadowing_builtin_symbols.sol", + "filename_relative": "tests/shadowing_builtin_symbols.sol", + "filename_absolute": "/home/travis/build/crytic/slither/tests/shadowing_builtin_symbols.sol", + "filename_short": "tests/shadowing_builtin_symbols.sol", + "lines": [ + 10, + 11, + 12, + 13, + 14, + 15, + 16 + ], + "starting_column": 1, + "ending_column": 2 + } + }, + "signature": "assert(bool)" } } - } - ] - }, - { - "check": "shadowing-builtin", - "impact": "Low", - "confidence": "High", - "description": "ExtendedContract.ecrecover (state variable @ tests/shadowing_builtin_symbols.sol#11) shadows built-in symbol \"ecrecover\"\n", - "elements": [ - { - "type": "variable", - "name": "ecrecover", - "source_mapping": { - "start": 170, - "length": 18, - "filename_used": "/home/travis/build/crytic/slither/tests/shadowing_builtin_symbols.sol", - "filename_relative": "tests/shadowing_builtin_symbols.sol", - "filename_absolute": "/home/travis/build/crytic/slither/tests/shadowing_builtin_symbols.sol", - "filename_short": "tests/shadowing_builtin_symbols.sol", - "lines": [ - 11 - ], - "starting_column": 5, - "ending_column": 23 - }, - "contract": { - "type": "contract", - "name": "ExtendedContract", + ] + }, + { + "check": "shadowing-builtin", + "impact": "Low", + "confidence": "High", + "description": "ExtendedContract.assert.msg (local variable @ tests/shadowing_builtin_symbols.sol#14) shadows built-in symbol \"msg\"\n", + "elements": [ + { + "type": "variable", + "name": "msg", "source_mapping": { - "start": 122, - "length": 139, + "start": 244, + "length": 8, "filename_used": "/home/travis/build/crytic/slither/tests/shadowing_builtin_symbols.sol", "filename_relative": "tests/shadowing_builtin_symbols.sol", "filename_absolute": "/home/travis/build/crytic/slither/tests/shadowing_builtin_symbols.sol", "filename_short": "tests/shadowing_builtin_symbols.sol", "lines": [ - 10, - 11, - 12, - 13, - 14, - 15, - 16 + 14 ], - "starting_column": 1, - "ending_column": 2 + "starting_column": 9, + "ending_column": 17 + }, + "type_specific_fields": { + "parent": { + "type": "function", + "name": "assert", + "source_mapping": { + "start": 195, + "length": 64, + "filename_used": "/home/travis/build/crytic/slither/tests/shadowing_builtin_symbols.sol", + "filename_relative": "tests/shadowing_builtin_symbols.sol", + "filename_absolute": "/home/travis/build/crytic/slither/tests/shadowing_builtin_symbols.sol", + "filename_short": "tests/shadowing_builtin_symbols.sol", + "lines": [ + 13, + 14, + 15 + ], + "starting_column": 5, + "ending_column": 6 + }, + "type_specific_fields": { + "parent": { + "type": "contract", + "name": "ExtendedContract", + "source_mapping": { + "start": 122, + "length": 139, + "filename_used": "/home/travis/build/crytic/slither/tests/shadowing_builtin_symbols.sol", + "filename_relative": "tests/shadowing_builtin_symbols.sol", + "filename_absolute": "/home/travis/build/crytic/slither/tests/shadowing_builtin_symbols.sol", + "filename_short": "tests/shadowing_builtin_symbols.sol", + "lines": [ + 10, + 11, + 12, + 13, + 14, + 15, + 16 + ], + "starting_column": 1, + "ending_column": 2 + } + }, + "signature": "assert(bool)" + } + } } } - } - ] - }, - { - "check": "shadowing-builtin", - "impact": "Low", - "confidence": "High", - "description": "FurtherExtendedContract.require (modifier @ tests/shadowing_builtin_symbols.sol#23-28) shadows built-in symbol \"require\"\n", - "elements": [ - { - "type": "function", - "name": "require", - "source_mapping": { - "start": 380, - "length": 120, - "filename_used": "/home/travis/build/crytic/slither/tests/shadowing_builtin_symbols.sol", - "filename_relative": "tests/shadowing_builtin_symbols.sol", - "filename_absolute": "/home/travis/build/crytic/slither/tests/shadowing_builtin_symbols.sol", - "filename_short": "tests/shadowing_builtin_symbols.sol", - "lines": [ - 23, - 24, - 25, - 26, - 27, - 28 - ], - "starting_column": 5, - "ending_column": 6 - }, - "contract": { - "type": "contract", - "name": "FurtherExtendedContract", + ] + }, + { + "check": "shadowing-builtin", + "impact": "Low", + "confidence": "High", + "description": "ExtendedContract.ecrecover (state variable @ tests/shadowing_builtin_symbols.sol#11) shadows built-in symbol \"ecrecover\"\n", + "elements": [ + { + "type": "variable", + "name": "ecrecover", "source_mapping": { - "start": 263, - "length": 239, + "start": 170, + "length": 18, "filename_used": "/home/travis/build/crytic/slither/tests/shadowing_builtin_symbols.sol", "filename_relative": "tests/shadowing_builtin_symbols.sol", "filename_absolute": "/home/travis/build/crytic/slither/tests/shadowing_builtin_symbols.sol", "filename_short": "tests/shadowing_builtin_symbols.sol", "lines": [ - 18, - 19, - 20, - 21, - 22, - 23, - 24, - 25, - 26, - 27, - 28, - 29 + 11 ], - "starting_column": 1, - "ending_column": 2 + "starting_column": 5, + "ending_column": 23 + }, + "type_specific_fields": { + "parent": { + "type": "contract", + "name": "ExtendedContract", + "source_mapping": { + "start": 122, + "length": 139, + "filename_used": "/home/travis/build/crytic/slither/tests/shadowing_builtin_symbols.sol", + "filename_relative": "tests/shadowing_builtin_symbols.sol", + "filename_absolute": "/home/travis/build/crytic/slither/tests/shadowing_builtin_symbols.sol", + "filename_short": "tests/shadowing_builtin_symbols.sol", + "lines": [ + 10, + 11, + 12, + 13, + 14, + 15, + 16 + ], + "starting_column": 1, + "ending_column": 2 + } + } } } - } - ] - }, - { - "check": "shadowing-builtin", - "impact": "Low", - "confidence": "High", - "description": "FurtherExtendedContract.require.keccak256 (local variable @ tests/shadowing_builtin_symbols.sol#25) shadows built-in symbol \"keccak256\"\n", - "elements": [ - { - "type": "variable", - "name": "keccak256", - "source_mapping": { - "start": 449, - "length": 14, - "filename_used": "/home/travis/build/crytic/slither/tests/shadowing_builtin_symbols.sol", - "filename_relative": "tests/shadowing_builtin_symbols.sol", - "filename_absolute": "/home/travis/build/crytic/slither/tests/shadowing_builtin_symbols.sol", - "filename_short": "tests/shadowing_builtin_symbols.sol", - "lines": [ - 25 - ], - "starting_column": 9, - "ending_column": 23 - }, - "function": { + ] + }, + { + "check": "shadowing-builtin", + "impact": "Low", + "confidence": "High", + "description": "FurtherExtendedContract.require (modifier @ tests/shadowing_builtin_symbols.sol#23-28) shadows built-in symbol \"require\"\n", + "elements": [ + { "type": "function", "name": "require", "source_mapping": { @@ -409,316 +353,412 @@ "starting_column": 5, "ending_column": 6 }, - "contract": { - "type": "contract", - "name": "FurtherExtendedContract", - "source_mapping": { - "start": 263, - "length": 239, - "filename_used": "/home/travis/build/crytic/slither/tests/shadowing_builtin_symbols.sol", - "filename_relative": "tests/shadowing_builtin_symbols.sol", - "filename_absolute": "/home/travis/build/crytic/slither/tests/shadowing_builtin_symbols.sol", - "filename_short": "tests/shadowing_builtin_symbols.sol", - "lines": [ - 18, - 19, - 20, - 21, - 22, - 23, - 24, - 25, - 26, - 27, - 28, - 29 - ], - "starting_column": 1, - "ending_column": 2 + "type_specific_fields": { + "parent": { + "type": "contract", + "name": "FurtherExtendedContract", + "source_mapping": { + "start": 263, + "length": 239, + "filename_used": "/home/travis/build/crytic/slither/tests/shadowing_builtin_symbols.sol", + "filename_relative": "tests/shadowing_builtin_symbols.sol", + "filename_absolute": "/home/travis/build/crytic/slither/tests/shadowing_builtin_symbols.sol", + "filename_short": "tests/shadowing_builtin_symbols.sol", + "lines": [ + 18, + 19, + 20, + 21, + 22, + 23, + 24, + 25, + 26, + 27, + 28, + 29 + ], + "starting_column": 1, + "ending_column": 2 + } + }, + "signature": "require()" + } + } + ] + }, + { + "check": "shadowing-builtin", + "impact": "Low", + "confidence": "High", + "description": "FurtherExtendedContract.require.keccak256 (local variable @ tests/shadowing_builtin_symbols.sol#25) shadows built-in symbol \"keccak256\"\n", + "elements": [ + { + "type": "variable", + "name": "keccak256", + "source_mapping": { + "start": 449, + "length": 14, + "filename_used": "/home/travis/build/crytic/slither/tests/shadowing_builtin_symbols.sol", + "filename_relative": "tests/shadowing_builtin_symbols.sol", + "filename_absolute": "/home/travis/build/crytic/slither/tests/shadowing_builtin_symbols.sol", + "filename_short": "tests/shadowing_builtin_symbols.sol", + "lines": [ + 25 + ], + "starting_column": 9, + "ending_column": 23 + }, + "type_specific_fields": { + "parent": { + "type": "function", + "name": "require", + "source_mapping": { + "start": 380, + "length": 120, + "filename_used": "/home/travis/build/crytic/slither/tests/shadowing_builtin_symbols.sol", + "filename_relative": "tests/shadowing_builtin_symbols.sol", + "filename_absolute": "/home/travis/build/crytic/slither/tests/shadowing_builtin_symbols.sol", + "filename_short": "tests/shadowing_builtin_symbols.sol", + "lines": [ + 23, + 24, + 25, + 26, + 27, + 28 + ], + "starting_column": 5, + "ending_column": 6 + }, + "type_specific_fields": { + "parent": { + "type": "contract", + "name": "FurtherExtendedContract", + "source_mapping": { + "start": 263, + "length": 239, + "filename_used": "/home/travis/build/crytic/slither/tests/shadowing_builtin_symbols.sol", + "filename_relative": "tests/shadowing_builtin_symbols.sol", + "filename_absolute": "/home/travis/build/crytic/slither/tests/shadowing_builtin_symbols.sol", + "filename_short": "tests/shadowing_builtin_symbols.sol", + "lines": [ + 18, + 19, + 20, + 21, + 22, + 23, + 24, + 25, + 26, + 27, + 28, + 29 + ], + "starting_column": 1, + "ending_column": 2 + } + }, + "signature": "require()" + } } } } - } - ] - }, - { - "check": "shadowing-builtin", - "impact": "Low", - "confidence": "High", - "description": "FurtherExtendedContract.require.sha3 (local variable @ tests/shadowing_builtin_symbols.sol#26) shadows built-in symbol \"sha3\"\n", - "elements": [ - { - "type": "variable", - "name": "sha3", - "source_mapping": { - "start": 473, - "length": 9, - "filename_used": "/home/travis/build/crytic/slither/tests/shadowing_builtin_symbols.sol", - "filename_relative": "tests/shadowing_builtin_symbols.sol", - "filename_absolute": "/home/travis/build/crytic/slither/tests/shadowing_builtin_symbols.sol", - "filename_short": "tests/shadowing_builtin_symbols.sol", - "lines": [ - 26 - ], - "starting_column": 9, - "ending_column": 18 - }, - "function": { - "type": "function", - "name": "require", + ] + }, + { + "check": "shadowing-builtin", + "impact": "Low", + "confidence": "High", + "description": "FurtherExtendedContract.require.sha3 (local variable @ tests/shadowing_builtin_symbols.sol#26) shadows built-in symbol \"sha3\"\n", + "elements": [ + { + "type": "variable", + "name": "sha3", "source_mapping": { - "start": 380, - "length": 120, + "start": 473, + "length": 9, "filename_used": "/home/travis/build/crytic/slither/tests/shadowing_builtin_symbols.sol", "filename_relative": "tests/shadowing_builtin_symbols.sol", "filename_absolute": "/home/travis/build/crytic/slither/tests/shadowing_builtin_symbols.sol", "filename_short": "tests/shadowing_builtin_symbols.sol", "lines": [ - 23, - 24, - 25, - 26, - 27, - 28 + 26 ], - "starting_column": 5, - "ending_column": 6 + "starting_column": 9, + "ending_column": 18 }, - "contract": { - "type": "contract", - "name": "FurtherExtendedContract", - "source_mapping": { - "start": 263, - "length": 239, - "filename_used": "/home/travis/build/crytic/slither/tests/shadowing_builtin_symbols.sol", - "filename_relative": "tests/shadowing_builtin_symbols.sol", - "filename_absolute": "/home/travis/build/crytic/slither/tests/shadowing_builtin_symbols.sol", - "filename_short": "tests/shadowing_builtin_symbols.sol", - "lines": [ - 18, - 19, - 20, - 21, - 22, - 23, - 24, - 25, - 26, - 27, - 28, - 29 - ], - "starting_column": 1, - "ending_column": 2 + "type_specific_fields": { + "parent": { + "type": "function", + "name": "require", + "source_mapping": { + "start": 380, + "length": 120, + "filename_used": "/home/travis/build/crytic/slither/tests/shadowing_builtin_symbols.sol", + "filename_relative": "tests/shadowing_builtin_symbols.sol", + "filename_absolute": "/home/travis/build/crytic/slither/tests/shadowing_builtin_symbols.sol", + "filename_short": "tests/shadowing_builtin_symbols.sol", + "lines": [ + 23, + 24, + 25, + 26, + 27, + 28 + ], + "starting_column": 5, + "ending_column": 6 + }, + "type_specific_fields": { + "parent": { + "type": "contract", + "name": "FurtherExtendedContract", + "source_mapping": { + "start": 263, + "length": 239, + "filename_used": "/home/travis/build/crytic/slither/tests/shadowing_builtin_symbols.sol", + "filename_relative": "tests/shadowing_builtin_symbols.sol", + "filename_absolute": "/home/travis/build/crytic/slither/tests/shadowing_builtin_symbols.sol", + "filename_short": "tests/shadowing_builtin_symbols.sol", + "lines": [ + 18, + 19, + 20, + 21, + 22, + 23, + 24, + 25, + 26, + 27, + 28, + 29 + ], + "starting_column": 1, + "ending_column": 2 + } + }, + "signature": "require()" + } } } } - } - ] - }, - { - "check": "shadowing-builtin", - "impact": "Low", - "confidence": "High", - "description": "FurtherExtendedContract.blockhash (state variable @ tests/shadowing_builtin_symbols.sol#19) shadows built-in symbol \"blockhash\"\n", - "elements": [ - { - "type": "variable", - "name": "blockhash", - "source_mapping": { - "start": 322, - "length": 18, - "filename_used": "/home/travis/build/crytic/slither/tests/shadowing_builtin_symbols.sol", - "filename_relative": "tests/shadowing_builtin_symbols.sol", - "filename_absolute": "/home/travis/build/crytic/slither/tests/shadowing_builtin_symbols.sol", - "filename_short": "tests/shadowing_builtin_symbols.sol", - "lines": [ - 19 - ], - "starting_column": 5, - "ending_column": 23 - }, - "contract": { - "type": "contract", - "name": "FurtherExtendedContract", + ] + }, + { + "check": "shadowing-builtin", + "impact": "Low", + "confidence": "High", + "description": "FurtherExtendedContract.blockhash (state variable @ tests/shadowing_builtin_symbols.sol#19) shadows built-in symbol \"blockhash\"\n", + "elements": [ + { + "type": "variable", + "name": "blockhash", "source_mapping": { - "start": 263, - "length": 239, + "start": 322, + "length": 18, "filename_used": "/home/travis/build/crytic/slither/tests/shadowing_builtin_symbols.sol", "filename_relative": "tests/shadowing_builtin_symbols.sol", "filename_absolute": "/home/travis/build/crytic/slither/tests/shadowing_builtin_symbols.sol", "filename_short": "tests/shadowing_builtin_symbols.sol", "lines": [ - 18, - 19, - 20, - 21, - 22, - 23, - 24, - 25, - 26, - 27, - 28, - 29 + 19 ], - "starting_column": 1, - "ending_column": 2 + "starting_column": 5, + "ending_column": 23 + }, + "type_specific_fields": { + "parent": { + "type": "contract", + "name": "FurtherExtendedContract", + "source_mapping": { + "start": 263, + "length": 239, + "filename_used": "/home/travis/build/crytic/slither/tests/shadowing_builtin_symbols.sol", + "filename_relative": "tests/shadowing_builtin_symbols.sol", + "filename_absolute": "/home/travis/build/crytic/slither/tests/shadowing_builtin_symbols.sol", + "filename_short": "tests/shadowing_builtin_symbols.sol", + "lines": [ + 18, + 19, + 20, + 21, + 22, + 23, + 24, + 25, + 26, + 27, + 28, + 29 + ], + "starting_column": 1, + "ending_column": 2 + } + } } } - } - ] - }, - { - "check": "shadowing-builtin", - "impact": "Low", - "confidence": "High", - "description": "FurtherExtendedContract.this (state variable @ tests/shadowing_builtin_symbols.sol#20) shadows built-in symbol \"this\"\n", - "elements": [ - { - "type": "variable", - "name": "this", - "source_mapping": { - "start": 346, - "length": 13, - "filename_used": "/home/travis/build/crytic/slither/tests/shadowing_builtin_symbols.sol", - "filename_relative": "tests/shadowing_builtin_symbols.sol", - "filename_absolute": "/home/travis/build/crytic/slither/tests/shadowing_builtin_symbols.sol", - "filename_short": "tests/shadowing_builtin_symbols.sol", - "lines": [ - 20 - ], - "starting_column": 5, - "ending_column": 18 - }, - "contract": { - "type": "contract", - "name": "FurtherExtendedContract", + ] + }, + { + "check": "shadowing-builtin", + "impact": "Low", + "confidence": "High", + "description": "FurtherExtendedContract.this (state variable @ tests/shadowing_builtin_symbols.sol#20) shadows built-in symbol \"this\"\n", + "elements": [ + { + "type": "variable", + "name": "this", "source_mapping": { - "start": 263, - "length": 239, + "start": 346, + "length": 13, "filename_used": "/home/travis/build/crytic/slither/tests/shadowing_builtin_symbols.sol", "filename_relative": "tests/shadowing_builtin_symbols.sol", "filename_absolute": "/home/travis/build/crytic/slither/tests/shadowing_builtin_symbols.sol", "filename_short": "tests/shadowing_builtin_symbols.sol", "lines": [ - 18, - 19, - 20, - 21, - 22, - 23, - 24, - 25, - 26, - 27, - 28, - 29 + 20 ], - "starting_column": 1, - "ending_column": 2 + "starting_column": 5, + "ending_column": 18 + }, + "type_specific_fields": { + "parent": { + "type": "contract", + "name": "FurtherExtendedContract", + "source_mapping": { + "start": 263, + "length": 239, + "filename_used": "/home/travis/build/crytic/slither/tests/shadowing_builtin_symbols.sol", + "filename_relative": "tests/shadowing_builtin_symbols.sol", + "filename_absolute": "/home/travis/build/crytic/slither/tests/shadowing_builtin_symbols.sol", + "filename_short": "tests/shadowing_builtin_symbols.sol", + "lines": [ + 18, + 19, + 20, + 21, + 22, + 23, + 24, + 25, + 26, + 27, + 28, + 29 + ], + "starting_column": 1, + "ending_column": 2 + } + } } } - } - ] - }, - { - "check": "shadowing-builtin", - "impact": "Low", - "confidence": "High", - "description": "FurtherExtendedContract.abi (state variable @ tests/shadowing_builtin_symbols.sol#21) shadows built-in symbol \"abi\"\n", - "elements": [ - { - "type": "variable", - "name": "abi", - "source_mapping": { - "start": 365, - "length": 8, - "filename_used": "/home/travis/build/crytic/slither/tests/shadowing_builtin_symbols.sol", - "filename_relative": "tests/shadowing_builtin_symbols.sol", - "filename_absolute": "/home/travis/build/crytic/slither/tests/shadowing_builtin_symbols.sol", - "filename_short": "tests/shadowing_builtin_symbols.sol", - "lines": [ - 21 - ], - "starting_column": 5, - "ending_column": 13 - }, - "contract": { - "type": "contract", - "name": "FurtherExtendedContract", + ] + }, + { + "check": "shadowing-builtin", + "impact": "Low", + "confidence": "High", + "description": "FurtherExtendedContract.abi (state variable @ tests/shadowing_builtin_symbols.sol#21) shadows built-in symbol \"abi\"\n", + "elements": [ + { + "type": "variable", + "name": "abi", "source_mapping": { - "start": 263, - "length": 239, + "start": 365, + "length": 8, "filename_used": "/home/travis/build/crytic/slither/tests/shadowing_builtin_symbols.sol", "filename_relative": "tests/shadowing_builtin_symbols.sol", "filename_absolute": "/home/travis/build/crytic/slither/tests/shadowing_builtin_symbols.sol", "filename_short": "tests/shadowing_builtin_symbols.sol", "lines": [ - 18, - 19, - 20, - 21, - 22, - 23, - 24, - 25, - 26, - 27, - 28, - 29 + 21 ], - "starting_column": 1, - "ending_column": 2 + "starting_column": 5, + "ending_column": 13 + }, + "type_specific_fields": { + "parent": { + "type": "contract", + "name": "FurtherExtendedContract", + "source_mapping": { + "start": 263, + "length": 239, + "filename_used": "/home/travis/build/crytic/slither/tests/shadowing_builtin_symbols.sol", + "filename_relative": "tests/shadowing_builtin_symbols.sol", + "filename_absolute": "/home/travis/build/crytic/slither/tests/shadowing_builtin_symbols.sol", + "filename_short": "tests/shadowing_builtin_symbols.sol", + "lines": [ + 18, + 19, + 20, + 21, + 22, + 23, + 24, + 25, + 26, + 27, + 28, + 29 + ], + "starting_column": 1, + "ending_column": 2 + } + } } } - } - ] - }, - { - "check": "shadowing-builtin", - "impact": "Low", - "confidence": "High", - "description": "Reserved.mutable (state variable @ tests/shadowing_builtin_symbols.sol#32) shadows built-in symbol \"mutable\"\n", - "elements": [ - { - "type": "variable", - "name": "mutable", - "source_mapping": { - "start": 527, - "length": 15, - "filename_used": "/home/travis/build/crytic/slither/tests/shadowing_builtin_symbols.sol", - "filename_relative": "tests/shadowing_builtin_symbols.sol", - "filename_absolute": "/home/travis/build/crytic/slither/tests/shadowing_builtin_symbols.sol", - "filename_short": "tests/shadowing_builtin_symbols.sol", - "lines": [ - 32 - ], - "starting_column": 5, - "ending_column": 20 - }, - "contract": { - "type": "contract", - "name": "Reserved", + ] + }, + { + "check": "shadowing-builtin", + "impact": "Low", + "confidence": "High", + "description": "Reserved.mutable (state variable @ tests/shadowing_builtin_symbols.sol#32) shadows built-in symbol \"mutable\"\n", + "elements": [ + { + "type": "variable", + "name": "mutable", "source_mapping": { - "start": 504, - "length": 42, + "start": 527, + "length": 15, "filename_used": "/home/travis/build/crytic/slither/tests/shadowing_builtin_symbols.sol", "filename_relative": "tests/shadowing_builtin_symbols.sol", "filename_absolute": "/home/travis/build/crytic/slither/tests/shadowing_builtin_symbols.sol", "filename_short": "tests/shadowing_builtin_symbols.sol", "lines": [ - 31, - 32, - 33, - 34 + 32 ], - "starting_column": 1, - "ending_column": 2 + "starting_column": 5, + "ending_column": 20 + }, + "type_specific_fields": { + "parent": { + "type": "contract", + "name": "Reserved", + "source_mapping": { + "start": 504, + "length": 42, + "filename_used": "/home/travis/build/crytic/slither/tests/shadowing_builtin_symbols.sol", + "filename_relative": "tests/shadowing_builtin_symbols.sol", + "filename_absolute": "/home/travis/build/crytic/slither/tests/shadowing_builtin_symbols.sol", + "filename_short": "tests/shadowing_builtin_symbols.sol", + "lines": [ + 31, + 32, + 33, + 34 + ], + "starting_column": 1, + "ending_column": 2 + } + } } } - } - ] - } - ] + ] + } + ] + } } \ No newline at end of file diff --git a/tests/expected_json/shadowing_local_variable.shadowing-local.json b/tests/expected_json/shadowing_local_variable.shadowing-local.json index 8f1586cb9..bfec04807 100644 --- a/tests/expected_json/shadowing_local_variable.shadowing-local.json +++ b/tests/expected_json/shadowing_local_variable.shadowing-local.json @@ -1,35 +1,20 @@ { "success": true, "error": null, - "results": [ - { - "check": "shadowing-local", - "impact": "Low", - "confidence": "High", - "description": "FurtherExtendedContract.shadowingParent.x (local variable @ tests/shadowing_local_variable.sol#25) shadows:\n\t- FurtherExtendedContract.x (state variable @ tests/shadowing_local_variable.sol#17)\n\t- ExtendedContract.x (state variable @ tests/shadowing_local_variable.sol#9)\n\t- BaseContract.x (state variable @ tests/shadowing_local_variable.sol#4)\n", - "elements": [ - { - "type": "variable", - "name": "x", - "source_mapping": { - "start": 376, - "length": 6, - "filename_used": "/home/travis/build/crytic/slither/tests/shadowing_local_variable.sol", - "filename_relative": "tests/shadowing_local_variable.sol", - "filename_absolute": "/home/travis/build/crytic/slither/tests/shadowing_local_variable.sol", - "filename_short": "tests/shadowing_local_variable.sol", - "lines": [ - 25 - ], - "starting_column": 30, - "ending_column": 36 - }, - "function": { - "type": "function", - "name": "shadowingParent", + "results": { + "detectors": [ + { + "check": "shadowing-local", + "impact": "Low", + "confidence": "High", + "description": "FurtherExtendedContract.shadowingParent.x (local variable @ tests/shadowing_local_variable.sol#25) shadows:\n\t- FurtherExtendedContract.x (state variable @ tests/shadowing_local_variable.sol#17)\n\t- ExtendedContract.x (state variable @ tests/shadowing_local_variable.sol#9)\n\t- BaseContract.x (state variable @ tests/shadowing_local_variable.sol#4)\n", + "elements": [ + { + "type": "variable", + "name": "x", "source_mapping": { - "start": 351, - "length": 79, + "start": 376, + "length": 6, "filename_used": "/home/travis/build/crytic/slither/tests/shadowing_local_variable.sol", "filename_relative": "tests/shadowing_local_variable.sol", "filename_absolute": "/home/travis/build/crytic/slither/tests/shadowing_local_variable.sol", @@ -37,189 +22,200 @@ "lines": [ 25 ], - "starting_column": 5, - "ending_column": 84 + "starting_column": 30, + "ending_column": 36 }, - "contract": { - "type": "contract", - "name": "FurtherExtendedContract", - "source_mapping": { - "start": 197, - "length": 235, - "filename_used": "/home/travis/build/crytic/slither/tests/shadowing_local_variable.sol", - "filename_relative": "tests/shadowing_local_variable.sol", - "filename_absolute": "/home/travis/build/crytic/slither/tests/shadowing_local_variable.sol", - "filename_short": "tests/shadowing_local_variable.sol", - "lines": [ - 16, - 17, - 18, - 19, - 20, - 21, - 22, - 23, - 24, - 25, - 26 - ], - "starting_column": 1, - "ending_column": 2 + "type_specific_fields": { + "parent": { + "type": "function", + "name": "shadowingParent", + "source_mapping": { + "start": 351, + "length": 79, + "filename_used": "/home/travis/build/crytic/slither/tests/shadowing_local_variable.sol", + "filename_relative": "tests/shadowing_local_variable.sol", + "filename_absolute": "/home/travis/build/crytic/slither/tests/shadowing_local_variable.sol", + "filename_short": "tests/shadowing_local_variable.sol", + "lines": [ + 25 + ], + "starting_column": 5, + "ending_column": 84 + }, + "type_specific_fields": { + "parent": { + "type": "contract", + "name": "FurtherExtendedContract", + "source_mapping": { + "start": 197, + "length": 235, + "filename_used": "/home/travis/build/crytic/slither/tests/shadowing_local_variable.sol", + "filename_relative": "tests/shadowing_local_variable.sol", + "filename_absolute": "/home/travis/build/crytic/slither/tests/shadowing_local_variable.sol", + "filename_short": "tests/shadowing_local_variable.sol", + "lines": [ + 16, + 17, + 18, + 19, + 20, + 21, + 22, + 23, + 24, + 25, + 26 + ], + "starting_column": 1, + "ending_column": 2 + } + }, + "signature": "shadowingParent(uint256)" + } } } - } - }, - { - "type": "variable", - "name": "x", - "source_mapping": { - "start": 256, - "length": 10, - "filename_used": "/home/travis/build/crytic/slither/tests/shadowing_local_variable.sol", - "filename_relative": "tests/shadowing_local_variable.sol", - "filename_absolute": "/home/travis/build/crytic/slither/tests/shadowing_local_variable.sol", - "filename_short": "tests/shadowing_local_variable.sol", - "lines": [ - 17 - ], - "starting_column": 5, - "ending_column": 15 }, - "contract": { - "type": "contract", - "name": "FurtherExtendedContract", + { + "type": "variable", + "name": "x", "source_mapping": { - "start": 197, - "length": 235, + "start": 256, + "length": 10, "filename_used": "/home/travis/build/crytic/slither/tests/shadowing_local_variable.sol", "filename_relative": "tests/shadowing_local_variable.sol", "filename_absolute": "/home/travis/build/crytic/slither/tests/shadowing_local_variable.sol", "filename_short": "tests/shadowing_local_variable.sol", "lines": [ - 16, - 17, - 18, - 19, - 20, - 21, - 22, - 23, - 24, - 25, - 26 + 17 ], - "starting_column": 1, - "ending_column": 2 + "starting_column": 5, + "ending_column": 15 + }, + "type_specific_fields": { + "parent": { + "type": "contract", + "name": "FurtherExtendedContract", + "source_mapping": { + "start": 197, + "length": 235, + "filename_used": "/home/travis/build/crytic/slither/tests/shadowing_local_variable.sol", + "filename_relative": "tests/shadowing_local_variable.sol", + "filename_absolute": "/home/travis/build/crytic/slither/tests/shadowing_local_variable.sol", + "filename_short": "tests/shadowing_local_variable.sol", + "lines": [ + 16, + 17, + 18, + 19, + 20, + 21, + 22, + 23, + 24, + 25, + 26 + ], + "starting_column": 1, + "ending_column": 2 + } + } } - } - }, - { - "type": "variable", - "name": "x", - "source_mapping": { - "start": 133, - "length": 10, - "filename_used": "/home/travis/build/crytic/slither/tests/shadowing_local_variable.sol", - "filename_relative": "tests/shadowing_local_variable.sol", - "filename_absolute": "/home/travis/build/crytic/slither/tests/shadowing_local_variable.sol", - "filename_short": "tests/shadowing_local_variable.sol", - "lines": [ - 9 - ], - "starting_column": 5, - "ending_column": 15 }, - "contract": { - "type": "contract", - "name": "ExtendedContract", + { + "type": "variable", + "name": "x", "source_mapping": { - "start": 85, - "length": 110, + "start": 133, + "length": 10, "filename_used": "/home/travis/build/crytic/slither/tests/shadowing_local_variable.sol", "filename_relative": "tests/shadowing_local_variable.sol", "filename_absolute": "/home/travis/build/crytic/slither/tests/shadowing_local_variable.sol", "filename_short": "tests/shadowing_local_variable.sol", "lines": [ - 8, - 9, - 10, - 11, - 12, - 13, - 14 + 9 ], - "starting_column": 1, - "ending_column": 2 + "starting_column": 5, + "ending_column": 15 + }, + "type_specific_fields": { + "parent": { + "type": "contract", + "name": "ExtendedContract", + "source_mapping": { + "start": 85, + "length": 110, + "filename_used": "/home/travis/build/crytic/slither/tests/shadowing_local_variable.sol", + "filename_relative": "tests/shadowing_local_variable.sol", + "filename_absolute": "/home/travis/build/crytic/slither/tests/shadowing_local_variable.sol", + "filename_short": "tests/shadowing_local_variable.sol", + "lines": [ + 8, + 9, + 10, + 11, + 12, + 13, + 14 + ], + "starting_column": 1, + "ending_column": 2 + } + } } - } - }, - { - "type": "variable", - "name": "x", - "source_mapping": { - "start": 54, - "length": 10, - "filename_used": "/home/travis/build/crytic/slither/tests/shadowing_local_variable.sol", - "filename_relative": "tests/shadowing_local_variable.sol", - "filename_absolute": "/home/travis/build/crytic/slither/tests/shadowing_local_variable.sol", - "filename_short": "tests/shadowing_local_variable.sol", - "lines": [ - 4 - ], - "starting_column": 5, - "ending_column": 15 }, - "contract": { - "type": "contract", - "name": "BaseContract", + { + "type": "variable", + "name": "x", "source_mapping": { - "start": 26, - "length": 57, + "start": 54, + "length": 10, "filename_used": "/home/travis/build/crytic/slither/tests/shadowing_local_variable.sol", "filename_relative": "tests/shadowing_local_variable.sol", "filename_absolute": "/home/travis/build/crytic/slither/tests/shadowing_local_variable.sol", "filename_short": "tests/shadowing_local_variable.sol", "lines": [ - 3, - 4, - 5, - 6 + 4 ], - "starting_column": 1, - "ending_column": 2 + "starting_column": 5, + "ending_column": 15 + }, + "type_specific_fields": { + "parent": { + "type": "contract", + "name": "BaseContract", + "source_mapping": { + "start": 26, + "length": 57, + "filename_used": "/home/travis/build/crytic/slither/tests/shadowing_local_variable.sol", + "filename_relative": "tests/shadowing_local_variable.sol", + "filename_absolute": "/home/travis/build/crytic/slither/tests/shadowing_local_variable.sol", + "filename_short": "tests/shadowing_local_variable.sol", + "lines": [ + 3, + 4, + 5, + 6 + ], + "starting_column": 1, + "ending_column": 2 + } + } } } - } - ] - }, - { - "check": "shadowing-local", - "impact": "Low", - "confidence": "High", - "description": "FurtherExtendedContract.shadowingParent.y (local variable @ tests/shadowing_local_variable.sol#25) shadows:\n\t- BaseContract.y (state variable @ tests/shadowing_local_variable.sol#5)\n", - "elements": [ - { - "type": "variable", - "name": "y", - "source_mapping": { - "start": 398, - "length": 5, - "filename_used": "/home/travis/build/crytic/slither/tests/shadowing_local_variable.sol", - "filename_relative": "tests/shadowing_local_variable.sol", - "filename_absolute": "/home/travis/build/crytic/slither/tests/shadowing_local_variable.sol", - "filename_short": "tests/shadowing_local_variable.sol", - "lines": [ - 25 - ], - "starting_column": 52, - "ending_column": 57 - }, - "function": { - "type": "function", - "name": "shadowingParent", + ] + }, + { + "check": "shadowing-local", + "impact": "Low", + "confidence": "High", + "description": "FurtherExtendedContract.shadowingParent.y (local variable @ tests/shadowing_local_variable.sol#25) shadows:\n\t- BaseContract.y (state variable @ tests/shadowing_local_variable.sol#5)\n", + "elements": [ + { + "type": "variable", + "name": "y", "source_mapping": { - "start": 351, - "length": 79, + "start": 398, + "length": 5, "filename_used": "/home/travis/build/crytic/slither/tests/shadowing_local_variable.sol", "filename_relative": "tests/shadowing_local_variable.sol", "filename_absolute": "/home/travis/build/crytic/slither/tests/shadowing_local_variable.sol", @@ -227,105 +223,112 @@ "lines": [ 25 ], - "starting_column": 5, - "ending_column": 84 + "starting_column": 52, + "ending_column": 57 }, - "contract": { - "type": "contract", - "name": "FurtherExtendedContract", - "source_mapping": { - "start": 197, - "length": 235, - "filename_used": "/home/travis/build/crytic/slither/tests/shadowing_local_variable.sol", - "filename_relative": "tests/shadowing_local_variable.sol", - "filename_absolute": "/home/travis/build/crytic/slither/tests/shadowing_local_variable.sol", - "filename_short": "tests/shadowing_local_variable.sol", - "lines": [ - 16, - 17, - 18, - 19, - 20, - 21, - 22, - 23, - 24, - 25, - 26 - ], - "starting_column": 1, - "ending_column": 2 + "type_specific_fields": { + "parent": { + "type": "function", + "name": "shadowingParent", + "source_mapping": { + "start": 351, + "length": 79, + "filename_used": "/home/travis/build/crytic/slither/tests/shadowing_local_variable.sol", + "filename_relative": "tests/shadowing_local_variable.sol", + "filename_absolute": "/home/travis/build/crytic/slither/tests/shadowing_local_variable.sol", + "filename_short": "tests/shadowing_local_variable.sol", + "lines": [ + 25 + ], + "starting_column": 5, + "ending_column": 84 + }, + "type_specific_fields": { + "parent": { + "type": "contract", + "name": "FurtherExtendedContract", + "source_mapping": { + "start": 197, + "length": 235, + "filename_used": "/home/travis/build/crytic/slither/tests/shadowing_local_variable.sol", + "filename_relative": "tests/shadowing_local_variable.sol", + "filename_absolute": "/home/travis/build/crytic/slither/tests/shadowing_local_variable.sol", + "filename_short": "tests/shadowing_local_variable.sol", + "lines": [ + 16, + 17, + 18, + 19, + 20, + 21, + 22, + 23, + 24, + 25, + 26 + ], + "starting_column": 1, + "ending_column": 2 + } + }, + "signature": "shadowingParent(uint256)" + } } } - } - }, - { - "type": "variable", - "name": "y", - "source_mapping": { - "start": 70, - "length": 10, - "filename_used": "/home/travis/build/crytic/slither/tests/shadowing_local_variable.sol", - "filename_relative": "tests/shadowing_local_variable.sol", - "filename_absolute": "/home/travis/build/crytic/slither/tests/shadowing_local_variable.sol", - "filename_short": "tests/shadowing_local_variable.sol", - "lines": [ - 5 - ], - "starting_column": 5, - "ending_column": 15 }, - "contract": { - "type": "contract", - "name": "BaseContract", + { + "type": "variable", + "name": "y", "source_mapping": { - "start": 26, - "length": 57, + "start": 70, + "length": 10, "filename_used": "/home/travis/build/crytic/slither/tests/shadowing_local_variable.sol", "filename_relative": "tests/shadowing_local_variable.sol", "filename_absolute": "/home/travis/build/crytic/slither/tests/shadowing_local_variable.sol", "filename_short": "tests/shadowing_local_variable.sol", "lines": [ - 3, - 4, - 5, - 6 + 5 ], - "starting_column": 1, - "ending_column": 2 + "starting_column": 5, + "ending_column": 15 + }, + "type_specific_fields": { + "parent": { + "type": "contract", + "name": "BaseContract", + "source_mapping": { + "start": 26, + "length": 57, + "filename_used": "/home/travis/build/crytic/slither/tests/shadowing_local_variable.sol", + "filename_relative": "tests/shadowing_local_variable.sol", + "filename_absolute": "/home/travis/build/crytic/slither/tests/shadowing_local_variable.sol", + "filename_short": "tests/shadowing_local_variable.sol", + "lines": [ + 3, + 4, + 5, + 6 + ], + "starting_column": 1, + "ending_column": 2 + } + } } } - } - ] - }, - { - "check": "shadowing-local", - "impact": "Low", - "confidence": "High", - "description": "FurtherExtendedContract.shadowingParent.z (local variable @ tests/shadowing_local_variable.sol#25) shadows:\n\t- ExtendedContract.z (function @ tests/shadowing_local_variable.sol#11)\n", - "elements": [ - { - "type": "variable", - "name": "z", - "source_mapping": { - "start": 405, - "length": 6, - "filename_used": "/home/travis/build/crytic/slither/tests/shadowing_local_variable.sol", - "filename_relative": "tests/shadowing_local_variable.sol", - "filename_absolute": "/home/travis/build/crytic/slither/tests/shadowing_local_variable.sol", - "filename_short": "tests/shadowing_local_variable.sol", - "lines": [ - 25 - ], - "starting_column": 59, - "ending_column": 65 - }, - "function": { - "type": "function", - "name": "shadowingParent", + ] + }, + { + "check": "shadowing-local", + "impact": "Low", + "confidence": "High", + "description": "FurtherExtendedContract.shadowingParent.z (local variable @ tests/shadowing_local_variable.sol#25) shadows:\n\t- ExtendedContract.z (function @ tests/shadowing_local_variable.sol#11)\n", + "elements": [ + { + "type": "variable", + "name": "z", "source_mapping": { - "start": 351, - "length": 79, + "start": 405, + "length": 6, "filename_used": "/home/travis/build/crytic/slither/tests/shadowing_local_variable.sol", "filename_relative": "tests/shadowing_local_variable.sol", "filename_absolute": "/home/travis/build/crytic/slither/tests/shadowing_local_variable.sol", @@ -333,108 +336,116 @@ "lines": [ 25 ], - "starting_column": 5, - "ending_column": 84 + "starting_column": 59, + "ending_column": 65 }, - "contract": { - "type": "contract", - "name": "FurtherExtendedContract", - "source_mapping": { - "start": 197, - "length": 235, - "filename_used": "/home/travis/build/crytic/slither/tests/shadowing_local_variable.sol", - "filename_relative": "tests/shadowing_local_variable.sol", - "filename_absolute": "/home/travis/build/crytic/slither/tests/shadowing_local_variable.sol", - "filename_short": "tests/shadowing_local_variable.sol", - "lines": [ - 16, - 17, - 18, - 19, - 20, - 21, - 22, - 23, - 24, - 25, - 26 - ], - "starting_column": 1, - "ending_column": 2 + "type_specific_fields": { + "parent": { + "type": "function", + "name": "shadowingParent", + "source_mapping": { + "start": 351, + "length": 79, + "filename_used": "/home/travis/build/crytic/slither/tests/shadowing_local_variable.sol", + "filename_relative": "tests/shadowing_local_variable.sol", + "filename_absolute": "/home/travis/build/crytic/slither/tests/shadowing_local_variable.sol", + "filename_short": "tests/shadowing_local_variable.sol", + "lines": [ + 25 + ], + "starting_column": 5, + "ending_column": 84 + }, + "type_specific_fields": { + "parent": { + "type": "contract", + "name": "FurtherExtendedContract", + "source_mapping": { + "start": 197, + "length": 235, + "filename_used": "/home/travis/build/crytic/slither/tests/shadowing_local_variable.sol", + "filename_relative": "tests/shadowing_local_variable.sol", + "filename_absolute": "/home/travis/build/crytic/slither/tests/shadowing_local_variable.sol", + "filename_short": "tests/shadowing_local_variable.sol", + "lines": [ + 16, + 17, + 18, + 19, + 20, + 21, + 22, + 23, + 24, + 25, + 26 + ], + "starting_column": 1, + "ending_column": 2 + } + }, + "signature": "shadowingParent(uint256)" + } } } - } - }, - { - "type": "function", - "name": "z", - "source_mapping": { - "start": 150, - "length": 27, - "filename_used": "/home/travis/build/crytic/slither/tests/shadowing_local_variable.sol", - "filename_relative": "tests/shadowing_local_variable.sol", - "filename_absolute": "/home/travis/build/crytic/slither/tests/shadowing_local_variable.sol", - "filename_short": "tests/shadowing_local_variable.sol", - "lines": [ - 11 - ], - "starting_column": 5, - "ending_column": 32 }, - "contract": { - "type": "contract", - "name": "ExtendedContract", + { + "type": "function", + "name": "z", "source_mapping": { - "start": 85, - "length": 110, + "start": 150, + "length": 27, "filename_used": "/home/travis/build/crytic/slither/tests/shadowing_local_variable.sol", "filename_relative": "tests/shadowing_local_variable.sol", "filename_absolute": "/home/travis/build/crytic/slither/tests/shadowing_local_variable.sol", "filename_short": "tests/shadowing_local_variable.sol", "lines": [ - 8, - 9, - 10, - 11, - 12, - 13, - 14 + 11 ], - "starting_column": 1, - "ending_column": 2 + "starting_column": 5, + "ending_column": 32 + }, + "type_specific_fields": { + "parent": { + "type": "contract", + "name": "ExtendedContract", + "source_mapping": { + "start": 85, + "length": 110, + "filename_used": "/home/travis/build/crytic/slither/tests/shadowing_local_variable.sol", + "filename_relative": "tests/shadowing_local_variable.sol", + "filename_absolute": "/home/travis/build/crytic/slither/tests/shadowing_local_variable.sol", + "filename_short": "tests/shadowing_local_variable.sol", + "lines": [ + 8, + 9, + 10, + 11, + 12, + 13, + 14 + ], + "starting_column": 1, + "ending_column": 2 + } + }, + "signature": "z()" } } - } - ] - }, - { - "check": "shadowing-local", - "impact": "Low", - "confidence": "High", - "description": "FurtherExtendedContract.shadowingParent.w (local variable @ tests/shadowing_local_variable.sol#25) shadows:\n\t- FurtherExtendedContract.w (modifier @ tests/shadowing_local_variable.sol#20-23)\n", - "elements": [ - { - "type": "variable", - "name": "w", - "source_mapping": { - "start": 413, - "length": 6, - "filename_used": "/home/travis/build/crytic/slither/tests/shadowing_local_variable.sol", - "filename_relative": "tests/shadowing_local_variable.sol", - "filename_absolute": "/home/travis/build/crytic/slither/tests/shadowing_local_variable.sol", - "filename_short": "tests/shadowing_local_variable.sol", - "lines": [ - 25 - ], - "starting_column": 67, - "ending_column": 73 - }, - "function": { - "type": "function", - "name": "shadowingParent", + ] + }, + { + "check": "shadowing-local", + "impact": "Low", + "confidence": "High", + "description": "FurtherExtendedContract.shadowingParent.w (local variable @ tests/shadowing_local_variable.sol#25) shadows:\n\t- FurtherExtendedContract.w (modifier @ tests/shadowing_local_variable.sol#20-23)\n", + "elements": [ + { + "type": "variable", + "name": "w", "source_mapping": { - "start": 351, - "length": 79, + "start": 413, + "length": 6, "filename_used": "/home/travis/build/crytic/slither/tests/shadowing_local_variable.sol", "filename_relative": "tests/shadowing_local_variable.sol", "filename_absolute": "/home/travis/build/crytic/slither/tests/shadowing_local_variable.sol", @@ -442,115 +453,123 @@ "lines": [ 25 ], - "starting_column": 5, - "ending_column": 84 + "starting_column": 67, + "ending_column": 73 }, - "contract": { - "type": "contract", - "name": "FurtherExtendedContract", - "source_mapping": { - "start": 197, - "length": 235, - "filename_used": "/home/travis/build/crytic/slither/tests/shadowing_local_variable.sol", - "filename_relative": "tests/shadowing_local_variable.sol", - "filename_absolute": "/home/travis/build/crytic/slither/tests/shadowing_local_variable.sol", - "filename_short": "tests/shadowing_local_variable.sol", - "lines": [ - 16, - 17, - 18, - 19, - 20, - 21, - 22, - 23, - 24, - 25, - 26 - ], - "starting_column": 1, - "ending_column": 2 + "type_specific_fields": { + "parent": { + "type": "function", + "name": "shadowingParent", + "source_mapping": { + "start": 351, + "length": 79, + "filename_used": "/home/travis/build/crytic/slither/tests/shadowing_local_variable.sol", + "filename_relative": "tests/shadowing_local_variable.sol", + "filename_absolute": "/home/travis/build/crytic/slither/tests/shadowing_local_variable.sol", + "filename_short": "tests/shadowing_local_variable.sol", + "lines": [ + 25 + ], + "starting_column": 5, + "ending_column": 84 + }, + "type_specific_fields": { + "parent": { + "type": "contract", + "name": "FurtherExtendedContract", + "source_mapping": { + "start": 197, + "length": 235, + "filename_used": "/home/travis/build/crytic/slither/tests/shadowing_local_variable.sol", + "filename_relative": "tests/shadowing_local_variable.sol", + "filename_absolute": "/home/travis/build/crytic/slither/tests/shadowing_local_variable.sol", + "filename_short": "tests/shadowing_local_variable.sol", + "lines": [ + 16, + 17, + 18, + 19, + 20, + 21, + 22, + 23, + 24, + 25, + 26 + ], + "starting_column": 1, + "ending_column": 2 + } + }, + "signature": "shadowingParent(uint256)" + } } } - } - }, - { - "type": "function", - "name": "w", - "source_mapping": { - "start": 274, - "length": 71, - "filename_used": "/home/travis/build/crytic/slither/tests/shadowing_local_variable.sol", - "filename_relative": "tests/shadowing_local_variable.sol", - "filename_absolute": "/home/travis/build/crytic/slither/tests/shadowing_local_variable.sol", - "filename_short": "tests/shadowing_local_variable.sol", - "lines": [ - 20, - 21, - 22, - 23 - ], - "starting_column": 5, - "ending_column": 6 }, - "contract": { - "type": "contract", - "name": "FurtherExtendedContract", + { + "type": "function", + "name": "w", "source_mapping": { - "start": 197, - "length": 235, + "start": 274, + "length": 71, "filename_used": "/home/travis/build/crytic/slither/tests/shadowing_local_variable.sol", "filename_relative": "tests/shadowing_local_variable.sol", "filename_absolute": "/home/travis/build/crytic/slither/tests/shadowing_local_variable.sol", "filename_short": "tests/shadowing_local_variable.sol", "lines": [ - 16, - 17, - 18, - 19, 20, 21, 22, - 23, - 24, - 25, - 26 + 23 ], - "starting_column": 1, - "ending_column": 2 + "starting_column": 5, + "ending_column": 6 + }, + "type_specific_fields": { + "parent": { + "type": "contract", + "name": "FurtherExtendedContract", + "source_mapping": { + "start": 197, + "length": 235, + "filename_used": "/home/travis/build/crytic/slither/tests/shadowing_local_variable.sol", + "filename_relative": "tests/shadowing_local_variable.sol", + "filename_absolute": "/home/travis/build/crytic/slither/tests/shadowing_local_variable.sol", + "filename_short": "tests/shadowing_local_variable.sol", + "lines": [ + 16, + 17, + 18, + 19, + 20, + 21, + 22, + 23, + 24, + 25, + 26 + ], + "starting_column": 1, + "ending_column": 2 + } + }, + "signature": "w()" } } - } - ] - }, - { - "check": "shadowing-local", - "impact": "Low", - "confidence": "High", - "description": "FurtherExtendedContract.shadowingParent.v (local variable @ tests/shadowing_local_variable.sol#25) shadows:\n\t- ExtendedContract.v (event @ tests/shadowing_local_variable.sol#13)\n", - "elements": [ - { - "type": "variable", - "name": "v", - "source_mapping": { - "start": 421, - "length": 6, - "filename_used": "/home/travis/build/crytic/slither/tests/shadowing_local_variable.sol", - "filename_relative": "tests/shadowing_local_variable.sol", - "filename_absolute": "/home/travis/build/crytic/slither/tests/shadowing_local_variable.sol", - "filename_short": "tests/shadowing_local_variable.sol", - "lines": [ - 25 - ], - "starting_column": 75, - "ending_column": 81 - }, - "function": { - "type": "function", - "name": "shadowingParent", + ] + }, + { + "check": "shadowing-local", + "impact": "Low", + "confidence": "High", + "description": "FurtherExtendedContract.shadowingParent.v (local variable @ tests/shadowing_local_variable.sol#25) shadows:\n\t- ExtendedContract.v (event @ tests/shadowing_local_variable.sol#13)\n", + "elements": [ + { + "type": "variable", + "name": "v", "source_mapping": { - "start": 351, - "length": 79, + "start": 421, + "length": 6, "filename_used": "/home/travis/build/crytic/slither/tests/shadowing_local_variable.sol", "filename_relative": "tests/shadowing_local_variable.sol", "filename_absolute": "/home/travis/build/crytic/slither/tests/shadowing_local_variable.sol", @@ -558,79 +577,104 @@ "lines": [ 25 ], - "starting_column": 5, - "ending_column": 84 + "starting_column": 75, + "ending_column": 81 }, - "contract": { - "type": "contract", - "name": "FurtherExtendedContract", - "source_mapping": { - "start": 197, - "length": 235, - "filename_used": "/home/travis/build/crytic/slither/tests/shadowing_local_variable.sol", - "filename_relative": "tests/shadowing_local_variable.sol", - "filename_absolute": "/home/travis/build/crytic/slither/tests/shadowing_local_variable.sol", - "filename_short": "tests/shadowing_local_variable.sol", - "lines": [ - 16, - 17, - 18, - 19, - 20, - 21, - 22, - 23, - 24, - 25, - 26 - ], - "starting_column": 1, - "ending_column": 2 + "type_specific_fields": { + "parent": { + "type": "function", + "name": "shadowingParent", + "source_mapping": { + "start": 351, + "length": 79, + "filename_used": "/home/travis/build/crytic/slither/tests/shadowing_local_variable.sol", + "filename_relative": "tests/shadowing_local_variable.sol", + "filename_absolute": "/home/travis/build/crytic/slither/tests/shadowing_local_variable.sol", + "filename_short": "tests/shadowing_local_variable.sol", + "lines": [ + 25 + ], + "starting_column": 5, + "ending_column": 84 + }, + "type_specific_fields": { + "parent": { + "type": "contract", + "name": "FurtherExtendedContract", + "source_mapping": { + "start": 197, + "length": 235, + "filename_used": "/home/travis/build/crytic/slither/tests/shadowing_local_variable.sol", + "filename_relative": "tests/shadowing_local_variable.sol", + "filename_absolute": "/home/travis/build/crytic/slither/tests/shadowing_local_variable.sol", + "filename_short": "tests/shadowing_local_variable.sol", + "lines": [ + 16, + 17, + 18, + 19, + 20, + 21, + 22, + 23, + 24, + 25, + 26 + ], + "starting_column": 1, + "ending_column": 2 + } + }, + "signature": "shadowingParent(uint256)" + } } } - } - }, - { - "type": "event", - "name": "v", - "source_mapping": { - "start": 183, - "length": 10, - "filename_used": "/home/travis/build/crytic/slither/tests/shadowing_local_variable.sol", - "filename_relative": "tests/shadowing_local_variable.sol", - "filename_absolute": "/home/travis/build/crytic/slither/tests/shadowing_local_variable.sol", - "filename_short": "tests/shadowing_local_variable.sol", - "lines": [ - 13 - ], - "starting_column": 5, - "ending_column": 15 }, - "contract": { - "type": "contract", - "name": "ExtendedContract", + { + "type": "event", + "name": "v", "source_mapping": { - "start": 85, - "length": 110, + "start": 183, + "length": 10, "filename_used": "/home/travis/build/crytic/slither/tests/shadowing_local_variable.sol", "filename_relative": "tests/shadowing_local_variable.sol", "filename_absolute": "/home/travis/build/crytic/slither/tests/shadowing_local_variable.sol", "filename_short": "tests/shadowing_local_variable.sol", "lines": [ - 8, - 9, - 10, - 11, - 12, - 13, - 14 + 13 ], - "starting_column": 1, - "ending_column": 2 + "starting_column": 5, + "ending_column": 15 + }, + "type_specific_fields": { + "parent": { + "type": "contract", + "name": "ExtendedContract", + "source_mapping": { + "start": 85, + "length": 110, + "filename_used": "/home/travis/build/crytic/slither/tests/shadowing_local_variable.sol", + "filename_relative": "tests/shadowing_local_variable.sol", + "filename_absolute": "/home/travis/build/crytic/slither/tests/shadowing_local_variable.sol", + "filename_short": "tests/shadowing_local_variable.sol", + "lines": [ + 8, + 9, + 10, + 11, + 12, + 13, + 14 + ], + "starting_column": 1, + "ending_column": 2 + } + }, + "signature": "v()" } } - } - ] - } - ] + ] + } + ] + } } \ No newline at end of file diff --git a/tests/expected_json/shadowing_state_variable.shadowing-state.json b/tests/expected_json/shadowing_state_variable.shadowing-state.json index ff4a75db1..5f2780606 100644 --- a/tests/expected_json/shadowing_state_variable.shadowing-state.json +++ b/tests/expected_json/shadowing_state_variable.shadowing-state.json @@ -1,100 +1,106 @@ { "success": true, "error": null, - "results": [ - { - "check": "shadowing-state", - "impact": "High", - "confidence": "High", - "description": "DerivedContract.owner (tests/shadowing_state_variable.sol#12) shadows:\n\t- BaseContract.owner (tests/shadowing_state_variable.sol#2)\n", - "elements": [ - { - "type": "variable", - "name": "owner", - "source_mapping": { - "start": 172, - "length": 13, - "filename_used": "/home/travis/build/crytic/slither/tests/shadowing_state_variable.sol", - "filename_relative": "tests/shadowing_state_variable.sol", - "filename_absolute": "/home/travis/build/crytic/slither/tests/shadowing_state_variable.sol", - "filename_short": "tests/shadowing_state_variable.sol", - "lines": [ - 12 - ], - "starting_column": 5, - "ending_column": 18 - }, - "contract": { - "type": "contract", - "name": "DerivedContract", + "results": { + "detectors": [ + { + "check": "shadowing-state", + "impact": "High", + "confidence": "High", + "description": "DerivedContract.owner (tests/shadowing_state_variable.sol#12) shadows:\n\t- BaseContract.owner (tests/shadowing_state_variable.sol#2)\n", + "elements": [ + { + "type": "variable", + "name": "owner", "source_mapping": { - "start": 126, - "length": 210, + "start": 172, + "length": 13, "filename_used": "/home/travis/build/crytic/slither/tests/shadowing_state_variable.sol", "filename_relative": "tests/shadowing_state_variable.sol", "filename_absolute": "/home/travis/build/crytic/slither/tests/shadowing_state_variable.sol", "filename_short": "tests/shadowing_state_variable.sol", "lines": [ - 11, - 12, - 13, - 14, - 15, - 16, - 17, - 18, - 19, - 20, - 21 + 12 ], - "starting_column": 1, - "ending_column": 2 + "starting_column": 5, + "ending_column": 18 + }, + "type_specific_fields": { + "parent": { + "type": "contract", + "name": "DerivedContract", + "source_mapping": { + "start": 126, + "length": 210, + "filename_used": "/home/travis/build/crytic/slither/tests/shadowing_state_variable.sol", + "filename_relative": "tests/shadowing_state_variable.sol", + "filename_absolute": "/home/travis/build/crytic/slither/tests/shadowing_state_variable.sol", + "filename_short": "tests/shadowing_state_variable.sol", + "lines": [ + 11, + 12, + 13, + 14, + 15, + 16, + 17, + 18, + 19, + 20, + 21 + ], + "starting_column": 1, + "ending_column": 2 + } + } } - } - }, - { - "type": "variable", - "name": "owner", - "source_mapping": { - "start": 27, - "length": 13, - "filename_used": "/home/travis/build/crytic/slither/tests/shadowing_state_variable.sol", - "filename_relative": "tests/shadowing_state_variable.sol", - "filename_absolute": "/home/travis/build/crytic/slither/tests/shadowing_state_variable.sol", - "filename_short": "tests/shadowing_state_variable.sol", - "lines": [ - 2 - ], - "starting_column": 5, - "ending_column": 18 }, - "contract": { - "type": "contract", - "name": "BaseContract", + { + "type": "variable", + "name": "owner", "source_mapping": { - "start": 0, - "length": 124, + "start": 27, + "length": 13, "filename_used": "/home/travis/build/crytic/slither/tests/shadowing_state_variable.sol", "filename_relative": "tests/shadowing_state_variable.sol", "filename_absolute": "/home/travis/build/crytic/slither/tests/shadowing_state_variable.sol", "filename_short": "tests/shadowing_state_variable.sol", "lines": [ - 1, - 2, - 3, - 4, - 5, - 6, - 7, - 8, - 9 + 2 ], - "starting_column": 1, - "ending_column": 2 + "starting_column": 5, + "ending_column": 18 + }, + "type_specific_fields": { + "parent": { + "type": "contract", + "name": "BaseContract", + "source_mapping": { + "start": 0, + "length": 124, + "filename_used": "/home/travis/build/crytic/slither/tests/shadowing_state_variable.sol", + "filename_relative": "tests/shadowing_state_variable.sol", + "filename_absolute": "/home/travis/build/crytic/slither/tests/shadowing_state_variable.sol", + "filename_short": "tests/shadowing_state_variable.sol", + "lines": [ + 1, + 2, + 3, + 4, + 5, + 6, + 7, + 8, + 9 + ], + "starting_column": 1, + "ending_column": 2 + } + } } } - } - ] - } - ] + ] + } + ] + } } \ No newline at end of file diff --git a/tests/expected_json/solc_version_incorrect.solc-version.json b/tests/expected_json/solc_version_incorrect.solc-version.json index 9c6b8b9f8..654b79fef 100644 --- a/tests/expected_json/solc_version_incorrect.solc-version.json +++ b/tests/expected_json/solc_version_incorrect.solc-version.json @@ -1,71 +1,77 @@ { "success": true, "error": null, - "results": [ - { - "check": "solc-version", - "impact": "Informational", - "confidence": "High", - "description": "Pragma version \"^0.4.23\" allows old versions (tests/solc_version_incorrect.sol#2)\n", - "elements": [ - { - "type": "pragma", - "name": "^0.4.23", - "source_mapping": { - "start": 63, - "length": 24, - "filename_used": "/home/travis/build/crytic/slither/tests/solc_version_incorrect.sol", - "filename_relative": "tests/solc_version_incorrect.sol", - "filename_absolute": "/home/travis/build/crytic/slither/tests/solc_version_incorrect.sol", - "filename_short": "tests/solc_version_incorrect.sol", - "lines": [ - 2 - ], - "starting_column": 1, - "ending_column": 25 - }, - "directive": [ - "solidity", - "^", - "0.4", - ".23" - ] - } - ] - }, - { - "check": "solc-version", - "impact": "Informational", - "confidence": "High", - "description": "Pragma version \">=0.4.0<0.6.0\" allows old versions (tests/solc_version_incorrect.sol#3)\n", - "elements": [ - { - "type": "pragma", - "name": ">=0.4.0<0.6.0", - "source_mapping": { - "start": 89, - "length": 31, - "filename_used": "/home/travis/build/crytic/slither/tests/solc_version_incorrect.sol", - "filename_relative": "tests/solc_version_incorrect.sol", - "filename_absolute": "/home/travis/build/crytic/slither/tests/solc_version_incorrect.sol", - "filename_short": "tests/solc_version_incorrect.sol", - "lines": [ - 3 - ], - "starting_column": 1, - "ending_column": 32 - }, - "directive": [ - "solidity", - ">=", - "0.4", - ".0", - "<", - "0.6", - ".0" - ] - } - ] - } - ] + "results": { + "detectors": [ + { + "check": "solc-version", + "impact": "Informational", + "confidence": "High", + "description": "Pragma version \"^0.4.23\" allows old versions (tests/solc_version_incorrect.sol#2)\n", + "elements": [ + { + "type": "pragma", + "name": "^0.4.23", + "source_mapping": { + "start": 63, + "length": 24, + "filename_used": "/home/travis/build/crytic/slither/tests/solc_version_incorrect.sol", + "filename_relative": "tests/solc_version_incorrect.sol", + "filename_absolute": "/home/travis/build/crytic/slither/tests/solc_version_incorrect.sol", + "filename_short": "tests/solc_version_incorrect.sol", + "lines": [ + 2 + ], + "starting_column": 1, + "ending_column": 25 + }, + "type_specific_fields": { + "directive": [ + "solidity", + "^", + "0.4", + ".23" + ] + } + } + ] + }, + { + "check": "solc-version", + "impact": "Informational", + "confidence": "High", + "description": "Pragma version \">=0.4.0<0.6.0\" allows old versions (tests/solc_version_incorrect.sol#3)\n", + "elements": [ + { + "type": "pragma", + "name": ">=0.4.0<0.6.0", + "source_mapping": { + "start": 89, + "length": 31, + "filename_used": "/home/travis/build/crytic/slither/tests/solc_version_incorrect.sol", + "filename_relative": "tests/solc_version_incorrect.sol", + "filename_absolute": "/home/travis/build/crytic/slither/tests/solc_version_incorrect.sol", + "filename_short": "tests/solc_version_incorrect.sol", + "lines": [ + 3 + ], + "starting_column": 1, + "ending_column": 32 + }, + "type_specific_fields": { + "directive": [ + "solidity", + ">=", + "0.4", + ".0", + "<", + "0.6", + ".0" + ] + } + } + ] + } + ] + } } \ No newline at end of file diff --git a/tests/expected_json/timestamp.timestamp.json b/tests/expected_json/timestamp.timestamp.json index 5b5e4726c..d60bd3692 100644 --- a/tests/expected_json/timestamp.timestamp.json +++ b/tests/expected_json/timestamp.timestamp.json @@ -1,85 +1,15 @@ { "success": true, "error": null, - "results": [ - { - "check": "timestamp", - "impact": "Low", - "confidence": "Medium", - "description": "Timestamp.bad0 (tests/timestamp.sol#4-6) uses timestamp for comparisons\n\tDangerous comparisons:\n\t- require(bool)(block.timestamp == 0) (tests/timestamp.sol#5)\n", - "elements": [ - { - "type": "function", - "name": "bad0", - "source_mapping": { - "start": 47, - "length": 70, - "filename_used": "/home/travis/build/crytic/slither/tests/timestamp.sol", - "filename_relative": "tests/timestamp.sol", - "filename_absolute": "/home/travis/build/crytic/slither/tests/timestamp.sol", - "filename_short": "tests/timestamp.sol", - "lines": [ - 4, - 5, - 6 - ], - "starting_column": 5, - "ending_column": 6 - }, - "contract": { - "type": "contract", - "name": "Timestamp", - "source_mapping": { - "start": 0, - "length": 402, - "filename_used": "/home/travis/build/crytic/slither/tests/timestamp.sol", - "filename_relative": "tests/timestamp.sol", - "filename_absolute": "/home/travis/build/crytic/slither/tests/timestamp.sol", - "filename_short": "tests/timestamp.sol", - "lines": [ - 1, - 2, - 3, - 4, - 5, - 6, - 7, - 8, - 9, - 10, - 11, - 12, - 13, - 14, - 15, - 16, - 17, - 18, - 19, - 20 - ], - "starting_column": 1, - "ending_column": 2 - } - } - }, - { - "type": "node", - "name": "require(bool)(block.timestamp == 0)", - "source_mapping": { - "start": 81, - "length": 29, - "filename_used": "/home/travis/build/crytic/slither/tests/timestamp.sol", - "filename_relative": "tests/timestamp.sol", - "filename_absolute": "/home/travis/build/crytic/slither/tests/timestamp.sol", - "filename_short": "tests/timestamp.sol", - "lines": [ - 5 - ], - "starting_column": 9, - "ending_column": 38 - }, - "function": { + "results": { + "detectors": [ + { + "check": "timestamp", + "impact": "Low", + "confidence": "Medium", + "description": "Timestamp.bad0 (tests/timestamp.sol#4-6) uses timestamp for comparisons\n\tDangerous comparisons:\n\t- require(bool)(block.timestamp == 0) (tests/timestamp.sol#5)\n", + "elements": [ + { "type": "function", "name": "bad0", "source_mapping": { @@ -97,125 +27,132 @@ "starting_column": 5, "ending_column": 6 }, - "contract": { - "type": "contract", - "name": "Timestamp", - "source_mapping": { - "start": 0, - "length": 402, - "filename_used": "/home/travis/build/crytic/slither/tests/timestamp.sol", - "filename_relative": "tests/timestamp.sol", - "filename_absolute": "/home/travis/build/crytic/slither/tests/timestamp.sol", - "filename_short": "tests/timestamp.sol", - "lines": [ - 1, - 2, - 3, - 4, - 5, - 6, - 7, - 8, - 9, - 10, - 11, - 12, - 13, - 14, - 15, - 16, - 17, - 18, - 19, - 20 - ], - "starting_column": 1, - "ending_column": 2 - } + "type_specific_fields": { + "parent": { + "type": "contract", + "name": "Timestamp", + "source_mapping": { + "start": 0, + "length": 402, + "filename_used": "/home/travis/build/crytic/slither/tests/timestamp.sol", + "filename_relative": "tests/timestamp.sol", + "filename_absolute": "/home/travis/build/crytic/slither/tests/timestamp.sol", + "filename_short": "tests/timestamp.sol", + "lines": [ + 1, + 2, + 3, + 4, + 5, + 6, + 7, + 8, + 9, + 10, + 11, + 12, + 13, + 14, + 15, + 16, + 17, + 18, + 19, + 20 + ], + "starting_column": 1, + "ending_column": 2 + } + }, + "signature": "bad0()" } - } - } - ] - }, - { - "check": "timestamp", - "impact": "Low", - "confidence": "Medium", - "description": "Timestamp.bad1 (tests/timestamp.sol#8-11) uses timestamp for comparisons\n\tDangerous comparisons:\n\t- require(bool)(time == 0) (tests/timestamp.sol#10)\n", - "elements": [ - { - "type": "function", - "name": "bad1", - "source_mapping": { - "start": 126, - "length": 96, - "filename_used": "/home/travis/build/crytic/slither/tests/timestamp.sol", - "filename_relative": "tests/timestamp.sol", - "filename_absolute": "/home/travis/build/crytic/slither/tests/timestamp.sol", - "filename_short": "tests/timestamp.sol", - "lines": [ - 8, - 9, - 10, - 11 - ], - "starting_column": 5, - "ending_column": 6 }, - "contract": { - "type": "contract", - "name": "Timestamp", + { + "type": "node", + "name": "require(bool)(block.timestamp == 0)", "source_mapping": { - "start": 0, - "length": 402, + "start": 81, + "length": 29, "filename_used": "/home/travis/build/crytic/slither/tests/timestamp.sol", "filename_relative": "tests/timestamp.sol", "filename_absolute": "/home/travis/build/crytic/slither/tests/timestamp.sol", "filename_short": "tests/timestamp.sol", "lines": [ - 1, - 2, - 3, - 4, - 5, - 6, - 7, - 8, - 9, - 10, - 11, - 12, - 13, - 14, - 15, - 16, - 17, - 18, - 19, - 20 + 5 ], - "starting_column": 1, - "ending_column": 2 + "starting_column": 9, + "ending_column": 38 + }, + "type_specific_fields": { + "parent": { + "type": "function", + "name": "bad0", + "source_mapping": { + "start": 47, + "length": 70, + "filename_used": "/home/travis/build/crytic/slither/tests/timestamp.sol", + "filename_relative": "tests/timestamp.sol", + "filename_absolute": "/home/travis/build/crytic/slither/tests/timestamp.sol", + "filename_short": "tests/timestamp.sol", + "lines": [ + 4, + 5, + 6 + ], + "starting_column": 5, + "ending_column": 6 + }, + "type_specific_fields": { + "parent": { + "type": "contract", + "name": "Timestamp", + "source_mapping": { + "start": 0, + "length": 402, + "filename_used": "/home/travis/build/crytic/slither/tests/timestamp.sol", + "filename_relative": "tests/timestamp.sol", + "filename_absolute": "/home/travis/build/crytic/slither/tests/timestamp.sol", + "filename_short": "tests/timestamp.sol", + "lines": [ + 1, + 2, + 3, + 4, + 5, + 6, + 7, + 8, + 9, + 10, + 11, + 12, + 13, + 14, + 15, + 16, + 17, + 18, + 19, + 20 + ], + "starting_column": 1, + "ending_column": 2 + } + }, + "signature": "bad0()" + } + } } } - }, - { - "type": "node", - "name": "require(bool)(time == 0)", - "source_mapping": { - "start": 197, - "length": 18, - "filename_used": "/home/travis/build/crytic/slither/tests/timestamp.sol", - "filename_relative": "tests/timestamp.sol", - "filename_absolute": "/home/travis/build/crytic/slither/tests/timestamp.sol", - "filename_short": "tests/timestamp.sol", - "lines": [ - 10 - ], - "starting_column": 9, - "ending_column": 27 - }, - "function": { + ] + }, + { + "check": "timestamp", + "impact": "Low", + "confidence": "Medium", + "description": "Timestamp.bad1 (tests/timestamp.sol#8-11) uses timestamp for comparisons\n\tDangerous comparisons:\n\t- require(bool)(time == 0) (tests/timestamp.sol#10)\n", + "elements": [ + { "type": "function", "name": "bad1", "source_mapping": { @@ -234,124 +171,133 @@ "starting_column": 5, "ending_column": 6 }, - "contract": { - "type": "contract", - "name": "Timestamp", - "source_mapping": { - "start": 0, - "length": 402, - "filename_used": "/home/travis/build/crytic/slither/tests/timestamp.sol", - "filename_relative": "tests/timestamp.sol", - "filename_absolute": "/home/travis/build/crytic/slither/tests/timestamp.sol", - "filename_short": "tests/timestamp.sol", - "lines": [ - 1, - 2, - 3, - 4, - 5, - 6, - 7, - 8, - 9, - 10, - 11, - 12, - 13, - 14, - 15, - 16, - 17, - 18, - 19, - 20 - ], - "starting_column": 1, - "ending_column": 2 - } + "type_specific_fields": { + "parent": { + "type": "contract", + "name": "Timestamp", + "source_mapping": { + "start": 0, + "length": 402, + "filename_used": "/home/travis/build/crytic/slither/tests/timestamp.sol", + "filename_relative": "tests/timestamp.sol", + "filename_absolute": "/home/travis/build/crytic/slither/tests/timestamp.sol", + "filename_short": "tests/timestamp.sol", + "lines": [ + 1, + 2, + 3, + 4, + 5, + 6, + 7, + 8, + 9, + 10, + 11, + 12, + 13, + 14, + 15, + 16, + 17, + 18, + 19, + 20 + ], + "starting_column": 1, + "ending_column": 2 + } + }, + "signature": "bad1()" } - } - } - ] - }, - { - "check": "timestamp", - "impact": "Low", - "confidence": "Medium", - "description": "Timestamp.bad2 (tests/timestamp.sol#13-15) uses timestamp for comparisons\n\tDangerous comparisons:\n\t- block.timestamp > 0 (tests/timestamp.sol#14)\n", - "elements": [ - { - "type": "function", - "name": "bad2", - "source_mapping": { - "start": 231, - "length": 79, - "filename_used": "/home/travis/build/crytic/slither/tests/timestamp.sol", - "filename_relative": "tests/timestamp.sol", - "filename_absolute": "/home/travis/build/crytic/slither/tests/timestamp.sol", - "filename_short": "tests/timestamp.sol", - "lines": [ - 13, - 14, - 15 - ], - "starting_column": 5, - "ending_column": 6 }, - "contract": { - "type": "contract", - "name": "Timestamp", + { + "type": "node", + "name": "require(bool)(time == 0)", "source_mapping": { - "start": 0, - "length": 402, + "start": 197, + "length": 18, "filename_used": "/home/travis/build/crytic/slither/tests/timestamp.sol", "filename_relative": "tests/timestamp.sol", "filename_absolute": "/home/travis/build/crytic/slither/tests/timestamp.sol", "filename_short": "tests/timestamp.sol", "lines": [ - 1, - 2, - 3, - 4, - 5, - 6, - 7, - 8, - 9, - 10, - 11, - 12, - 13, - 14, - 15, - 16, - 17, - 18, - 19, - 20 + 10 ], - "starting_column": 1, - "ending_column": 2 + "starting_column": 9, + "ending_column": 27 + }, + "type_specific_fields": { + "parent": { + "type": "function", + "name": "bad1", + "source_mapping": { + "start": 126, + "length": 96, + "filename_used": "/home/travis/build/crytic/slither/tests/timestamp.sol", + "filename_relative": "tests/timestamp.sol", + "filename_absolute": "/home/travis/build/crytic/slither/tests/timestamp.sol", + "filename_short": "tests/timestamp.sol", + "lines": [ + 8, + 9, + 10, + 11 + ], + "starting_column": 5, + "ending_column": 6 + }, + "type_specific_fields": { + "parent": { + "type": "contract", + "name": "Timestamp", + "source_mapping": { + "start": 0, + "length": 402, + "filename_used": "/home/travis/build/crytic/slither/tests/timestamp.sol", + "filename_relative": "tests/timestamp.sol", + "filename_absolute": "/home/travis/build/crytic/slither/tests/timestamp.sol", + "filename_short": "tests/timestamp.sol", + "lines": [ + 1, + 2, + 3, + 4, + 5, + 6, + 7, + 8, + 9, + 10, + 11, + 12, + 13, + 14, + 15, + 16, + 17, + 18, + 19, + 20 + ], + "starting_column": 1, + "ending_column": 2 + } + }, + "signature": "bad1()" + } + } } } - }, - { - "type": "node", - "name": "block.timestamp > 0", - "source_mapping": { - "start": 279, - "length": 24, - "filename_used": "/home/travis/build/crytic/slither/tests/timestamp.sol", - "filename_relative": "tests/timestamp.sol", - "filename_absolute": "/home/travis/build/crytic/slither/tests/timestamp.sol", - "filename_short": "tests/timestamp.sol", - "lines": [ - 14 - ], - "starting_column": 9, - "ending_column": 33 - }, - "function": { + ] + }, + { + "check": "timestamp", + "impact": "Low", + "confidence": "Medium", + "description": "Timestamp.bad2 (tests/timestamp.sol#13-15) uses timestamp for comparisons\n\tDangerous comparisons:\n\t- block.timestamp > 0 (tests/timestamp.sol#14)\n", + "elements": [ + { "type": "function", "name": "bad2", "source_mapping": { @@ -369,45 +315,125 @@ "starting_column": 5, "ending_column": 6 }, - "contract": { - "type": "contract", - "name": "Timestamp", - "source_mapping": { - "start": 0, - "length": 402, - "filename_used": "/home/travis/build/crytic/slither/tests/timestamp.sol", - "filename_relative": "tests/timestamp.sol", - "filename_absolute": "/home/travis/build/crytic/slither/tests/timestamp.sol", - "filename_short": "tests/timestamp.sol", - "lines": [ - 1, - 2, - 3, - 4, - 5, - 6, - 7, - 8, - 9, - 10, - 11, - 12, - 13, - 14, - 15, - 16, - 17, - 18, - 19, - 20 - ], - "starting_column": 1, - "ending_column": 2 + "type_specific_fields": { + "parent": { + "type": "contract", + "name": "Timestamp", + "source_mapping": { + "start": 0, + "length": 402, + "filename_used": "/home/travis/build/crytic/slither/tests/timestamp.sol", + "filename_relative": "tests/timestamp.sol", + "filename_absolute": "/home/travis/build/crytic/slither/tests/timestamp.sol", + "filename_short": "tests/timestamp.sol", + "lines": [ + 1, + 2, + 3, + 4, + 5, + 6, + 7, + 8, + 9, + 10, + 11, + 12, + 13, + 14, + 15, + 16, + 17, + 18, + 19, + 20 + ], + "starting_column": 1, + "ending_column": 2 + } + }, + "signature": "bad2()" + } + }, + { + "type": "node", + "name": "block.timestamp > 0", + "source_mapping": { + "start": 279, + "length": 24, + "filename_used": "/home/travis/build/crytic/slither/tests/timestamp.sol", + "filename_relative": "tests/timestamp.sol", + "filename_absolute": "/home/travis/build/crytic/slither/tests/timestamp.sol", + "filename_short": "tests/timestamp.sol", + "lines": [ + 14 + ], + "starting_column": 9, + "ending_column": 33 + }, + "type_specific_fields": { + "parent": { + "type": "function", + "name": "bad2", + "source_mapping": { + "start": 231, + "length": 79, + "filename_used": "/home/travis/build/crytic/slither/tests/timestamp.sol", + "filename_relative": "tests/timestamp.sol", + "filename_absolute": "/home/travis/build/crytic/slither/tests/timestamp.sol", + "filename_short": "tests/timestamp.sol", + "lines": [ + 13, + 14, + 15 + ], + "starting_column": 5, + "ending_column": 6 + }, + "type_specific_fields": { + "parent": { + "type": "contract", + "name": "Timestamp", + "source_mapping": { + "start": 0, + "length": 402, + "filename_used": "/home/travis/build/crytic/slither/tests/timestamp.sol", + "filename_relative": "tests/timestamp.sol", + "filename_absolute": "/home/travis/build/crytic/slither/tests/timestamp.sol", + "filename_short": "tests/timestamp.sol", + "lines": [ + 1, + 2, + 3, + 4, + 5, + 6, + 7, + 8, + 9, + 10, + 11, + 12, + 13, + 14, + 15, + 16, + 17, + 18, + 19, + 20 + ], + "starting_column": 1, + "ending_column": 2 + } + }, + "signature": "bad2()" + } } } } - } - ] - } - ] + ] + } + ] + } } \ No newline at end of file diff --git a/tests/expected_json/too_many_digits.too-many-digits.json b/tests/expected_json/too_many_digits.too-many-digits.json index d101963ae..17fd16f45 100644 --- a/tests/expected_json/too_many_digits.too-many-digits.json +++ b/tests/expected_json/too_many_digits.too-many-digits.json @@ -1,584 +1,616 @@ { "success": true, "error": null, - "results": [ - { - "check": "too-many-digits", - "impact": "Informational", - "confidence": "Medium", - "description": "C.f (tests/too_many_digits.sol#9-15) uses literals with too many digits:\n\t- x1 = 0x000001\n", - "elements": [ - { - "type": "node", - "name": "x1 = 0x000001", - "source_mapping": { - "start": 206, - "length": 18, - "filename_used": "/home/travis/build/crytic/slither/tests/too_many_digits.sol", - "filename_relative": "tests/too_many_digits.sol", - "filename_absolute": "/home/travis/build/crytic/slither/tests/too_many_digits.sol", - "filename_short": "tests/too_many_digits.sol", - "lines": [ - 10 - ], - "starting_column": 9, - "ending_column": 27 - }, - "function": { - "type": "function", - "name": "f", + "results": { + "detectors": [ + { + "check": "too-many-digits", + "impact": "Informational", + "confidence": "Medium", + "description": "C.f (tests/too_many_digits.sol#9-15) uses literals with too many digits:\n\t- x1 = 0x000001\n", + "elements": [ + { + "type": "node", + "name": "x1 = 0x000001", "source_mapping": { - "start": 174, - "length": 195, + "start": 206, + "length": 18, "filename_used": "/home/travis/build/crytic/slither/tests/too_many_digits.sol", "filename_relative": "tests/too_many_digits.sol", "filename_absolute": "/home/travis/build/crytic/slither/tests/too_many_digits.sol", "filename_short": "tests/too_many_digits.sol", "lines": [ - 9, - 10, - 11, - 12, - 13, - 14, - 15 + 10 ], - "starting_column": 5, - "ending_column": 6 + "starting_column": 9, + "ending_column": 27 }, - "contract": { - "type": "contract", - "name": "C", - "source_mapping": { - "start": 25, - "length": 833, - "filename_used": "/home/travis/build/crytic/slither/tests/too_many_digits.sol", - "filename_relative": "tests/too_many_digits.sol", - "filename_absolute": "/home/travis/build/crytic/slither/tests/too_many_digits.sol", - "filename_short": "tests/too_many_digits.sol", - "lines": [ - 3, - 4, - 5, - 6, - 7, - 8, - 9, - 10, - 11, - 12, - 13, - 14, - 15, - 16, - 17, - 18, - 19, - 20, - 21, - 22, - 23, - 24, - 25, - 26, - 27, - 28, - 29, - 30, - 31, - 32, - 33, - 34, - 35 - ], - "starting_column": 1, - "ending_column": 2 + "type_specific_fields": { + "parent": { + "type": "function", + "name": "f", + "source_mapping": { + "start": 174, + "length": 195, + "filename_used": "/home/travis/build/crytic/slither/tests/too_many_digits.sol", + "filename_relative": "tests/too_many_digits.sol", + "filename_absolute": "/home/travis/build/crytic/slither/tests/too_many_digits.sol", + "filename_short": "tests/too_many_digits.sol", + "lines": [ + 9, + 10, + 11, + 12, + 13, + 14, + 15 + ], + "starting_column": 5, + "ending_column": 6 + }, + "type_specific_fields": { + "parent": { + "type": "contract", + "name": "C", + "source_mapping": { + "start": 25, + "length": 833, + "filename_used": "/home/travis/build/crytic/slither/tests/too_many_digits.sol", + "filename_relative": "tests/too_many_digits.sol", + "filename_absolute": "/home/travis/build/crytic/slither/tests/too_many_digits.sol", + "filename_short": "tests/too_many_digits.sol", + "lines": [ + 3, + 4, + 5, + 6, + 7, + 8, + 9, + 10, + 11, + 12, + 13, + 14, + 15, + 16, + 17, + 18, + 19, + 20, + 21, + 22, + 23, + 24, + 25, + 26, + 27, + 28, + 29, + 30, + 31, + 32, + 33, + 34, + 35 + ], + "starting_column": 1, + "ending_column": 2 + } + }, + "signature": "f()" + } } } } - } - ] - }, - { - "check": "too-many-digits", - "impact": "Informational", - "confidence": "Medium", - "description": "C.f (tests/too_many_digits.sol#9-15) uses literals with too many digits:\n\t- x2 = 0x0000000000001\n", - "elements": [ - { - "type": "node", - "name": "x2 = 0x0000000000001", - "source_mapping": { - "start": 234, - "length": 25, - "filename_used": "/home/travis/build/crytic/slither/tests/too_many_digits.sol", - "filename_relative": "tests/too_many_digits.sol", - "filename_absolute": "/home/travis/build/crytic/slither/tests/too_many_digits.sol", - "filename_short": "tests/too_many_digits.sol", - "lines": [ - 11 - ], - "starting_column": 9, - "ending_column": 34 - }, - "function": { - "type": "function", - "name": "f", + ] + }, + { + "check": "too-many-digits", + "impact": "Informational", + "confidence": "Medium", + "description": "C.f (tests/too_many_digits.sol#9-15) uses literals with too many digits:\n\t- x2 = 0x0000000000001\n", + "elements": [ + { + "type": "node", + "name": "x2 = 0x0000000000001", "source_mapping": { - "start": 174, - "length": 195, + "start": 234, + "length": 25, "filename_used": "/home/travis/build/crytic/slither/tests/too_many_digits.sol", "filename_relative": "tests/too_many_digits.sol", "filename_absolute": "/home/travis/build/crytic/slither/tests/too_many_digits.sol", "filename_short": "tests/too_many_digits.sol", "lines": [ - 9, - 10, - 11, - 12, - 13, - 14, - 15 + 11 ], - "starting_column": 5, - "ending_column": 6 + "starting_column": 9, + "ending_column": 34 }, - "contract": { - "type": "contract", - "name": "C", - "source_mapping": { - "start": 25, - "length": 833, - "filename_used": "/home/travis/build/crytic/slither/tests/too_many_digits.sol", - "filename_relative": "tests/too_many_digits.sol", - "filename_absolute": "/home/travis/build/crytic/slither/tests/too_many_digits.sol", - "filename_short": "tests/too_many_digits.sol", - "lines": [ - 3, - 4, - 5, - 6, - 7, - 8, - 9, - 10, - 11, - 12, - 13, - 14, - 15, - 16, - 17, - 18, - 19, - 20, - 21, - 22, - 23, - 24, - 25, - 26, - 27, - 28, - 29, - 30, - 31, - 32, - 33, - 34, - 35 - ], - "starting_column": 1, - "ending_column": 2 + "type_specific_fields": { + "parent": { + "type": "function", + "name": "f", + "source_mapping": { + "start": 174, + "length": 195, + "filename_used": "/home/travis/build/crytic/slither/tests/too_many_digits.sol", + "filename_relative": "tests/too_many_digits.sol", + "filename_absolute": "/home/travis/build/crytic/slither/tests/too_many_digits.sol", + "filename_short": "tests/too_many_digits.sol", + "lines": [ + 9, + 10, + 11, + 12, + 13, + 14, + 15 + ], + "starting_column": 5, + "ending_column": 6 + }, + "type_specific_fields": { + "parent": { + "type": "contract", + "name": "C", + "source_mapping": { + "start": 25, + "length": 833, + "filename_used": "/home/travis/build/crytic/slither/tests/too_many_digits.sol", + "filename_relative": "tests/too_many_digits.sol", + "filename_absolute": "/home/travis/build/crytic/slither/tests/too_many_digits.sol", + "filename_short": "tests/too_many_digits.sol", + "lines": [ + 3, + 4, + 5, + 6, + 7, + 8, + 9, + 10, + 11, + 12, + 13, + 14, + 15, + 16, + 17, + 18, + 19, + 20, + 21, + 22, + 23, + 24, + 25, + 26, + 27, + 28, + 29, + 30, + 31, + 32, + 33, + 34, + 35 + ], + "starting_column": 1, + "ending_column": 2 + } + }, + "signature": "f()" + } } } } - } - ] - }, - { - "check": "too-many-digits", - "impact": "Informational", - "confidence": "Medium", - "description": "C.f (tests/too_many_digits.sol#9-15) uses literals with too many digits:\n\t- x3 = 1000000000000000000\n", - "elements": [ - { - "type": "node", - "name": "x3 = 1000000000000000000", - "source_mapping": { - "start": 269, - "length": 29, - "filename_used": "/home/travis/build/crytic/slither/tests/too_many_digits.sol", - "filename_relative": "tests/too_many_digits.sol", - "filename_absolute": "/home/travis/build/crytic/slither/tests/too_many_digits.sol", - "filename_short": "tests/too_many_digits.sol", - "lines": [ - 12 - ], - "starting_column": 9, - "ending_column": 38 - }, - "function": { - "type": "function", - "name": "f", + ] + }, + { + "check": "too-many-digits", + "impact": "Informational", + "confidence": "Medium", + "description": "C.f (tests/too_many_digits.sol#9-15) uses literals with too many digits:\n\t- x3 = 1000000000000000000\n", + "elements": [ + { + "type": "node", + "name": "x3 = 1000000000000000000", "source_mapping": { - "start": 174, - "length": 195, + "start": 269, + "length": 29, "filename_used": "/home/travis/build/crytic/slither/tests/too_many_digits.sol", "filename_relative": "tests/too_many_digits.sol", "filename_absolute": "/home/travis/build/crytic/slither/tests/too_many_digits.sol", "filename_short": "tests/too_many_digits.sol", "lines": [ - 9, - 10, - 11, - 12, - 13, - 14, - 15 + 12 ], - "starting_column": 5, - "ending_column": 6 + "starting_column": 9, + "ending_column": 38 }, - "contract": { - "type": "contract", - "name": "C", - "source_mapping": { - "start": 25, - "length": 833, - "filename_used": "/home/travis/build/crytic/slither/tests/too_many_digits.sol", - "filename_relative": "tests/too_many_digits.sol", - "filename_absolute": "/home/travis/build/crytic/slither/tests/too_many_digits.sol", - "filename_short": "tests/too_many_digits.sol", - "lines": [ - 3, - 4, - 5, - 6, - 7, - 8, - 9, - 10, - 11, - 12, - 13, - 14, - 15, - 16, - 17, - 18, - 19, - 20, - 21, - 22, - 23, - 24, - 25, - 26, - 27, - 28, - 29, - 30, - 31, - 32, - 33, - 34, - 35 - ], - "starting_column": 1, - "ending_column": 2 + "type_specific_fields": { + "parent": { + "type": "function", + "name": "f", + "source_mapping": { + "start": 174, + "length": 195, + "filename_used": "/home/travis/build/crytic/slither/tests/too_many_digits.sol", + "filename_relative": "tests/too_many_digits.sol", + "filename_absolute": "/home/travis/build/crytic/slither/tests/too_many_digits.sol", + "filename_short": "tests/too_many_digits.sol", + "lines": [ + 9, + 10, + 11, + 12, + 13, + 14, + 15 + ], + "starting_column": 5, + "ending_column": 6 + }, + "type_specific_fields": { + "parent": { + "type": "contract", + "name": "C", + "source_mapping": { + "start": 25, + "length": 833, + "filename_used": "/home/travis/build/crytic/slither/tests/too_many_digits.sol", + "filename_relative": "tests/too_many_digits.sol", + "filename_absolute": "/home/travis/build/crytic/slither/tests/too_many_digits.sol", + "filename_short": "tests/too_many_digits.sol", + "lines": [ + 3, + 4, + 5, + 6, + 7, + 8, + 9, + 10, + 11, + 12, + 13, + 14, + 15, + 16, + 17, + 18, + 19, + 20, + 21, + 22, + 23, + 24, + 25, + 26, + 27, + 28, + 29, + 30, + 31, + 32, + 33, + 34, + 35 + ], + "starting_column": 1, + "ending_column": 2 + } + }, + "signature": "f()" + } } } } - } - ] - }, - { - "check": "too-many-digits", - "impact": "Informational", - "confidence": "Medium", - "description": "C.f (tests/too_many_digits.sol#9-15) uses literals with too many digits:\n\t- x4 = 100000\n", - "elements": [ - { - "type": "node", - "name": "x4 = 100000", - "source_mapping": { - "start": 308, - "length": 16, - "filename_used": "/home/travis/build/crytic/slither/tests/too_many_digits.sol", - "filename_relative": "tests/too_many_digits.sol", - "filename_absolute": "/home/travis/build/crytic/slither/tests/too_many_digits.sol", - "filename_short": "tests/too_many_digits.sol", - "lines": [ - 13 - ], - "starting_column": 9, - "ending_column": 25 - }, - "function": { - "type": "function", - "name": "f", + ] + }, + { + "check": "too-many-digits", + "impact": "Informational", + "confidence": "Medium", + "description": "C.f (tests/too_many_digits.sol#9-15) uses literals with too many digits:\n\t- x4 = 100000\n", + "elements": [ + { + "type": "node", + "name": "x4 = 100000", "source_mapping": { - "start": 174, - "length": 195, + "start": 308, + "length": 16, "filename_used": "/home/travis/build/crytic/slither/tests/too_many_digits.sol", "filename_relative": "tests/too_many_digits.sol", "filename_absolute": "/home/travis/build/crytic/slither/tests/too_many_digits.sol", "filename_short": "tests/too_many_digits.sol", "lines": [ - 9, - 10, - 11, - 12, - 13, - 14, - 15 + 13 ], - "starting_column": 5, - "ending_column": 6 + "starting_column": 9, + "ending_column": 25 }, - "contract": { - "type": "contract", - "name": "C", - "source_mapping": { - "start": 25, - "length": 833, - "filename_used": "/home/travis/build/crytic/slither/tests/too_many_digits.sol", - "filename_relative": "tests/too_many_digits.sol", - "filename_absolute": "/home/travis/build/crytic/slither/tests/too_many_digits.sol", - "filename_short": "tests/too_many_digits.sol", - "lines": [ - 3, - 4, - 5, - 6, - 7, - 8, - 9, - 10, - 11, - 12, - 13, - 14, - 15, - 16, - 17, - 18, - 19, - 20, - 21, - 22, - 23, - 24, - 25, - 26, - 27, - 28, - 29, - 30, - 31, - 32, - 33, - 34, - 35 - ], - "starting_column": 1, - "ending_column": 2 + "type_specific_fields": { + "parent": { + "type": "function", + "name": "f", + "source_mapping": { + "start": 174, + "length": 195, + "filename_used": "/home/travis/build/crytic/slither/tests/too_many_digits.sol", + "filename_relative": "tests/too_many_digits.sol", + "filename_absolute": "/home/travis/build/crytic/slither/tests/too_many_digits.sol", + "filename_short": "tests/too_many_digits.sol", + "lines": [ + 9, + 10, + 11, + 12, + 13, + 14, + 15 + ], + "starting_column": 5, + "ending_column": 6 + }, + "type_specific_fields": { + "parent": { + "type": "contract", + "name": "C", + "source_mapping": { + "start": 25, + "length": 833, + "filename_used": "/home/travis/build/crytic/slither/tests/too_many_digits.sol", + "filename_relative": "tests/too_many_digits.sol", + "filename_absolute": "/home/travis/build/crytic/slither/tests/too_many_digits.sol", + "filename_short": "tests/too_many_digits.sol", + "lines": [ + 3, + 4, + 5, + 6, + 7, + 8, + 9, + 10, + 11, + 12, + 13, + 14, + 15, + 16, + 17, + 18, + 19, + 20, + 21, + 22, + 23, + 24, + 25, + 26, + 27, + 28, + 29, + 30, + 31, + 32, + 33, + 34, + 35 + ], + "starting_column": 1, + "ending_column": 2 + } + }, + "signature": "f()" + } } } } - } - ] - }, - { - "check": "too-many-digits", - "impact": "Informational", - "confidence": "Medium", - "description": "C.h (tests/too_many_digits.sol#20-24) uses literals with too many digits:\n\t- x2 = 100000\n", - "elements": [ - { - "type": "node", - "name": "x2 = 100000", - "source_mapping": { - "start": 509, - "length": 16, - "filename_used": "/home/travis/build/crytic/slither/tests/too_many_digits.sol", - "filename_relative": "tests/too_many_digits.sol", - "filename_absolute": "/home/travis/build/crytic/slither/tests/too_many_digits.sol", - "filename_short": "tests/too_many_digits.sol", - "lines": [ - 22 - ], - "starting_column": 9, - "ending_column": 25 - }, - "function": { - "type": "function", - "name": "h", + ] + }, + { + "check": "too-many-digits", + "impact": "Informational", + "confidence": "Medium", + "description": "C.h (tests/too_many_digits.sol#20-24) uses literals with too many digits:\n\t- x2 = 100000\n", + "elements": [ + { + "type": "node", + "name": "x2 = 100000", "source_mapping": { - "start": 453, - "length": 113, + "start": 509, + "length": 16, "filename_used": "/home/travis/build/crytic/slither/tests/too_many_digits.sol", "filename_relative": "tests/too_many_digits.sol", "filename_absolute": "/home/travis/build/crytic/slither/tests/too_many_digits.sol", "filename_short": "tests/too_many_digits.sol", "lines": [ - 20, - 21, - 22, - 23, - 24 + 22 ], - "starting_column": 5, - "ending_column": 6 + "starting_column": 9, + "ending_column": 25 }, - "contract": { - "type": "contract", - "name": "C", - "source_mapping": { - "start": 25, - "length": 833, - "filename_used": "/home/travis/build/crytic/slither/tests/too_many_digits.sol", - "filename_relative": "tests/too_many_digits.sol", - "filename_absolute": "/home/travis/build/crytic/slither/tests/too_many_digits.sol", - "filename_short": "tests/too_many_digits.sol", - "lines": [ - 3, - 4, - 5, - 6, - 7, - 8, - 9, - 10, - 11, - 12, - 13, - 14, - 15, - 16, - 17, - 18, - 19, - 20, - 21, - 22, - 23, - 24, - 25, - 26, - 27, - 28, - 29, - 30, - 31, - 32, - 33, - 34, - 35 - ], - "starting_column": 1, - "ending_column": 2 + "type_specific_fields": { + "parent": { + "type": "function", + "name": "h", + "source_mapping": { + "start": 453, + "length": 113, + "filename_used": "/home/travis/build/crytic/slither/tests/too_many_digits.sol", + "filename_relative": "tests/too_many_digits.sol", + "filename_absolute": "/home/travis/build/crytic/slither/tests/too_many_digits.sol", + "filename_short": "tests/too_many_digits.sol", + "lines": [ + 20, + 21, + 22, + 23, + 24 + ], + "starting_column": 5, + "ending_column": 6 + }, + "type_specific_fields": { + "parent": { + "type": "contract", + "name": "C", + "source_mapping": { + "start": 25, + "length": 833, + "filename_used": "/home/travis/build/crytic/slither/tests/too_many_digits.sol", + "filename_relative": "tests/too_many_digits.sol", + "filename_absolute": "/home/travis/build/crytic/slither/tests/too_many_digits.sol", + "filename_short": "tests/too_many_digits.sol", + "lines": [ + 3, + 4, + 5, + 6, + 7, + 8, + 9, + 10, + 11, + 12, + 13, + 14, + 15, + 16, + 17, + 18, + 19, + 20, + 21, + 22, + 23, + 24, + 25, + 26, + 27, + 28, + 29, + 30, + 31, + 32, + 33, + 34, + 35 + ], + "starting_column": 1, + "ending_column": 2 + } + }, + "signature": "h()" + } } } } - } - ] - }, - { - "check": "too-many-digits", - "impact": "Informational", - "confidence": "Medium", - "description": "C.i (tests/too_many_digits.sol#29-33) uses literals with too many digits:\n\t- x2 = 1000000000000 + 10000000000000 + 100000000000000 + 1000000000000000 + 10000000000000000\n", - "elements": [ - { - "type": "node", - "name": "x2 = 1000000000000 + 10000000000000 + 100000000000000 + 1000000000000000 + 10000000000000000", - "source_mapping": { - "start": 749, - "length": 67, - "filename_used": "/home/travis/build/crytic/slither/tests/too_many_digits.sol", - "filename_relative": "tests/too_many_digits.sol", - "filename_absolute": "/home/travis/build/crytic/slither/tests/too_many_digits.sol", - "filename_short": "tests/too_many_digits.sol", - "lines": [ - 31 - ], - "starting_column": 9, - "ending_column": 76 - }, - "function": { - "type": "function", - "name": "i", + ] + }, + { + "check": "too-many-digits", + "impact": "Informational", + "confidence": "Medium", + "description": "C.i (tests/too_many_digits.sol#29-33) uses literals with too many digits:\n\t- x2 = 1000000000000 + 10000000000000 + 100000000000000 + 1000000000000000 + 10000000000000000\n", + "elements": [ + { + "type": "node", + "name": "x2 = 1000000000000 + 10000000000000 + 100000000000000 + 1000000000000000 + 10000000000000000", "source_mapping": { - "start": 650, - "length": 201, + "start": 749, + "length": 67, "filename_used": "/home/travis/build/crytic/slither/tests/too_many_digits.sol", "filename_relative": "tests/too_many_digits.sol", "filename_absolute": "/home/travis/build/crytic/slither/tests/too_many_digits.sol", "filename_short": "tests/too_many_digits.sol", "lines": [ - 29, - 30, - 31, - 32, - 33 + 31 ], - "starting_column": 5, - "ending_column": 6 + "starting_column": 9, + "ending_column": 76 }, - "contract": { - "type": "contract", - "name": "C", - "source_mapping": { - "start": 25, - "length": 833, - "filename_used": "/home/travis/build/crytic/slither/tests/too_many_digits.sol", - "filename_relative": "tests/too_many_digits.sol", - "filename_absolute": "/home/travis/build/crytic/slither/tests/too_many_digits.sol", - "filename_short": "tests/too_many_digits.sol", - "lines": [ - 3, - 4, - 5, - 6, - 7, - 8, - 9, - 10, - 11, - 12, - 13, - 14, - 15, - 16, - 17, - 18, - 19, - 20, - 21, - 22, - 23, - 24, - 25, - 26, - 27, - 28, - 29, - 30, - 31, - 32, - 33, - 34, - 35 - ], - "starting_column": 1, - "ending_column": 2 + "type_specific_fields": { + "parent": { + "type": "function", + "name": "i", + "source_mapping": { + "start": 650, + "length": 201, + "filename_used": "/home/travis/build/crytic/slither/tests/too_many_digits.sol", + "filename_relative": "tests/too_many_digits.sol", + "filename_absolute": "/home/travis/build/crytic/slither/tests/too_many_digits.sol", + "filename_short": "tests/too_many_digits.sol", + "lines": [ + 29, + 30, + 31, + 32, + 33 + ], + "starting_column": 5, + "ending_column": 6 + }, + "type_specific_fields": { + "parent": { + "type": "contract", + "name": "C", + "source_mapping": { + "start": 25, + "length": 833, + "filename_used": "/home/travis/build/crytic/slither/tests/too_many_digits.sol", + "filename_relative": "tests/too_many_digits.sol", + "filename_absolute": "/home/travis/build/crytic/slither/tests/too_many_digits.sol", + "filename_short": "tests/too_many_digits.sol", + "lines": [ + 3, + 4, + 5, + 6, + 7, + 8, + 9, + 10, + 11, + 12, + 13, + 14, + 15, + 16, + 17, + 18, + 19, + 20, + 21, + 22, + 23, + 24, + 25, + 26, + 27, + 28, + 29, + 30, + 31, + 32, + 33, + 34, + 35 + ], + "starting_column": 1, + "ending_column": 2 + } + }, + "signature": "i()" + } } } } - } - ] - } - ] + ] + } + ] + } } \ No newline at end of file diff --git a/tests/expected_json/tx_origin-0.5.1.tx-origin.json b/tests/expected_json/tx_origin-0.5.1.tx-origin.json index 8bee2a3ae..579212f4e 100644 --- a/tests/expected_json/tx_origin-0.5.1.tx-origin.json +++ b/tests/expected_json/tx_origin-0.5.1.tx-origin.json @@ -1,178 +1,190 @@ { "success": true, "error": null, - "results": [ - { - "check": "tx-origin", - "impact": "Medium", - "confidence": "Medium", - "description": "TxOrigin.bug0 uses tx.origin for authorization: \"require(bool)(tx.origin == owner)\" (tests/tx_origin-0.5.1.sol#10)\n", - "elements": [ - { - "type": "node", - "name": "require(bool)(tx.origin == owner)", - "source_mapping": { - "start": 159, - "length": 27, - "filename_used": "/home/travis/build/crytic/slither/tests/tx_origin-0.5.1.sol", - "filename_relative": "tests/tx_origin-0.5.1.sol", - "filename_absolute": "/home/travis/build/crytic/slither/tests/tx_origin-0.5.1.sol", - "filename_short": "tests/tx_origin-0.5.1.sol", - "lines": [ - 10 - ], - "starting_column": 9, - "ending_column": 36 - }, - "function": { - "type": "function", - "name": "bug0", + "results": { + "detectors": [ + { + "check": "tx-origin", + "impact": "Medium", + "confidence": "Medium", + "description": "TxOrigin.bug0 uses tx.origin for authorization: \"require(bool)(tx.origin == owner)\" (tests/tx_origin-0.5.1.sol#10)\n", + "elements": [ + { + "type": "node", + "name": "require(bool)(tx.origin == owner)", "source_mapping": { - "start": 127, - "length": 66, + "start": 159, + "length": 27, "filename_used": "/home/travis/build/crytic/slither/tests/tx_origin-0.5.1.sol", "filename_relative": "tests/tx_origin-0.5.1.sol", "filename_absolute": "/home/travis/build/crytic/slither/tests/tx_origin-0.5.1.sol", "filename_short": "tests/tx_origin-0.5.1.sol", "lines": [ - 9, - 10, - 11 + 10 ], - "starting_column": 5, - "ending_column": 6 + "starting_column": 9, + "ending_column": 36 }, - "contract": { - "type": "contract", - "name": "TxOrigin", - "source_mapping": { - "start": 25, - "length": 442, - "filename_used": "/home/travis/build/crytic/slither/tests/tx_origin-0.5.1.sol", - "filename_relative": "tests/tx_origin-0.5.1.sol", - "filename_absolute": "/home/travis/build/crytic/slither/tests/tx_origin-0.5.1.sol", - "filename_short": "tests/tx_origin-0.5.1.sol", - "lines": [ - 3, - 4, - 5, - 6, - 7, - 8, - 9, - 10, - 11, - 12, - 13, - 14, - 15, - 16, - 17, - 18, - 19, - 20, - 21, - 22, - 23, - 24, - 25, - 26 - ], - "starting_column": 1, - "ending_column": 2 + "type_specific_fields": { + "parent": { + "type": "function", + "name": "bug0", + "source_mapping": { + "start": 127, + "length": 66, + "filename_used": "/home/travis/build/crytic/slither/tests/tx_origin-0.5.1.sol", + "filename_relative": "tests/tx_origin-0.5.1.sol", + "filename_absolute": "/home/travis/build/crytic/slither/tests/tx_origin-0.5.1.sol", + "filename_short": "tests/tx_origin-0.5.1.sol", + "lines": [ + 9, + 10, + 11 + ], + "starting_column": 5, + "ending_column": 6 + }, + "type_specific_fields": { + "parent": { + "type": "contract", + "name": "TxOrigin", + "source_mapping": { + "start": 25, + "length": 442, + "filename_used": "/home/travis/build/crytic/slither/tests/tx_origin-0.5.1.sol", + "filename_relative": "tests/tx_origin-0.5.1.sol", + "filename_absolute": "/home/travis/build/crytic/slither/tests/tx_origin-0.5.1.sol", + "filename_short": "tests/tx_origin-0.5.1.sol", + "lines": [ + 3, + 4, + 5, + 6, + 7, + 8, + 9, + 10, + 11, + 12, + 13, + 14, + 15, + 16, + 17, + 18, + 19, + 20, + 21, + 22, + 23, + 24, + 25, + 26 + ], + "starting_column": 1, + "ending_column": 2 + } + }, + "signature": "bug0()" + } } } } - } - ] - }, - { - "check": "tx-origin", - "impact": "Medium", - "confidence": "Medium", - "description": "TxOrigin.bug2 uses tx.origin for authorization: \"tx.origin != owner\" (tests/tx_origin-0.5.1.sol#14-16)\n", - "elements": [ - { - "type": "node", - "name": "tx.origin != owner", - "source_mapping": { - "start": 231, - "length": 57, - "filename_used": "/home/travis/build/crytic/slither/tests/tx_origin-0.5.1.sol", - "filename_relative": "tests/tx_origin-0.5.1.sol", - "filename_absolute": "/home/travis/build/crytic/slither/tests/tx_origin-0.5.1.sol", - "filename_short": "tests/tx_origin-0.5.1.sol", - "lines": [ - 14, - 15, - 16 - ], - "starting_column": 9, - "ending_column": 10 - }, - "function": { - "type": "function", - "name": "bug2", + ] + }, + { + "check": "tx-origin", + "impact": "Medium", + "confidence": "Medium", + "description": "TxOrigin.bug2 uses tx.origin for authorization: \"tx.origin != owner\" (tests/tx_origin-0.5.1.sol#14-16)\n", + "elements": [ + { + "type": "node", + "name": "tx.origin != owner", "source_mapping": { - "start": 199, - "length": 95, + "start": 231, + "length": 57, "filename_used": "/home/travis/build/crytic/slither/tests/tx_origin-0.5.1.sol", "filename_relative": "tests/tx_origin-0.5.1.sol", "filename_absolute": "/home/travis/build/crytic/slither/tests/tx_origin-0.5.1.sol", "filename_short": "tests/tx_origin-0.5.1.sol", "lines": [ - 13, 14, 15, - 16, - 17 + 16 ], - "starting_column": 5, - "ending_column": 6 + "starting_column": 9, + "ending_column": 10 }, - "contract": { - "type": "contract", - "name": "TxOrigin", - "source_mapping": { - "start": 25, - "length": 442, - "filename_used": "/home/travis/build/crytic/slither/tests/tx_origin-0.5.1.sol", - "filename_relative": "tests/tx_origin-0.5.1.sol", - "filename_absolute": "/home/travis/build/crytic/slither/tests/tx_origin-0.5.1.sol", - "filename_short": "tests/tx_origin-0.5.1.sol", - "lines": [ - 3, - 4, - 5, - 6, - 7, - 8, - 9, - 10, - 11, - 12, - 13, - 14, - 15, - 16, - 17, - 18, - 19, - 20, - 21, - 22, - 23, - 24, - 25, - 26 - ], - "starting_column": 1, - "ending_column": 2 + "type_specific_fields": { + "parent": { + "type": "function", + "name": "bug2", + "source_mapping": { + "start": 199, + "length": 95, + "filename_used": "/home/travis/build/crytic/slither/tests/tx_origin-0.5.1.sol", + "filename_relative": "tests/tx_origin-0.5.1.sol", + "filename_absolute": "/home/travis/build/crytic/slither/tests/tx_origin-0.5.1.sol", + "filename_short": "tests/tx_origin-0.5.1.sol", + "lines": [ + 13, + 14, + 15, + 16, + 17 + ], + "starting_column": 5, + "ending_column": 6 + }, + "type_specific_fields": { + "parent": { + "type": "contract", + "name": "TxOrigin", + "source_mapping": { + "start": 25, + "length": 442, + "filename_used": "/home/travis/build/crytic/slither/tests/tx_origin-0.5.1.sol", + "filename_relative": "tests/tx_origin-0.5.1.sol", + "filename_absolute": "/home/travis/build/crytic/slither/tests/tx_origin-0.5.1.sol", + "filename_short": "tests/tx_origin-0.5.1.sol", + "lines": [ + 3, + 4, + 5, + 6, + 7, + 8, + 9, + 10, + 11, + 12, + 13, + 14, + 15, + 16, + 17, + 18, + 19, + 20, + 21, + 22, + 23, + 24, + 25, + 26 + ], + "starting_column": 1, + "ending_column": 2 + } + }, + "signature": "bug2()" + } } } } - } - ] - } - ] + ] + } + ] + } } \ No newline at end of file diff --git a/tests/expected_json/tx_origin.tx-origin.json b/tests/expected_json/tx_origin.tx-origin.json index 769ad7180..6a30badb3 100644 --- a/tests/expected_json/tx_origin.tx-origin.json +++ b/tests/expected_json/tx_origin.tx-origin.json @@ -1,178 +1,190 @@ { "success": true, "error": null, - "results": [ - { - "check": "tx-origin", - "impact": "Medium", - "confidence": "Medium", - "description": "TxOrigin.bug0 uses tx.origin for authorization: \"require(bool)(tx.origin == owner)\" (tests/tx_origin.sol#10)\n", - "elements": [ - { - "type": "node", - "name": "require(bool)(tx.origin == owner)", - "source_mapping": { - "start": 142, - "length": 27, - "filename_used": "/home/travis/build/crytic/slither/tests/tx_origin.sol", - "filename_relative": "tests/tx_origin.sol", - "filename_absolute": "/home/travis/build/crytic/slither/tests/tx_origin.sol", - "filename_short": "tests/tx_origin.sol", - "lines": [ - 10 - ], - "starting_column": 9, - "ending_column": 36 - }, - "function": { - "type": "function", - "name": "bug0", + "results": { + "detectors": [ + { + "check": "tx-origin", + "impact": "Medium", + "confidence": "Medium", + "description": "TxOrigin.bug0 uses tx.origin for authorization: \"require(bool)(tx.origin == owner)\" (tests/tx_origin.sol#10)\n", + "elements": [ + { + "type": "node", + "name": "require(bool)(tx.origin == owner)", "source_mapping": { - "start": 116, - "length": 60, + "start": 142, + "length": 27, "filename_used": "/home/travis/build/crytic/slither/tests/tx_origin.sol", "filename_relative": "tests/tx_origin.sol", "filename_absolute": "/home/travis/build/crytic/slither/tests/tx_origin.sol", "filename_short": "tests/tx_origin.sol", "lines": [ - 9, - 10, - 11 + 10 ], - "starting_column": 5, - "ending_column": 6 + "starting_column": 9, + "ending_column": 36 }, - "contract": { - "type": "contract", - "name": "TxOrigin", - "source_mapping": { - "start": 28, - "length": 393, - "filename_used": "/home/travis/build/crytic/slither/tests/tx_origin.sol", - "filename_relative": "tests/tx_origin.sol", - "filename_absolute": "/home/travis/build/crytic/slither/tests/tx_origin.sol", - "filename_short": "tests/tx_origin.sol", - "lines": [ - 3, - 4, - 5, - 6, - 7, - 8, - 9, - 10, - 11, - 12, - 13, - 14, - 15, - 16, - 17, - 18, - 19, - 20, - 21, - 22, - 23, - 24, - 25, - 26 - ], - "starting_column": 1, - "ending_column": 2 + "type_specific_fields": { + "parent": { + "type": "function", + "name": "bug0", + "source_mapping": { + "start": 116, + "length": 60, + "filename_used": "/home/travis/build/crytic/slither/tests/tx_origin.sol", + "filename_relative": "tests/tx_origin.sol", + "filename_absolute": "/home/travis/build/crytic/slither/tests/tx_origin.sol", + "filename_short": "tests/tx_origin.sol", + "lines": [ + 9, + 10, + 11 + ], + "starting_column": 5, + "ending_column": 6 + }, + "type_specific_fields": { + "parent": { + "type": "contract", + "name": "TxOrigin", + "source_mapping": { + "start": 28, + "length": 393, + "filename_used": "/home/travis/build/crytic/slither/tests/tx_origin.sol", + "filename_relative": "tests/tx_origin.sol", + "filename_absolute": "/home/travis/build/crytic/slither/tests/tx_origin.sol", + "filename_short": "tests/tx_origin.sol", + "lines": [ + 3, + 4, + 5, + 6, + 7, + 8, + 9, + 10, + 11, + 12, + 13, + 14, + 15, + 16, + 17, + 18, + 19, + 20, + 21, + 22, + 23, + 24, + 25, + 26 + ], + "starting_column": 1, + "ending_column": 2 + } + }, + "signature": "bug0()" + } } } } - } - ] - }, - { - "check": "tx-origin", - "impact": "Medium", - "confidence": "Medium", - "description": "TxOrigin.bug2 uses tx.origin for authorization: \"tx.origin != owner\" (tests/tx_origin.sol#14-16)\n", - "elements": [ - { - "type": "node", - "name": "tx.origin != owner", - "source_mapping": { - "start": 208, - "length": 57, - "filename_used": "/home/travis/build/crytic/slither/tests/tx_origin.sol", - "filename_relative": "tests/tx_origin.sol", - "filename_absolute": "/home/travis/build/crytic/slither/tests/tx_origin.sol", - "filename_short": "tests/tx_origin.sol", - "lines": [ - 14, - 15, - 16 - ], - "starting_column": 9, - "ending_column": 10 - }, - "function": { - "type": "function", - "name": "bug2", + ] + }, + { + "check": "tx-origin", + "impact": "Medium", + "confidence": "Medium", + "description": "TxOrigin.bug2 uses tx.origin for authorization: \"tx.origin != owner\" (tests/tx_origin.sol#14-16)\n", + "elements": [ + { + "type": "node", + "name": "tx.origin != owner", "source_mapping": { - "start": 182, - "length": 89, + "start": 208, + "length": 57, "filename_used": "/home/travis/build/crytic/slither/tests/tx_origin.sol", "filename_relative": "tests/tx_origin.sol", "filename_absolute": "/home/travis/build/crytic/slither/tests/tx_origin.sol", "filename_short": "tests/tx_origin.sol", "lines": [ - 13, 14, 15, - 16, - 17 + 16 ], - "starting_column": 5, - "ending_column": 6 + "starting_column": 9, + "ending_column": 10 }, - "contract": { - "type": "contract", - "name": "TxOrigin", - "source_mapping": { - "start": 28, - "length": 393, - "filename_used": "/home/travis/build/crytic/slither/tests/tx_origin.sol", - "filename_relative": "tests/tx_origin.sol", - "filename_absolute": "/home/travis/build/crytic/slither/tests/tx_origin.sol", - "filename_short": "tests/tx_origin.sol", - "lines": [ - 3, - 4, - 5, - 6, - 7, - 8, - 9, - 10, - 11, - 12, - 13, - 14, - 15, - 16, - 17, - 18, - 19, - 20, - 21, - 22, - 23, - 24, - 25, - 26 - ], - "starting_column": 1, - "ending_column": 2 + "type_specific_fields": { + "parent": { + "type": "function", + "name": "bug2", + "source_mapping": { + "start": 182, + "length": 89, + "filename_used": "/home/travis/build/crytic/slither/tests/tx_origin.sol", + "filename_relative": "tests/tx_origin.sol", + "filename_absolute": "/home/travis/build/crytic/slither/tests/tx_origin.sol", + "filename_short": "tests/tx_origin.sol", + "lines": [ + 13, + 14, + 15, + 16, + 17 + ], + "starting_column": 5, + "ending_column": 6 + }, + "type_specific_fields": { + "parent": { + "type": "contract", + "name": "TxOrigin", + "source_mapping": { + "start": 28, + "length": 393, + "filename_used": "/home/travis/build/crytic/slither/tests/tx_origin.sol", + "filename_relative": "tests/tx_origin.sol", + "filename_absolute": "/home/travis/build/crytic/slither/tests/tx_origin.sol", + "filename_short": "tests/tx_origin.sol", + "lines": [ + 3, + 4, + 5, + 6, + 7, + 8, + 9, + 10, + 11, + 12, + 13, + 14, + 15, + 16, + 17, + 18, + 19, + 20, + 21, + 22, + 23, + 24, + 25, + 26 + ], + "starting_column": 1, + "ending_column": 2 + } + }, + "signature": "bug2()" + } } } } - } - ] - } - ] + ] + } + ] + } } \ No newline at end of file diff --git a/tests/expected_json/unchecked_lowlevel-0.5.1.unchecked-lowlevel.json b/tests/expected_json/unchecked_lowlevel-0.5.1.unchecked-lowlevel.json index d5fedf564..463896045 100644 --- a/tests/expected_json/unchecked_lowlevel-0.5.1.unchecked-lowlevel.json +++ b/tests/expected_json/unchecked_lowlevel-0.5.1.unchecked-lowlevel.json @@ -1,123 +1,133 @@ { "success": true, "error": null, - "results": [ - { - "check": "unchecked-lowlevel", - "impact": "Medium", - "confidence": "Medium", - "description": "MyConc.bad (tests/unchecked_lowlevel-0.5.1.sol#2-4) ignores return value by low-level calls \"dst.call.value(msg.value)()\" (tests/unchecked_lowlevel-0.5.1.sol#3)\n", - "elements": [ - { - "type": "node", - "name": "dst.call.value(msg.value)()", - "source_mapping": { - "start": 81, - "length": 29, - "filename_used": "/home/travis/build/crytic/slither/tests/unchecked_lowlevel-0.5.1.sol", - "filename_relative": "tests/unchecked_lowlevel-0.5.1.sol", - "filename_absolute": "/home/travis/build/crytic/slither/tests/unchecked_lowlevel-0.5.1.sol", - "filename_short": "tests/unchecked_lowlevel-0.5.1.sol", - "lines": [ - 3 - ], - "starting_column": 9, - "ending_column": 38 - }, - "function": { - "type": "function", - "name": "bad", + "results": { + "detectors": [ + { + "check": "unchecked-lowlevel", + "impact": "Medium", + "confidence": "Medium", + "description": "MyConc.bad (tests/unchecked_lowlevel-0.5.1.sol#2-4) ignores return value by low-level calls \"dst.call.value(msg.value)()\" (tests/unchecked_lowlevel-0.5.1.sol#3)\n", + "elements": [ + { + "type": "node", + "name": "dst.call.value(msg.value)()", "source_mapping": { - "start": 21, - "length": 96, + "start": 81, + "length": 29, "filename_used": "/home/travis/build/crytic/slither/tests/unchecked_lowlevel-0.5.1.sol", "filename_relative": "tests/unchecked_lowlevel-0.5.1.sol", "filename_absolute": "/home/travis/build/crytic/slither/tests/unchecked_lowlevel-0.5.1.sol", "filename_short": "tests/unchecked_lowlevel-0.5.1.sol", "lines": [ - 2, - 3, - 4 + 3 ], - "starting_column": 5, - "ending_column": 6 + "starting_column": 9, + "ending_column": 38 }, - "contract": { - "type": "contract", - "name": "MyConc", - "source_mapping": { - "start": 0, - "length": 274, - "filename_used": "/home/travis/build/crytic/slither/tests/unchecked_lowlevel-0.5.1.sol", - "filename_relative": "tests/unchecked_lowlevel-0.5.1.sol", - "filename_absolute": "/home/travis/build/crytic/slither/tests/unchecked_lowlevel-0.5.1.sol", - "filename_short": "tests/unchecked_lowlevel-0.5.1.sol", - "lines": [ - 1, - 2, - 3, - 4, - 5, - 6, - 7, - 8, - 9, - 10, - 11 - ], - "starting_column": 1, - "ending_column": 2 + "type_specific_fields": { + "parent": { + "type": "function", + "name": "bad", + "source_mapping": { + "start": 21, + "length": 96, + "filename_used": "/home/travis/build/crytic/slither/tests/unchecked_lowlevel-0.5.1.sol", + "filename_relative": "tests/unchecked_lowlevel-0.5.1.sol", + "filename_absolute": "/home/travis/build/crytic/slither/tests/unchecked_lowlevel-0.5.1.sol", + "filename_short": "tests/unchecked_lowlevel-0.5.1.sol", + "lines": [ + 2, + 3, + 4 + ], + "starting_column": 5, + "ending_column": 6 + }, + "type_specific_fields": { + "parent": { + "type": "contract", + "name": "MyConc", + "source_mapping": { + "start": 0, + "length": 274, + "filename_used": "/home/travis/build/crytic/slither/tests/unchecked_lowlevel-0.5.1.sol", + "filename_relative": "tests/unchecked_lowlevel-0.5.1.sol", + "filename_absolute": "/home/travis/build/crytic/slither/tests/unchecked_lowlevel-0.5.1.sol", + "filename_short": "tests/unchecked_lowlevel-0.5.1.sol", + "lines": [ + 1, + 2, + 3, + 4, + 5, + 6, + 7, + 8, + 9, + 10, + 11 + ], + "starting_column": 1, + "ending_column": 2 + } + }, + "signature": "bad(address)" + } } } - } - }, - { - "type": "function", - "name": "bad", - "source_mapping": { - "start": 21, - "length": 96, - "filename_used": "/home/travis/build/crytic/slither/tests/unchecked_lowlevel-0.5.1.sol", - "filename_relative": "tests/unchecked_lowlevel-0.5.1.sol", - "filename_absolute": "/home/travis/build/crytic/slither/tests/unchecked_lowlevel-0.5.1.sol", - "filename_short": "tests/unchecked_lowlevel-0.5.1.sol", - "lines": [ - 2, - 3, - 4 - ], - "starting_column": 5, - "ending_column": 6 }, - "contract": { - "type": "contract", - "name": "MyConc", + { + "type": "function", + "name": "bad", "source_mapping": { - "start": 0, - "length": 274, + "start": 21, + "length": 96, "filename_used": "/home/travis/build/crytic/slither/tests/unchecked_lowlevel-0.5.1.sol", "filename_relative": "tests/unchecked_lowlevel-0.5.1.sol", "filename_absolute": "/home/travis/build/crytic/slither/tests/unchecked_lowlevel-0.5.1.sol", "filename_short": "tests/unchecked_lowlevel-0.5.1.sol", "lines": [ - 1, 2, 3, - 4, - 5, - 6, - 7, - 8, - 9, - 10, - 11 + 4 ], - "starting_column": 1, - "ending_column": 2 + "starting_column": 5, + "ending_column": 6 + }, + "type_specific_fields": { + "parent": { + "type": "contract", + "name": "MyConc", + "source_mapping": { + "start": 0, + "length": 274, + "filename_used": "/home/travis/build/crytic/slither/tests/unchecked_lowlevel-0.5.1.sol", + "filename_relative": "tests/unchecked_lowlevel-0.5.1.sol", + "filename_absolute": "/home/travis/build/crytic/slither/tests/unchecked_lowlevel-0.5.1.sol", + "filename_short": "tests/unchecked_lowlevel-0.5.1.sol", + "lines": [ + 1, + 2, + 3, + 4, + 5, + 6, + 7, + 8, + 9, + 10, + 11 + ], + "starting_column": 1, + "ending_column": 2 + } + }, + "signature": "bad(address)" } } - } - ] - } - ] + ] + } + ] + } } \ No newline at end of file diff --git a/tests/expected_json/unchecked_lowlevel.unchecked-lowlevel.json b/tests/expected_json/unchecked_lowlevel.unchecked-lowlevel.json index 7c52cd1ad..c6a339f92 100644 --- a/tests/expected_json/unchecked_lowlevel.unchecked-lowlevel.json +++ b/tests/expected_json/unchecked_lowlevel.unchecked-lowlevel.json @@ -1,121 +1,131 @@ { "success": true, "error": null, - "results": [ - { - "check": "unchecked-lowlevel", - "impact": "Medium", - "confidence": "Medium", - "description": "MyConc.bad (tests/unchecked_lowlevel.sol#2-4) ignores return value by low-level calls \"dst.call.value(msg.value)()\" (tests/unchecked_lowlevel.sol#3)\n", - "elements": [ - { - "type": "node", - "name": "dst.call.value(msg.value)()", - "source_mapping": { - "start": 73, - "length": 29, - "filename_used": "/home/travis/build/crytic/slither/tests/unchecked_lowlevel.sol", - "filename_relative": "tests/unchecked_lowlevel.sol", - "filename_absolute": "/home/travis/build/crytic/slither/tests/unchecked_lowlevel.sol", - "filename_short": "tests/unchecked_lowlevel.sol", - "lines": [ - 3 - ], - "starting_column": 9, - "ending_column": 38 - }, - "function": { - "type": "function", - "name": "bad", + "results": { + "detectors": [ + { + "check": "unchecked-lowlevel", + "impact": "Medium", + "confidence": "Medium", + "description": "MyConc.bad (tests/unchecked_lowlevel.sol#2-4) ignores return value by low-level calls \"dst.call.value(msg.value)()\" (tests/unchecked_lowlevel.sol#3)\n", + "elements": [ + { + "type": "node", + "name": "dst.call.value(msg.value)()", "source_mapping": { - "start": 21, - "length": 88, + "start": 73, + "length": 29, "filename_used": "/home/travis/build/crytic/slither/tests/unchecked_lowlevel.sol", "filename_relative": "tests/unchecked_lowlevel.sol", "filename_absolute": "/home/travis/build/crytic/slither/tests/unchecked_lowlevel.sol", "filename_short": "tests/unchecked_lowlevel.sol", "lines": [ - 2, - 3, - 4 + 3 ], - "starting_column": 5, - "ending_column": 6 + "starting_column": 9, + "ending_column": 38 }, - "contract": { - "type": "contract", - "name": "MyConc", - "source_mapping": { - "start": 0, - "length": 214, - "filename_used": "/home/travis/build/crytic/slither/tests/unchecked_lowlevel.sol", - "filename_relative": "tests/unchecked_lowlevel.sol", - "filename_absolute": "/home/travis/build/crytic/slither/tests/unchecked_lowlevel.sol", - "filename_short": "tests/unchecked_lowlevel.sol", - "lines": [ - 1, - 2, - 3, - 4, - 5, - 6, - 7, - 8, - 9, - 10 - ], - "starting_column": 1, - "ending_column": 2 + "type_specific_fields": { + "parent": { + "type": "function", + "name": "bad", + "source_mapping": { + "start": 21, + "length": 88, + "filename_used": "/home/travis/build/crytic/slither/tests/unchecked_lowlevel.sol", + "filename_relative": "tests/unchecked_lowlevel.sol", + "filename_absolute": "/home/travis/build/crytic/slither/tests/unchecked_lowlevel.sol", + "filename_short": "tests/unchecked_lowlevel.sol", + "lines": [ + 2, + 3, + 4 + ], + "starting_column": 5, + "ending_column": 6 + }, + "type_specific_fields": { + "parent": { + "type": "contract", + "name": "MyConc", + "source_mapping": { + "start": 0, + "length": 214, + "filename_used": "/home/travis/build/crytic/slither/tests/unchecked_lowlevel.sol", + "filename_relative": "tests/unchecked_lowlevel.sol", + "filename_absolute": "/home/travis/build/crytic/slither/tests/unchecked_lowlevel.sol", + "filename_short": "tests/unchecked_lowlevel.sol", + "lines": [ + 1, + 2, + 3, + 4, + 5, + 6, + 7, + 8, + 9, + 10 + ], + "starting_column": 1, + "ending_column": 2 + } + }, + "signature": "bad(address)" + } } } - } - }, - { - "type": "function", - "name": "bad", - "source_mapping": { - "start": 21, - "length": 88, - "filename_used": "/home/travis/build/crytic/slither/tests/unchecked_lowlevel.sol", - "filename_relative": "tests/unchecked_lowlevel.sol", - "filename_absolute": "/home/travis/build/crytic/slither/tests/unchecked_lowlevel.sol", - "filename_short": "tests/unchecked_lowlevel.sol", - "lines": [ - 2, - 3, - 4 - ], - "starting_column": 5, - "ending_column": 6 }, - "contract": { - "type": "contract", - "name": "MyConc", + { + "type": "function", + "name": "bad", "source_mapping": { - "start": 0, - "length": 214, + "start": 21, + "length": 88, "filename_used": "/home/travis/build/crytic/slither/tests/unchecked_lowlevel.sol", "filename_relative": "tests/unchecked_lowlevel.sol", "filename_absolute": "/home/travis/build/crytic/slither/tests/unchecked_lowlevel.sol", "filename_short": "tests/unchecked_lowlevel.sol", "lines": [ - 1, 2, 3, - 4, - 5, - 6, - 7, - 8, - 9, - 10 + 4 ], - "starting_column": 1, - "ending_column": 2 + "starting_column": 5, + "ending_column": 6 + }, + "type_specific_fields": { + "parent": { + "type": "contract", + "name": "MyConc", + "source_mapping": { + "start": 0, + "length": 214, + "filename_used": "/home/travis/build/crytic/slither/tests/unchecked_lowlevel.sol", + "filename_relative": "tests/unchecked_lowlevel.sol", + "filename_absolute": "/home/travis/build/crytic/slither/tests/unchecked_lowlevel.sol", + "filename_short": "tests/unchecked_lowlevel.sol", + "lines": [ + 1, + 2, + 3, + 4, + 5, + 6, + 7, + 8, + 9, + 10 + ], + "starting_column": 1, + "ending_column": 2 + } + }, + "signature": "bad(address)" } } - } - ] - } - ] + ] + } + ] + } } \ No newline at end of file diff --git a/tests/expected_json/unchecked_send-0.5.1.unchecked-send.json b/tests/expected_json/unchecked_send-0.5.1.unchecked-send.json index a90e3c472..bf4bc8184 100644 --- a/tests/expected_json/unchecked_send-0.5.1.unchecked-send.json +++ b/tests/expected_json/unchecked_send-0.5.1.unchecked-send.json @@ -1,137 +1,147 @@ { "success": true, "error": null, - "results": [ - { - "check": "unchecked-send", - "impact": "Medium", - "confidence": "Medium", - "description": "MyConc.bad (tests/unchecked_send-0.5.1.sol#2-4) ignores return value by send calls \"dst.send(msg.value)\" (tests/unchecked_send-0.5.1.sol#3)\n", - "elements": [ - { - "type": "node", - "name": "dst.send(msg.value)", - "source_mapping": { - "start": 81, - "length": 19, - "filename_used": "/home/travis/build/crytic/slither/tests/unchecked_send-0.5.1.sol", - "filename_relative": "tests/unchecked_send-0.5.1.sol", - "filename_absolute": "/home/travis/build/crytic/slither/tests/unchecked_send-0.5.1.sol", - "filename_short": "tests/unchecked_send-0.5.1.sol", - "lines": [ - 3 - ], - "starting_column": 9, - "ending_column": 28 - }, - "function": { - "type": "function", - "name": "bad", + "results": { + "detectors": [ + { + "check": "unchecked-send", + "impact": "Medium", + "confidence": "Medium", + "description": "MyConc.bad (tests/unchecked_send-0.5.1.sol#2-4) ignores return value by send calls \"dst.send(msg.value)\" (tests/unchecked_send-0.5.1.sol#3)\n", + "elements": [ + { + "type": "node", + "name": "dst.send(msg.value)", "source_mapping": { - "start": 21, - "length": 86, + "start": 81, + "length": 19, "filename_used": "/home/travis/build/crytic/slither/tests/unchecked_send-0.5.1.sol", "filename_relative": "tests/unchecked_send-0.5.1.sol", "filename_absolute": "/home/travis/build/crytic/slither/tests/unchecked_send-0.5.1.sol", "filename_short": "tests/unchecked_send-0.5.1.sol", "lines": [ - 2, - 3, - 4 + 3 ], - "starting_column": 5, - "ending_column": 6 + "starting_column": 9, + "ending_column": 28 }, - "contract": { - "type": "contract", - "name": "MyConc", - "source_mapping": { - "start": 0, - "length": 419, - "filename_used": "/home/travis/build/crytic/slither/tests/unchecked_send-0.5.1.sol", - "filename_relative": "tests/unchecked_send-0.5.1.sol", - "filename_absolute": "/home/travis/build/crytic/slither/tests/unchecked_send-0.5.1.sol", - "filename_short": "tests/unchecked_send-0.5.1.sol", - "lines": [ - 1, - 2, - 3, - 4, - 5, - 6, - 7, - 8, - 9, - 10, - 11, - 12, - 13, - 14, - 15, - 16, - 17, - 18 - ], - "starting_column": 1, - "ending_column": 2 + "type_specific_fields": { + "parent": { + "type": "function", + "name": "bad", + "source_mapping": { + "start": 21, + "length": 86, + "filename_used": "/home/travis/build/crytic/slither/tests/unchecked_send-0.5.1.sol", + "filename_relative": "tests/unchecked_send-0.5.1.sol", + "filename_absolute": "/home/travis/build/crytic/slither/tests/unchecked_send-0.5.1.sol", + "filename_short": "tests/unchecked_send-0.5.1.sol", + "lines": [ + 2, + 3, + 4 + ], + "starting_column": 5, + "ending_column": 6 + }, + "type_specific_fields": { + "parent": { + "type": "contract", + "name": "MyConc", + "source_mapping": { + "start": 0, + "length": 419, + "filename_used": "/home/travis/build/crytic/slither/tests/unchecked_send-0.5.1.sol", + "filename_relative": "tests/unchecked_send-0.5.1.sol", + "filename_absolute": "/home/travis/build/crytic/slither/tests/unchecked_send-0.5.1.sol", + "filename_short": "tests/unchecked_send-0.5.1.sol", + "lines": [ + 1, + 2, + 3, + 4, + 5, + 6, + 7, + 8, + 9, + 10, + 11, + 12, + 13, + 14, + 15, + 16, + 17, + 18 + ], + "starting_column": 1, + "ending_column": 2 + } + }, + "signature": "bad(address)" + } } } - } - }, - { - "type": "function", - "name": "bad", - "source_mapping": { - "start": 21, - "length": 86, - "filename_used": "/home/travis/build/crytic/slither/tests/unchecked_send-0.5.1.sol", - "filename_relative": "tests/unchecked_send-0.5.1.sol", - "filename_absolute": "/home/travis/build/crytic/slither/tests/unchecked_send-0.5.1.sol", - "filename_short": "tests/unchecked_send-0.5.1.sol", - "lines": [ - 2, - 3, - 4 - ], - "starting_column": 5, - "ending_column": 6 }, - "contract": { - "type": "contract", - "name": "MyConc", + { + "type": "function", + "name": "bad", "source_mapping": { - "start": 0, - "length": 419, + "start": 21, + "length": 86, "filename_used": "/home/travis/build/crytic/slither/tests/unchecked_send-0.5.1.sol", "filename_relative": "tests/unchecked_send-0.5.1.sol", "filename_absolute": "/home/travis/build/crytic/slither/tests/unchecked_send-0.5.1.sol", "filename_short": "tests/unchecked_send-0.5.1.sol", "lines": [ - 1, 2, 3, - 4, - 5, - 6, - 7, - 8, - 9, - 10, - 11, - 12, - 13, - 14, - 15, - 16, - 17, - 18 + 4 ], - "starting_column": 1, - "ending_column": 2 + "starting_column": 5, + "ending_column": 6 + }, + "type_specific_fields": { + "parent": { + "type": "contract", + "name": "MyConc", + "source_mapping": { + "start": 0, + "length": 419, + "filename_used": "/home/travis/build/crytic/slither/tests/unchecked_send-0.5.1.sol", + "filename_relative": "tests/unchecked_send-0.5.1.sol", + "filename_absolute": "/home/travis/build/crytic/slither/tests/unchecked_send-0.5.1.sol", + "filename_short": "tests/unchecked_send-0.5.1.sol", + "lines": [ + 1, + 2, + 3, + 4, + 5, + 6, + 7, + 8, + 9, + 10, + 11, + 12, + 13, + 14, + 15, + 16, + 17, + 18 + ], + "starting_column": 1, + "ending_column": 2 + } + }, + "signature": "bad(address)" } } - } - ] - } - ] + ] + } + ] + } } \ No newline at end of file diff --git a/tests/expected_json/uninitialized-0.5.1.uninitialized-state.json b/tests/expected_json/uninitialized-0.5.1.uninitialized-state.json index edb84a25b..07cd618c0 100644 --- a/tests/expected_json/uninitialized-0.5.1.uninitialized-state.json +++ b/tests/expected_json/uninitialized-0.5.1.uninitialized-state.json @@ -1,426 +1,448 @@ { "success": true, "error": null, - "results": [ - { - "check": "uninitialized-state", - "impact": "High", - "confidence": "High", - "description": "Uninitialized.destination (tests/uninitialized-0.5.1.sol#5) is never initialized. It is used in:\n\t- transfer (tests/uninitialized-0.5.1.sol#7-9)\n", - "elements": [ - { - "type": "variable", - "name": "destination", - "source_mapping": { - "start": 54, - "length": 27, - "filename_used": "/home/travis/build/crytic/slither/tests/uninitialized-0.5.1.sol", - "filename_relative": "tests/uninitialized-0.5.1.sol", - "filename_absolute": "/home/travis/build/crytic/slither/tests/uninitialized-0.5.1.sol", - "filename_short": "tests/uninitialized-0.5.1.sol", - "lines": [ - 5 - ], - "starting_column": 5, - "ending_column": 32 - }, - "contract": { - "type": "contract", - "name": "Uninitialized", + "results": { + "detectors": [ + { + "check": "uninitialized-state", + "impact": "High", + "confidence": "High", + "description": "Uninitialized.destination (tests/uninitialized-0.5.1.sol#5) is never initialized. It is used in:\n\t- transfer (tests/uninitialized-0.5.1.sol#7-9)\n", + "elements": [ + { + "type": "variable", + "name": "destination", "source_mapping": { - "start": 25, - "length": 148, + "start": 54, + "length": 27, "filename_used": "/home/travis/build/crytic/slither/tests/uninitialized-0.5.1.sol", "filename_relative": "tests/uninitialized-0.5.1.sol", "filename_absolute": "/home/travis/build/crytic/slither/tests/uninitialized-0.5.1.sol", "filename_short": "tests/uninitialized-0.5.1.sol", "lines": [ - 3, - 4, - 5, - 6, - 7, - 8, - 9, - 10, - 11 + 5 ], - "starting_column": 1, - "ending_column": 2 + "starting_column": 5, + "ending_column": 32 + }, + "type_specific_fields": { + "parent": { + "type": "contract", + "name": "Uninitialized", + "source_mapping": { + "start": 25, + "length": 148, + "filename_used": "/home/travis/build/crytic/slither/tests/uninitialized-0.5.1.sol", + "filename_relative": "tests/uninitialized-0.5.1.sol", + "filename_absolute": "/home/travis/build/crytic/slither/tests/uninitialized-0.5.1.sol", + "filename_short": "tests/uninitialized-0.5.1.sol", + "lines": [ + 3, + 4, + 5, + 6, + 7, + 8, + 9, + 10, + 11 + ], + "starting_column": 1, + "ending_column": 2 + } + } } - } - }, - { - "type": "function", - "name": "transfer", - "source_mapping": { - "start": 88, - "length": 82, - "filename_used": "/home/travis/build/crytic/slither/tests/uninitialized-0.5.1.sol", - "filename_relative": "tests/uninitialized-0.5.1.sol", - "filename_absolute": "/home/travis/build/crytic/slither/tests/uninitialized-0.5.1.sol", - "filename_short": "tests/uninitialized-0.5.1.sol", - "lines": [ - 7, - 8, - 9 - ], - "starting_column": 5, - "ending_column": 6 }, - "contract": { - "type": "contract", - "name": "Uninitialized", + { + "type": "function", + "name": "transfer", "source_mapping": { - "start": 25, - "length": 148, + "start": 88, + "length": 82, "filename_used": "/home/travis/build/crytic/slither/tests/uninitialized-0.5.1.sol", "filename_relative": "tests/uninitialized-0.5.1.sol", "filename_absolute": "/home/travis/build/crytic/slither/tests/uninitialized-0.5.1.sol", "filename_short": "tests/uninitialized-0.5.1.sol", "lines": [ - 3, - 4, - 5, - 6, 7, 8, - 9, - 10, - 11 + 9 ], - "starting_column": 1, - "ending_column": 2 + "starting_column": 5, + "ending_column": 6 + }, + "type_specific_fields": { + "parent": { + "type": "contract", + "name": "Uninitialized", + "source_mapping": { + "start": 25, + "length": 148, + "filename_used": "/home/travis/build/crytic/slither/tests/uninitialized-0.5.1.sol", + "filename_relative": "tests/uninitialized-0.5.1.sol", + "filename_absolute": "/home/travis/build/crytic/slither/tests/uninitialized-0.5.1.sol", + "filename_short": "tests/uninitialized-0.5.1.sol", + "lines": [ + 3, + 4, + 5, + 6, + 7, + 8, + 9, + 10, + 11 + ], + "starting_column": 1, + "ending_column": 2 + } + }, + "signature": "transfer()" } } - } - ] - }, - { - "check": "uninitialized-state", - "impact": "High", - "confidence": "High", - "description": "Test.balances (tests/uninitialized-0.5.1.sol#15) is never initialized. It is used in:\n\t- use (tests/uninitialized-0.5.1.sol#23-26)\n", - "elements": [ - { - "type": "variable", - "name": "balances", - "source_mapping": { - "start": 196, - "length": 34, - "filename_used": "/home/travis/build/crytic/slither/tests/uninitialized-0.5.1.sol", - "filename_relative": "tests/uninitialized-0.5.1.sol", - "filename_absolute": "/home/travis/build/crytic/slither/tests/uninitialized-0.5.1.sol", - "filename_short": "tests/uninitialized-0.5.1.sol", - "lines": [ - 15 - ], - "starting_column": 5, - "ending_column": 39 - }, - "contract": { - "type": "contract", - "name": "Test", + ] + }, + { + "check": "uninitialized-state", + "impact": "High", + "confidence": "High", + "description": "Test.balances (tests/uninitialized-0.5.1.sol#15) is never initialized. It is used in:\n\t- use (tests/uninitialized-0.5.1.sol#23-26)\n", + "elements": [ + { + "type": "variable", + "name": "balances", "source_mapping": { - "start": 176, - "length": 349, + "start": 196, + "length": 34, "filename_used": "/home/travis/build/crytic/slither/tests/uninitialized-0.5.1.sol", "filename_relative": "tests/uninitialized-0.5.1.sol", "filename_absolute": "/home/travis/build/crytic/slither/tests/uninitialized-0.5.1.sol", "filename_short": "tests/uninitialized-0.5.1.sol", "lines": [ - 14, - 15, - 16, - 17, - 18, - 19, - 20, - 21, - 22, - 23, - 24, - 25, - 26, - 27 + 15 ], - "starting_column": 1, - "ending_column": 2 + "starting_column": 5, + "ending_column": 39 + }, + "type_specific_fields": { + "parent": { + "type": "contract", + "name": "Test", + "source_mapping": { + "start": 176, + "length": 349, + "filename_used": "/home/travis/build/crytic/slither/tests/uninitialized-0.5.1.sol", + "filename_relative": "tests/uninitialized-0.5.1.sol", + "filename_absolute": "/home/travis/build/crytic/slither/tests/uninitialized-0.5.1.sol", + "filename_short": "tests/uninitialized-0.5.1.sol", + "lines": [ + 14, + 15, + 16, + 17, + 18, + 19, + 20, + 21, + 22, + 23, + 24, + 25, + 26, + 27 + ], + "starting_column": 1, + "ending_column": 2 + } + } } - } - }, - { - "type": "function", - "name": "use", - "source_mapping": { - "start": 369, - "length": 154, - "filename_used": "/home/travis/build/crytic/slither/tests/uninitialized-0.5.1.sol", - "filename_relative": "tests/uninitialized-0.5.1.sol", - "filename_absolute": "/home/travis/build/crytic/slither/tests/uninitialized-0.5.1.sol", - "filename_short": "tests/uninitialized-0.5.1.sol", - "lines": [ - 23, - 24, - 25, - 26 - ], - "starting_column": 5, - "ending_column": 6 }, - "contract": { - "type": "contract", - "name": "Test", + { + "type": "function", + "name": "use", "source_mapping": { - "start": 176, - "length": 349, + "start": 369, + "length": 154, "filename_used": "/home/travis/build/crytic/slither/tests/uninitialized-0.5.1.sol", "filename_relative": "tests/uninitialized-0.5.1.sol", "filename_absolute": "/home/travis/build/crytic/slither/tests/uninitialized-0.5.1.sol", "filename_short": "tests/uninitialized-0.5.1.sol", "lines": [ - 14, - 15, - 16, - 17, - 18, - 19, - 20, - 21, - 22, 23, 24, 25, - 26, - 27 + 26 ], - "starting_column": 1, - "ending_column": 2 + "starting_column": 5, + "ending_column": 6 + }, + "type_specific_fields": { + "parent": { + "type": "contract", + "name": "Test", + "source_mapping": { + "start": 176, + "length": 349, + "filename_used": "/home/travis/build/crytic/slither/tests/uninitialized-0.5.1.sol", + "filename_relative": "tests/uninitialized-0.5.1.sol", + "filename_absolute": "/home/travis/build/crytic/slither/tests/uninitialized-0.5.1.sol", + "filename_short": "tests/uninitialized-0.5.1.sol", + "lines": [ + 14, + 15, + 16, + 17, + 18, + 19, + 20, + 21, + 22, + 23, + 24, + 25, + 26, + 27 + ], + "starting_column": 1, + "ending_column": 2 + } + }, + "signature": "use()" } } - } - ] - }, - { - "check": "uninitialized-state", - "impact": "High", - "confidence": "High", - "description": "Test2.st (tests/uninitialized-0.5.1.sol#45) is never initialized. It is used in:\n\t- use (tests/uninitialized-0.5.1.sol#53-56)\n", - "elements": [ - { - "type": "variable", - "name": "st", - "source_mapping": { - "start": 726, - "length": 15, - "filename_used": "/home/travis/build/crytic/slither/tests/uninitialized-0.5.1.sol", - "filename_relative": "tests/uninitialized-0.5.1.sol", - "filename_absolute": "/home/travis/build/crytic/slither/tests/uninitialized-0.5.1.sol", - "filename_short": "tests/uninitialized-0.5.1.sol", - "lines": [ - 45 - ], - "starting_column": 5, - "ending_column": 20 - }, - "contract": { - "type": "contract", - "name": "Test2", + ] + }, + { + "check": "uninitialized-state", + "impact": "High", + "confidence": "High", + "description": "Test2.st (tests/uninitialized-0.5.1.sol#45) is never initialized. It is used in:\n\t- use (tests/uninitialized-0.5.1.sol#53-56)\n", + "elements": [ + { + "type": "variable", + "name": "st", "source_mapping": { - "start": 672, - "length": 373, + "start": 726, + "length": 15, "filename_used": "/home/travis/build/crytic/slither/tests/uninitialized-0.5.1.sol", "filename_relative": "tests/uninitialized-0.5.1.sol", "filename_absolute": "/home/travis/build/crytic/slither/tests/uninitialized-0.5.1.sol", "filename_short": "tests/uninitialized-0.5.1.sol", "lines": [ - 42, - 43, - 44, - 45, - 46, - 47, - 48, - 49, - 50, - 51, - 52, - 53, - 54, - 55, - 56, - 57, - 58 + 45 ], - "starting_column": 1, - "ending_column": 2 + "starting_column": 5, + "ending_column": 20 + }, + "type_specific_fields": { + "parent": { + "type": "contract", + "name": "Test2", + "source_mapping": { + "start": 672, + "length": 373, + "filename_used": "/home/travis/build/crytic/slither/tests/uninitialized-0.5.1.sol", + "filename_relative": "tests/uninitialized-0.5.1.sol", + "filename_absolute": "/home/travis/build/crytic/slither/tests/uninitialized-0.5.1.sol", + "filename_short": "tests/uninitialized-0.5.1.sol", + "lines": [ + 42, + 43, + 44, + 45, + 46, + 47, + 48, + 49, + 50, + 51, + 52, + 53, + 54, + 55, + 56, + 57, + 58 + ], + "starting_column": 1, + "ending_column": 2 + } + } } - } - }, - { - "type": "function", - "name": "use", - "source_mapping": { - "start": 913, - "length": 129, - "filename_used": "/home/travis/build/crytic/slither/tests/uninitialized-0.5.1.sol", - "filename_relative": "tests/uninitialized-0.5.1.sol", - "filename_absolute": "/home/travis/build/crytic/slither/tests/uninitialized-0.5.1.sol", - "filename_short": "tests/uninitialized-0.5.1.sol", - "lines": [ - 53, - 54, - 55, - 56 - ], - "starting_column": 5, - "ending_column": 6 }, - "contract": { - "type": "contract", - "name": "Test2", + { + "type": "function", + "name": "use", "source_mapping": { - "start": 672, - "length": 373, + "start": 913, + "length": 129, "filename_used": "/home/travis/build/crytic/slither/tests/uninitialized-0.5.1.sol", "filename_relative": "tests/uninitialized-0.5.1.sol", "filename_absolute": "/home/travis/build/crytic/slither/tests/uninitialized-0.5.1.sol", "filename_short": "tests/uninitialized-0.5.1.sol", "lines": [ - 42, - 43, - 44, - 45, - 46, - 47, - 48, - 49, - 50, - 51, - 52, 53, 54, 55, - 56, - 57, - 58 + 56 ], - "starting_column": 1, - "ending_column": 2 + "starting_column": 5, + "ending_column": 6 + }, + "type_specific_fields": { + "parent": { + "type": "contract", + "name": "Test2", + "source_mapping": { + "start": 672, + "length": 373, + "filename_used": "/home/travis/build/crytic/slither/tests/uninitialized-0.5.1.sol", + "filename_relative": "tests/uninitialized-0.5.1.sol", + "filename_absolute": "/home/travis/build/crytic/slither/tests/uninitialized-0.5.1.sol", + "filename_short": "tests/uninitialized-0.5.1.sol", + "lines": [ + 42, + 43, + 44, + 45, + 46, + 47, + 48, + 49, + 50, + 51, + 52, + 53, + 54, + 55, + 56, + 57, + 58 + ], + "starting_column": 1, + "ending_column": 2 + } + }, + "signature": "use()" } } - } - ] - }, - { - "check": "uninitialized-state", - "impact": "High", - "confidence": "High", - "description": "Test2.v (tests/uninitialized-0.5.1.sol#47) is never initialized. It is used in:\n\t- init (tests/uninitialized-0.5.1.sol#49-51)\n", - "elements": [ - { - "type": "variable", - "name": "v", - "source_mapping": { - "start": 779, - "length": 6, - "filename_used": "/home/travis/build/crytic/slither/tests/uninitialized-0.5.1.sol", - "filename_relative": "tests/uninitialized-0.5.1.sol", - "filename_absolute": "/home/travis/build/crytic/slither/tests/uninitialized-0.5.1.sol", - "filename_short": "tests/uninitialized-0.5.1.sol", - "lines": [ - 47 - ], - "starting_column": 5, - "ending_column": 11 - }, - "contract": { - "type": "contract", - "name": "Test2", + ] + }, + { + "check": "uninitialized-state", + "impact": "High", + "confidence": "High", + "description": "Test2.v (tests/uninitialized-0.5.1.sol#47) is never initialized. It is used in:\n\t- init (tests/uninitialized-0.5.1.sol#49-51)\n", + "elements": [ + { + "type": "variable", + "name": "v", "source_mapping": { - "start": 672, - "length": 373, + "start": 779, + "length": 6, "filename_used": "/home/travis/build/crytic/slither/tests/uninitialized-0.5.1.sol", "filename_relative": "tests/uninitialized-0.5.1.sol", "filename_absolute": "/home/travis/build/crytic/slither/tests/uninitialized-0.5.1.sol", "filename_short": "tests/uninitialized-0.5.1.sol", "lines": [ - 42, - 43, - 44, - 45, - 46, - 47, - 48, - 49, - 50, - 51, - 52, - 53, - 54, - 55, - 56, - 57, - 58 + 47 ], - "starting_column": 1, - "ending_column": 2 + "starting_column": 5, + "ending_column": 11 + }, + "type_specific_fields": { + "parent": { + "type": "contract", + "name": "Test2", + "source_mapping": { + "start": 672, + "length": 373, + "filename_used": "/home/travis/build/crytic/slither/tests/uninitialized-0.5.1.sol", + "filename_relative": "tests/uninitialized-0.5.1.sol", + "filename_absolute": "/home/travis/build/crytic/slither/tests/uninitialized-0.5.1.sol", + "filename_short": "tests/uninitialized-0.5.1.sol", + "lines": [ + 42, + 43, + 44, + 45, + 46, + 47, + 48, + 49, + 50, + 51, + 52, + 53, + 54, + 55, + 56, + 57, + 58 + ], + "starting_column": 1, + "ending_column": 2 + } + } } - } - }, - { - "type": "function", - "name": "init", - "source_mapping": { - "start": 848, - "length": 59, - "filename_used": "/home/travis/build/crytic/slither/tests/uninitialized-0.5.1.sol", - "filename_relative": "tests/uninitialized-0.5.1.sol", - "filename_absolute": "/home/travis/build/crytic/slither/tests/uninitialized-0.5.1.sol", - "filename_short": "tests/uninitialized-0.5.1.sol", - "lines": [ - 49, - 50, - 51 - ], - "starting_column": 5, - "ending_column": 6 }, - "contract": { - "type": "contract", - "name": "Test2", + { + "type": "function", + "name": "init", "source_mapping": { - "start": 672, - "length": 373, + "start": 848, + "length": 59, "filename_used": "/home/travis/build/crytic/slither/tests/uninitialized-0.5.1.sol", "filename_relative": "tests/uninitialized-0.5.1.sol", "filename_absolute": "/home/travis/build/crytic/slither/tests/uninitialized-0.5.1.sol", "filename_short": "tests/uninitialized-0.5.1.sol", "lines": [ - 42, - 43, - 44, - 45, - 46, - 47, - 48, 49, 50, - 51, - 52, - 53, - 54, - 55, - 56, - 57, - 58 + 51 ], - "starting_column": 1, - "ending_column": 2 + "starting_column": 5, + "ending_column": 6 + }, + "type_specific_fields": { + "parent": { + "type": "contract", + "name": "Test2", + "source_mapping": { + "start": 672, + "length": 373, + "filename_used": "/home/travis/build/crytic/slither/tests/uninitialized-0.5.1.sol", + "filename_relative": "tests/uninitialized-0.5.1.sol", + "filename_absolute": "/home/travis/build/crytic/slither/tests/uninitialized-0.5.1.sol", + "filename_short": "tests/uninitialized-0.5.1.sol", + "lines": [ + 42, + 43, + 44, + 45, + 46, + 47, + 48, + 49, + 50, + 51, + 52, + 53, + 54, + 55, + 56, + 57, + 58 + ], + "starting_column": 1, + "ending_column": 2 + } + }, + "signature": "init()" } } - } - ] - } - ] + ] + } + ] + } } \ No newline at end of file diff --git a/tests/expected_json/uninitialized.uninitialized-state.json b/tests/expected_json/uninitialized.uninitialized-state.json index c1d30b553..1c46dd8c5 100644 --- a/tests/expected_json/uninitialized.uninitialized-state.json +++ b/tests/expected_json/uninitialized.uninitialized-state.json @@ -1,426 +1,448 @@ { "success": true, "error": null, - "results": [ - { - "check": "uninitialized-state", - "impact": "High", - "confidence": "High", - "description": "Uninitialized.destination (tests/uninitialized.sol#5) is never initialized. It is used in:\n\t- transfer (tests/uninitialized.sol#7-9)\n", - "elements": [ - { - "type": "variable", - "name": "destination", - "source_mapping": { - "start": 55, - "length": 19, - "filename_used": "/home/travis/build/crytic/slither/tests/uninitialized.sol", - "filename_relative": "tests/uninitialized.sol", - "filename_absolute": "/home/travis/build/crytic/slither/tests/uninitialized.sol", - "filename_short": "tests/uninitialized.sol", - "lines": [ - 5 - ], - "starting_column": 5, - "ending_column": 24 - }, - "contract": { - "type": "contract", - "name": "Uninitialized", + "results": { + "detectors": [ + { + "check": "uninitialized-state", + "impact": "High", + "confidence": "High", + "description": "Uninitialized.destination (tests/uninitialized.sol#5) is never initialized. It is used in:\n\t- transfer (tests/uninitialized.sol#7-9)\n", + "elements": [ + { + "type": "variable", + "name": "destination", "source_mapping": { - "start": 26, - "length": 140, + "start": 55, + "length": 19, "filename_used": "/home/travis/build/crytic/slither/tests/uninitialized.sol", "filename_relative": "tests/uninitialized.sol", "filename_absolute": "/home/travis/build/crytic/slither/tests/uninitialized.sol", "filename_short": "tests/uninitialized.sol", "lines": [ - 3, - 4, - 5, - 6, - 7, - 8, - 9, - 10, - 11 + 5 ], - "starting_column": 1, - "ending_column": 2 + "starting_column": 5, + "ending_column": 24 + }, + "type_specific_fields": { + "parent": { + "type": "contract", + "name": "Uninitialized", + "source_mapping": { + "start": 26, + "length": 140, + "filename_used": "/home/travis/build/crytic/slither/tests/uninitialized.sol", + "filename_relative": "tests/uninitialized.sol", + "filename_absolute": "/home/travis/build/crytic/slither/tests/uninitialized.sol", + "filename_short": "tests/uninitialized.sol", + "lines": [ + 3, + 4, + 5, + 6, + 7, + 8, + 9, + 10, + 11 + ], + "starting_column": 1, + "ending_column": 2 + } + } } - } - }, - { - "type": "function", - "name": "transfer", - "source_mapping": { - "start": 81, - "length": 82, - "filename_used": "/home/travis/build/crytic/slither/tests/uninitialized.sol", - "filename_relative": "tests/uninitialized.sol", - "filename_absolute": "/home/travis/build/crytic/slither/tests/uninitialized.sol", - "filename_short": "tests/uninitialized.sol", - "lines": [ - 7, - 8, - 9 - ], - "starting_column": 5, - "ending_column": 6 }, - "contract": { - "type": "contract", - "name": "Uninitialized", + { + "type": "function", + "name": "transfer", "source_mapping": { - "start": 26, - "length": 140, + "start": 81, + "length": 82, "filename_used": "/home/travis/build/crytic/slither/tests/uninitialized.sol", "filename_relative": "tests/uninitialized.sol", "filename_absolute": "/home/travis/build/crytic/slither/tests/uninitialized.sol", "filename_short": "tests/uninitialized.sol", "lines": [ - 3, - 4, - 5, - 6, 7, 8, - 9, - 10, - 11 + 9 ], - "starting_column": 1, - "ending_column": 2 + "starting_column": 5, + "ending_column": 6 + }, + "type_specific_fields": { + "parent": { + "type": "contract", + "name": "Uninitialized", + "source_mapping": { + "start": 26, + "length": 140, + "filename_used": "/home/travis/build/crytic/slither/tests/uninitialized.sol", + "filename_relative": "tests/uninitialized.sol", + "filename_absolute": "/home/travis/build/crytic/slither/tests/uninitialized.sol", + "filename_short": "tests/uninitialized.sol", + "lines": [ + 3, + 4, + 5, + 6, + 7, + 8, + 9, + 10, + 11 + ], + "starting_column": 1, + "ending_column": 2 + } + }, + "signature": "transfer()" } } - } - ] - }, - { - "check": "uninitialized-state", - "impact": "High", - "confidence": "High", - "description": "Test.balances (tests/uninitialized.sol#15) is never initialized. It is used in:\n\t- use (tests/uninitialized.sol#23-26)\n", - "elements": [ - { - "type": "variable", - "name": "balances", - "source_mapping": { - "start": 189, - "length": 34, - "filename_used": "/home/travis/build/crytic/slither/tests/uninitialized.sol", - "filename_relative": "tests/uninitialized.sol", - "filename_absolute": "/home/travis/build/crytic/slither/tests/uninitialized.sol", - "filename_short": "tests/uninitialized.sol", - "lines": [ - 15 - ], - "starting_column": 5, - "ending_column": 39 - }, - "contract": { - "type": "contract", - "name": "Test", + ] + }, + { + "check": "uninitialized-state", + "impact": "High", + "confidence": "High", + "description": "Test.balances (tests/uninitialized.sol#15) is never initialized. It is used in:\n\t- use (tests/uninitialized.sol#23-26)\n", + "elements": [ + { + "type": "variable", + "name": "balances", "source_mapping": { - "start": 169, - "length": 332, + "start": 189, + "length": 34, "filename_used": "/home/travis/build/crytic/slither/tests/uninitialized.sol", "filename_relative": "tests/uninitialized.sol", "filename_absolute": "/home/travis/build/crytic/slither/tests/uninitialized.sol", "filename_short": "tests/uninitialized.sol", "lines": [ - 14, - 15, - 16, - 17, - 18, - 19, - 20, - 21, - 22, - 23, - 24, - 25, - 26, - 27 + 15 ], - "starting_column": 1, - "ending_column": 2 + "starting_column": 5, + "ending_column": 39 + }, + "type_specific_fields": { + "parent": { + "type": "contract", + "name": "Test", + "source_mapping": { + "start": 169, + "length": 332, + "filename_used": "/home/travis/build/crytic/slither/tests/uninitialized.sol", + "filename_relative": "tests/uninitialized.sol", + "filename_absolute": "/home/travis/build/crytic/slither/tests/uninitialized.sol", + "filename_short": "tests/uninitialized.sol", + "lines": [ + 14, + 15, + 16, + 17, + 18, + 19, + 20, + 21, + 22, + 23, + 24, + 25, + 26, + 27 + ], + "starting_column": 1, + "ending_column": 2 + } + } } - } - }, - { - "type": "function", - "name": "use", - "source_mapping": { - "start": 356, - "length": 143, - "filename_used": "/home/travis/build/crytic/slither/tests/uninitialized.sol", - "filename_relative": "tests/uninitialized.sol", - "filename_absolute": "/home/travis/build/crytic/slither/tests/uninitialized.sol", - "filename_short": "tests/uninitialized.sol", - "lines": [ - 23, - 24, - 25, - 26 - ], - "starting_column": 5, - "ending_column": 6 }, - "contract": { - "type": "contract", - "name": "Test", + { + "type": "function", + "name": "use", "source_mapping": { - "start": 169, - "length": 332, + "start": 356, + "length": 143, "filename_used": "/home/travis/build/crytic/slither/tests/uninitialized.sol", "filename_relative": "tests/uninitialized.sol", "filename_absolute": "/home/travis/build/crytic/slither/tests/uninitialized.sol", "filename_short": "tests/uninitialized.sol", "lines": [ - 14, - 15, - 16, - 17, - 18, - 19, - 20, - 21, - 22, 23, 24, 25, - 26, - 27 + 26 ], - "starting_column": 1, - "ending_column": 2 + "starting_column": 5, + "ending_column": 6 + }, + "type_specific_fields": { + "parent": { + "type": "contract", + "name": "Test", + "source_mapping": { + "start": 169, + "length": 332, + "filename_used": "/home/travis/build/crytic/slither/tests/uninitialized.sol", + "filename_relative": "tests/uninitialized.sol", + "filename_absolute": "/home/travis/build/crytic/slither/tests/uninitialized.sol", + "filename_short": "tests/uninitialized.sol", + "lines": [ + 14, + 15, + 16, + 17, + 18, + 19, + 20, + 21, + 22, + 23, + 24, + 25, + 26, + 27 + ], + "starting_column": 1, + "ending_column": 2 + } + }, + "signature": "use()" } } - } - ] - }, - { - "check": "uninitialized-state", - "impact": "High", - "confidence": "High", - "description": "Test2.st (tests/uninitialized.sol#45) is never initialized. It is used in:\n\t- use (tests/uninitialized.sol#53-56)\n", - "elements": [ - { - "type": "variable", - "name": "st", - "source_mapping": { - "start": 695, - "length": 15, - "filename_used": "/home/travis/build/crytic/slither/tests/uninitialized.sol", - "filename_relative": "tests/uninitialized.sol", - "filename_absolute": "/home/travis/build/crytic/slither/tests/uninitialized.sol", - "filename_short": "tests/uninitialized.sol", - "lines": [ - 45 - ], - "starting_column": 5, - "ending_column": 20 - }, - "contract": { - "type": "contract", - "name": "Test2", + ] + }, + { + "check": "uninitialized-state", + "impact": "High", + "confidence": "High", + "description": "Test2.st (tests/uninitialized.sol#45) is never initialized. It is used in:\n\t- use (tests/uninitialized.sol#53-56)\n", + "elements": [ + { + "type": "variable", + "name": "st", "source_mapping": { - "start": 641, - "length": 354, + "start": 695, + "length": 15, "filename_used": "/home/travis/build/crytic/slither/tests/uninitialized.sol", "filename_relative": "tests/uninitialized.sol", "filename_absolute": "/home/travis/build/crytic/slither/tests/uninitialized.sol", "filename_short": "tests/uninitialized.sol", "lines": [ - 42, - 43, - 44, - 45, - 46, - 47, - 48, - 49, - 50, - 51, - 52, - 53, - 54, - 55, - 56, - 57, - 58 + 45 ], - "starting_column": 1, - "ending_column": 2 + "starting_column": 5, + "ending_column": 20 + }, + "type_specific_fields": { + "parent": { + "type": "contract", + "name": "Test2", + "source_mapping": { + "start": 641, + "length": 354, + "filename_used": "/home/travis/build/crytic/slither/tests/uninitialized.sol", + "filename_relative": "tests/uninitialized.sol", + "filename_absolute": "/home/travis/build/crytic/slither/tests/uninitialized.sol", + "filename_short": "tests/uninitialized.sol", + "lines": [ + 42, + 43, + 44, + 45, + 46, + 47, + 48, + 49, + 50, + 51, + 52, + 53, + 54, + 55, + 56, + 57, + 58 + ], + "starting_column": 1, + "ending_column": 2 + } + } } - } - }, - { - "type": "function", - "name": "use", - "source_mapping": { - "start": 875, - "length": 117, - "filename_used": "/home/travis/build/crytic/slither/tests/uninitialized.sol", - "filename_relative": "tests/uninitialized.sol", - "filename_absolute": "/home/travis/build/crytic/slither/tests/uninitialized.sol", - "filename_short": "tests/uninitialized.sol", - "lines": [ - 53, - 54, - 55, - 56 - ], - "starting_column": 5, - "ending_column": 6 }, - "contract": { - "type": "contract", - "name": "Test2", + { + "type": "function", + "name": "use", "source_mapping": { - "start": 641, - "length": 354, + "start": 875, + "length": 117, "filename_used": "/home/travis/build/crytic/slither/tests/uninitialized.sol", "filename_relative": "tests/uninitialized.sol", "filename_absolute": "/home/travis/build/crytic/slither/tests/uninitialized.sol", "filename_short": "tests/uninitialized.sol", "lines": [ - 42, - 43, - 44, - 45, - 46, - 47, - 48, - 49, - 50, - 51, - 52, 53, 54, 55, - 56, - 57, - 58 + 56 ], - "starting_column": 1, - "ending_column": 2 + "starting_column": 5, + "ending_column": 6 + }, + "type_specific_fields": { + "parent": { + "type": "contract", + "name": "Test2", + "source_mapping": { + "start": 641, + "length": 354, + "filename_used": "/home/travis/build/crytic/slither/tests/uninitialized.sol", + "filename_relative": "tests/uninitialized.sol", + "filename_absolute": "/home/travis/build/crytic/slither/tests/uninitialized.sol", + "filename_short": "tests/uninitialized.sol", + "lines": [ + 42, + 43, + 44, + 45, + 46, + 47, + 48, + 49, + 50, + 51, + 52, + 53, + 54, + 55, + 56, + 57, + 58 + ], + "starting_column": 1, + "ending_column": 2 + } + }, + "signature": "use()" } } - } - ] - }, - { - "check": "uninitialized-state", - "impact": "High", - "confidence": "High", - "description": "Test2.v (tests/uninitialized.sol#47) is never initialized. It is used in:\n\t- init (tests/uninitialized.sol#49-51)\n", - "elements": [ - { - "type": "variable", - "name": "v", - "source_mapping": { - "start": 748, - "length": 6, - "filename_used": "/home/travis/build/crytic/slither/tests/uninitialized.sol", - "filename_relative": "tests/uninitialized.sol", - "filename_absolute": "/home/travis/build/crytic/slither/tests/uninitialized.sol", - "filename_short": "tests/uninitialized.sol", - "lines": [ - 47 - ], - "starting_column": 5, - "ending_column": 11 - }, - "contract": { - "type": "contract", - "name": "Test2", + ] + }, + { + "check": "uninitialized-state", + "impact": "High", + "confidence": "High", + "description": "Test2.v (tests/uninitialized.sol#47) is never initialized. It is used in:\n\t- init (tests/uninitialized.sol#49-51)\n", + "elements": [ + { + "type": "variable", + "name": "v", "source_mapping": { - "start": 641, - "length": 354, + "start": 748, + "length": 6, "filename_used": "/home/travis/build/crytic/slither/tests/uninitialized.sol", "filename_relative": "tests/uninitialized.sol", "filename_absolute": "/home/travis/build/crytic/slither/tests/uninitialized.sol", "filename_short": "tests/uninitialized.sol", "lines": [ - 42, - 43, - 44, - 45, - 46, - 47, - 48, - 49, - 50, - 51, - 52, - 53, - 54, - 55, - 56, - 57, - 58 + 47 ], - "starting_column": 1, - "ending_column": 2 + "starting_column": 5, + "ending_column": 11 + }, + "type_specific_fields": { + "parent": { + "type": "contract", + "name": "Test2", + "source_mapping": { + "start": 641, + "length": 354, + "filename_used": "/home/travis/build/crytic/slither/tests/uninitialized.sol", + "filename_relative": "tests/uninitialized.sol", + "filename_absolute": "/home/travis/build/crytic/slither/tests/uninitialized.sol", + "filename_short": "tests/uninitialized.sol", + "lines": [ + 42, + 43, + 44, + 45, + 46, + 47, + 48, + 49, + 50, + 51, + 52, + 53, + 54, + 55, + 56, + 57, + 58 + ], + "starting_column": 1, + "ending_column": 2 + } + } } - } - }, - { - "type": "function", - "name": "init", - "source_mapping": { - "start": 817, - "length": 52, - "filename_used": "/home/travis/build/crytic/slither/tests/uninitialized.sol", - "filename_relative": "tests/uninitialized.sol", - "filename_absolute": "/home/travis/build/crytic/slither/tests/uninitialized.sol", - "filename_short": "tests/uninitialized.sol", - "lines": [ - 49, - 50, - 51 - ], - "starting_column": 5, - "ending_column": 6 }, - "contract": { - "type": "contract", - "name": "Test2", + { + "type": "function", + "name": "init", "source_mapping": { - "start": 641, - "length": 354, + "start": 817, + "length": 52, "filename_used": "/home/travis/build/crytic/slither/tests/uninitialized.sol", "filename_relative": "tests/uninitialized.sol", "filename_absolute": "/home/travis/build/crytic/slither/tests/uninitialized.sol", "filename_short": "tests/uninitialized.sol", "lines": [ - 42, - 43, - 44, - 45, - 46, - 47, - 48, 49, 50, - 51, - 52, - 53, - 54, - 55, - 56, - 57, - 58 + 51 ], - "starting_column": 1, - "ending_column": 2 + "starting_column": 5, + "ending_column": 6 + }, + "type_specific_fields": { + "parent": { + "type": "contract", + "name": "Test2", + "source_mapping": { + "start": 641, + "length": 354, + "filename_used": "/home/travis/build/crytic/slither/tests/uninitialized.sol", + "filename_relative": "tests/uninitialized.sol", + "filename_absolute": "/home/travis/build/crytic/slither/tests/uninitialized.sol", + "filename_short": "tests/uninitialized.sol", + "lines": [ + 42, + 43, + 44, + 45, + 46, + 47, + 48, + 49, + 50, + 51, + 52, + 53, + 54, + 55, + 56, + 57, + 58 + ], + "starting_column": 1, + "ending_column": 2 + } + }, + "signature": "init()" } } - } - ] - } - ] + ] + } + ] + } } \ No newline at end of file diff --git a/tests/expected_json/uninitialized_local_variable.uninitialized-local.json b/tests/expected_json/uninitialized_local_variable.uninitialized-local.json index fc63df777..4b403fddc 100644 --- a/tests/expected_json/uninitialized_local_variable.uninitialized-local.json +++ b/tests/expected_json/uninitialized_local_variable.uninitialized-local.json @@ -1,123 +1,133 @@ { "success": true, "error": null, - "results": [ - { - "check": "uninitialized-local", - "impact": "Medium", - "confidence": "Medium", - "description": "uint_not_init in Uninitialized.func (tests/uninitialized_local_variable.sol#4) is a local variable never initialiazed\n", - "elements": [ - { - "type": "variable", - "name": "uint_not_init", - "source_mapping": { - "start": 77, - "length": 18, - "filename_used": "/home/travis/build/crytic/slither/tests/uninitialized_local_variable.sol", - "filename_relative": "tests/uninitialized_local_variable.sol", - "filename_absolute": "/home/travis/build/crytic/slither/tests/uninitialized_local_variable.sol", - "filename_short": "tests/uninitialized_local_variable.sol", - "lines": [ - 4 - ], - "starting_column": 9, - "ending_column": 27 - }, - "function": { - "type": "function", - "name": "func", + "results": { + "detectors": [ + { + "check": "uninitialized-local", + "impact": "Medium", + "confidence": "Medium", + "description": "uint_not_init in Uninitialized.func (tests/uninitialized_local_variable.sol#4) is a local variable never initialiazed\n", + "elements": [ + { + "type": "variable", + "name": "uint_not_init", "source_mapping": { - "start": 29, - "length": 143, + "start": 77, + "length": 18, "filename_used": "/home/travis/build/crytic/slither/tests/uninitialized_local_variable.sol", "filename_relative": "tests/uninitialized_local_variable.sol", "filename_absolute": "/home/travis/build/crytic/slither/tests/uninitialized_local_variable.sol", "filename_short": "tests/uninitialized_local_variable.sol", "lines": [ - 3, - 4, - 5, - 6, - 7 + 4 ], - "starting_column": 5, - "ending_column": 6 + "starting_column": 9, + "ending_column": 27 }, - "contract": { - "type": "contract", - "name": "Uninitialized", - "source_mapping": { - "start": 0, - "length": 179, - "filename_used": "/home/travis/build/crytic/slither/tests/uninitialized_local_variable.sol", - "filename_relative": "tests/uninitialized_local_variable.sol", - "filename_absolute": "/home/travis/build/crytic/slither/tests/uninitialized_local_variable.sol", - "filename_short": "tests/uninitialized_local_variable.sol", - "lines": [ - 1, - 2, - 3, - 4, - 5, - 6, - 7, - 8, - 9 - ], - "starting_column": 1, - "ending_column": 2 + "type_specific_fields": { + "parent": { + "type": "function", + "name": "func", + "source_mapping": { + "start": 29, + "length": 143, + "filename_used": "/home/travis/build/crytic/slither/tests/uninitialized_local_variable.sol", + "filename_relative": "tests/uninitialized_local_variable.sol", + "filename_absolute": "/home/travis/build/crytic/slither/tests/uninitialized_local_variable.sol", + "filename_short": "tests/uninitialized_local_variable.sol", + "lines": [ + 3, + 4, + 5, + 6, + 7 + ], + "starting_column": 5, + "ending_column": 6 + }, + "type_specific_fields": { + "parent": { + "type": "contract", + "name": "Uninitialized", + "source_mapping": { + "start": 0, + "length": 179, + "filename_used": "/home/travis/build/crytic/slither/tests/uninitialized_local_variable.sol", + "filename_relative": "tests/uninitialized_local_variable.sol", + "filename_absolute": "/home/travis/build/crytic/slither/tests/uninitialized_local_variable.sol", + "filename_short": "tests/uninitialized_local_variable.sol", + "lines": [ + 1, + 2, + 3, + 4, + 5, + 6, + 7, + 8, + 9 + ], + "starting_column": 1, + "ending_column": 2 + } + }, + "signature": "func()" + } } } - } - }, - { - "type": "function", - "name": "func", - "source_mapping": { - "start": 29, - "length": 143, - "filename_used": "/home/travis/build/crytic/slither/tests/uninitialized_local_variable.sol", - "filename_relative": "tests/uninitialized_local_variable.sol", - "filename_absolute": "/home/travis/build/crytic/slither/tests/uninitialized_local_variable.sol", - "filename_short": "tests/uninitialized_local_variable.sol", - "lines": [ - 3, - 4, - 5, - 6, - 7 - ], - "starting_column": 5, - "ending_column": 6 }, - "contract": { - "type": "contract", - "name": "Uninitialized", + { + "type": "function", + "name": "func", "source_mapping": { - "start": 0, - "length": 179, + "start": 29, + "length": 143, "filename_used": "/home/travis/build/crytic/slither/tests/uninitialized_local_variable.sol", "filename_relative": "tests/uninitialized_local_variable.sol", "filename_absolute": "/home/travis/build/crytic/slither/tests/uninitialized_local_variable.sol", "filename_short": "tests/uninitialized_local_variable.sol", "lines": [ - 1, - 2, 3, 4, 5, 6, - 7, - 8, - 9 + 7 ], - "starting_column": 1, - "ending_column": 2 + "starting_column": 5, + "ending_column": 6 + }, + "type_specific_fields": { + "parent": { + "type": "contract", + "name": "Uninitialized", + "source_mapping": { + "start": 0, + "length": 179, + "filename_used": "/home/travis/build/crytic/slither/tests/uninitialized_local_variable.sol", + "filename_relative": "tests/uninitialized_local_variable.sol", + "filename_absolute": "/home/travis/build/crytic/slither/tests/uninitialized_local_variable.sol", + "filename_short": "tests/uninitialized_local_variable.sol", + "lines": [ + 1, + 2, + 3, + 4, + 5, + 6, + 7, + 8, + 9 + ], + "starting_column": 1, + "ending_column": 2 + } + }, + "signature": "func()" } } - } - ] - } - ] + ] + } + ] + } } \ No newline at end of file diff --git a/tests/expected_json/uninitialized_storage_pointer.uninitialized-storage.json b/tests/expected_json/uninitialized_storage_pointer.uninitialized-storage.json index 26424a105..81128da24 100644 --- a/tests/expected_json/uninitialized_storage_pointer.uninitialized-storage.json +++ b/tests/expected_json/uninitialized_storage_pointer.uninitialized-storage.json @@ -1,135 +1,145 @@ { "success": true, "error": null, - "results": [ - { - "check": "uninitialized-storage", - "impact": "High", - "confidence": "High", - "description": "st_bug in Uninitialized.func (tests/uninitialized_storage_pointer.sol#10) is a storage variable never initialiazed\n", - "elements": [ - { - "type": "variable", - "name": "st_bug", - "source_mapping": { - "start": 171, - "length": 9, - "filename_used": "/home/travis/build/crytic/slither/tests/uninitialized_storage_pointer.sol", - "filename_relative": "tests/uninitialized_storage_pointer.sol", - "filename_absolute": "/home/travis/build/crytic/slither/tests/uninitialized_storage_pointer.sol", - "filename_short": "tests/uninitialized_storage_pointer.sol", - "lines": [ - 10 - ], - "starting_column": 9, - "ending_column": 18 - }, - "function": { - "type": "function", - "name": "func", + "results": { + "detectors": [ + { + "check": "uninitialized-storage", + "impact": "High", + "confidence": "High", + "description": "st_bug in Uninitialized.func (tests/uninitialized_storage_pointer.sol#10) is a storage variable never initialiazed\n", + "elements": [ + { + "type": "variable", + "name": "st_bug", "source_mapping": { - "start": 67, - "length": 143, + "start": 171, + "length": 9, "filename_used": "/home/travis/build/crytic/slither/tests/uninitialized_storage_pointer.sol", "filename_relative": "tests/uninitialized_storage_pointer.sol", "filename_absolute": "/home/travis/build/crytic/slither/tests/uninitialized_storage_pointer.sol", "filename_short": "tests/uninitialized_storage_pointer.sol", "lines": [ - 7, - 8, - 9, - 10, - 11, - 12 + 10 ], - "starting_column": 5, - "ending_column": 6 + "starting_column": 9, + "ending_column": 18 }, - "contract": { - "type": "contract", - "name": "Uninitialized", - "source_mapping": { - "start": 0, - "length": 217, - "filename_used": "/home/travis/build/crytic/slither/tests/uninitialized_storage_pointer.sol", - "filename_relative": "tests/uninitialized_storage_pointer.sol", - "filename_absolute": "/home/travis/build/crytic/slither/tests/uninitialized_storage_pointer.sol", - "filename_short": "tests/uninitialized_storage_pointer.sol", - "lines": [ - 1, - 2, - 3, - 4, - 5, - 6, - 7, - 8, - 9, - 10, - 11, - 12, - 13, - 14 - ], - "starting_column": 1, - "ending_column": 2 + "type_specific_fields": { + "parent": { + "type": "function", + "name": "func", + "source_mapping": { + "start": 67, + "length": 143, + "filename_used": "/home/travis/build/crytic/slither/tests/uninitialized_storage_pointer.sol", + "filename_relative": "tests/uninitialized_storage_pointer.sol", + "filename_absolute": "/home/travis/build/crytic/slither/tests/uninitialized_storage_pointer.sol", + "filename_short": "tests/uninitialized_storage_pointer.sol", + "lines": [ + 7, + 8, + 9, + 10, + 11, + 12 + ], + "starting_column": 5, + "ending_column": 6 + }, + "type_specific_fields": { + "parent": { + "type": "contract", + "name": "Uninitialized", + "source_mapping": { + "start": 0, + "length": 217, + "filename_used": "/home/travis/build/crytic/slither/tests/uninitialized_storage_pointer.sol", + "filename_relative": "tests/uninitialized_storage_pointer.sol", + "filename_absolute": "/home/travis/build/crytic/slither/tests/uninitialized_storage_pointer.sol", + "filename_short": "tests/uninitialized_storage_pointer.sol", + "lines": [ + 1, + 2, + 3, + 4, + 5, + 6, + 7, + 8, + 9, + 10, + 11, + 12, + 13, + 14 + ], + "starting_column": 1, + "ending_column": 2 + } + }, + "signature": "func()" + } } } - } - }, - { - "type": "function", - "name": "func", - "source_mapping": { - "start": 67, - "length": 143, - "filename_used": "/home/travis/build/crytic/slither/tests/uninitialized_storage_pointer.sol", - "filename_relative": "tests/uninitialized_storage_pointer.sol", - "filename_absolute": "/home/travis/build/crytic/slither/tests/uninitialized_storage_pointer.sol", - "filename_short": "tests/uninitialized_storage_pointer.sol", - "lines": [ - 7, - 8, - 9, - 10, - 11, - 12 - ], - "starting_column": 5, - "ending_column": 6 }, - "contract": { - "type": "contract", - "name": "Uninitialized", + { + "type": "function", + "name": "func", "source_mapping": { - "start": 0, - "length": 217, + "start": 67, + "length": 143, "filename_used": "/home/travis/build/crytic/slither/tests/uninitialized_storage_pointer.sol", "filename_relative": "tests/uninitialized_storage_pointer.sol", "filename_absolute": "/home/travis/build/crytic/slither/tests/uninitialized_storage_pointer.sol", "filename_short": "tests/uninitialized_storage_pointer.sol", "lines": [ - 1, - 2, - 3, - 4, - 5, - 6, 7, 8, 9, 10, 11, - 12, - 13, - 14 + 12 ], - "starting_column": 1, - "ending_column": 2 + "starting_column": 5, + "ending_column": 6 + }, + "type_specific_fields": { + "parent": { + "type": "contract", + "name": "Uninitialized", + "source_mapping": { + "start": 0, + "length": 217, + "filename_used": "/home/travis/build/crytic/slither/tests/uninitialized_storage_pointer.sol", + "filename_relative": "tests/uninitialized_storage_pointer.sol", + "filename_absolute": "/home/travis/build/crytic/slither/tests/uninitialized_storage_pointer.sol", + "filename_short": "tests/uninitialized_storage_pointer.sol", + "lines": [ + 1, + 2, + 3, + 4, + 5, + 6, + 7, + 8, + 9, + 10, + 11, + 12, + 13, + 14 + ], + "starting_column": 1, + "ending_column": 2 + } + }, + "signature": "func()" } } - } - ] - } - ] + ] + } + ] + } } \ No newline at end of file diff --git a/tests/expected_json/unused_return.unused-return.json b/tests/expected_json/unused_return.unused-return.json index e7f6124cd..ad8f40b12 100644 --- a/tests/expected_json/unused_return.unused-return.json +++ b/tests/expected_json/unused_return.unused-return.json @@ -1,30 +1,100 @@ { "success": true, "error": null, - "results": [ - { - "check": "unused-return", - "impact": "Medium", - "confidence": "Medium", - "description": "User.test (tests/unused_return.sol#17-29) ignores return value by external calls \"t.f()\" (tests/unused_return.sol#18)\n", - "elements": [ - { - "type": "node", - "name": "t.f()", - "source_mapping": { - "start": 279, - "length": 5, - "filename_used": "/home/travis/build/crytic/slither/tests/unused_return.sol", - "filename_relative": "tests/unused_return.sol", - "filename_absolute": "/home/travis/build/crytic/slither/tests/unused_return.sol", - "filename_short": "tests/unused_return.sol", - "lines": [ - 18 - ], - "starting_column": 9, - "ending_column": 14 + "results": { + "detectors": [ + { + "check": "unused-return", + "impact": "Medium", + "confidence": "Medium", + "description": "User.test (tests/unused_return.sol#17-29) ignores return value by external calls \"t.f()\" (tests/unused_return.sol#18)\n", + "elements": [ + { + "type": "node", + "name": "t.f()", + "source_mapping": { + "start": 279, + "length": 5, + "filename_used": "/home/travis/build/crytic/slither/tests/unused_return.sol", + "filename_relative": "tests/unused_return.sol", + "filename_absolute": "/home/travis/build/crytic/slither/tests/unused_return.sol", + "filename_short": "tests/unused_return.sol", + "lines": [ + 18 + ], + "starting_column": 9, + "ending_column": 14 + }, + "type_specific_fields": { + "parent": { + "type": "function", + "name": "test", + "source_mapping": { + "start": 239, + "length": 354, + "filename_used": "/home/travis/build/crytic/slither/tests/unused_return.sol", + "filename_relative": "tests/unused_return.sol", + "filename_absolute": "/home/travis/build/crytic/slither/tests/unused_return.sol", + "filename_short": "tests/unused_return.sol", + "lines": [ + 17, + 18, + 19, + 20, + 21, + 22, + 23, + 24, + 25, + 26, + 27, + 28, + 29 + ], + "starting_column": 5, + "ending_column": 6 + }, + "type_specific_fields": { + "parent": { + "type": "contract", + "name": "User", + "source_mapping": { + "start": 189, + "length": 406, + "filename_used": "/home/travis/build/crytic/slither/tests/unused_return.sol", + "filename_relative": "tests/unused_return.sol", + "filename_absolute": "/home/travis/build/crytic/slither/tests/unused_return.sol", + "filename_short": "tests/unused_return.sol", + "lines": [ + 13, + 14, + 15, + 16, + 17, + 18, + 19, + 20, + 21, + 22, + 23, + 24, + 25, + 26, + 27, + 28, + 29, + 30 + ], + "starting_column": 1, + "ending_column": 2 + } + }, + "signature": "test(Target)" + } + } + } }, - "function": { + { "type": "function", "name": "test", "source_mapping": { @@ -52,130 +122,138 @@ "starting_column": 5, "ending_column": 6 }, - "contract": { - "type": "contract", - "name": "User", - "source_mapping": { - "start": 189, - "length": 406, - "filename_used": "/home/travis/build/crytic/slither/tests/unused_return.sol", - "filename_relative": "tests/unused_return.sol", - "filename_absolute": "/home/travis/build/crytic/slither/tests/unused_return.sol", - "filename_short": "tests/unused_return.sol", - "lines": [ - 13, - 14, - 15, - 16, - 17, - 18, - 19, - 20, - 21, - 22, - 23, - 24, - 25, - 26, - 27, - 28, - 29, - 30 - ], - "starting_column": 1, - "ending_column": 2 - } + "type_specific_fields": { + "parent": { + "type": "contract", + "name": "User", + "source_mapping": { + "start": 189, + "length": 406, + "filename_used": "/home/travis/build/crytic/slither/tests/unused_return.sol", + "filename_relative": "tests/unused_return.sol", + "filename_absolute": "/home/travis/build/crytic/slither/tests/unused_return.sol", + "filename_short": "tests/unused_return.sol", + "lines": [ + 13, + 14, + 15, + 16, + 17, + 18, + 19, + 20, + 21, + 22, + 23, + 24, + 25, + 26, + 27, + 28, + 29, + 30 + ], + "starting_column": 1, + "ending_column": 2 + } + }, + "signature": "test(Target)" } } - }, - { - "type": "function", - "name": "test", - "source_mapping": { - "start": 239, - "length": 354, - "filename_used": "/home/travis/build/crytic/slither/tests/unused_return.sol", - "filename_relative": "tests/unused_return.sol", - "filename_absolute": "/home/travis/build/crytic/slither/tests/unused_return.sol", - "filename_short": "tests/unused_return.sol", - "lines": [ - 17, - 18, - 19, - 20, - 21, - 22, - 23, - 24, - 25, - 26, - 27, - 28, - 29 - ], - "starting_column": 5, - "ending_column": 6 - }, - "contract": { - "type": "contract", - "name": "User", + ] + }, + { + "check": "unused-return", + "impact": "Medium", + "confidence": "Medium", + "description": "User.test (tests/unused_return.sol#17-29) ignores return value by external calls \"a.add(0)\" (tests/unused_return.sol#22)\n", + "elements": [ + { + "type": "node", + "name": "a.add(0)", "source_mapping": { - "start": 189, - "length": 406, + "start": 353, + "length": 8, "filename_used": "/home/travis/build/crytic/slither/tests/unused_return.sol", "filename_relative": "tests/unused_return.sol", "filename_absolute": "/home/travis/build/crytic/slither/tests/unused_return.sol", "filename_short": "tests/unused_return.sol", "lines": [ - 13, - 14, - 15, - 16, - 17, - 18, - 19, - 20, - 21, - 22, - 23, - 24, - 25, - 26, - 27, - 28, - 29, - 30 + 22 ], - "starting_column": 1, - "ending_column": 2 + "starting_column": 9, + "ending_column": 17 + }, + "type_specific_fields": { + "parent": { + "type": "function", + "name": "test", + "source_mapping": { + "start": 239, + "length": 354, + "filename_used": "/home/travis/build/crytic/slither/tests/unused_return.sol", + "filename_relative": "tests/unused_return.sol", + "filename_absolute": "/home/travis/build/crytic/slither/tests/unused_return.sol", + "filename_short": "tests/unused_return.sol", + "lines": [ + 17, + 18, + 19, + 20, + 21, + 22, + 23, + 24, + 25, + 26, + 27, + 28, + 29 + ], + "starting_column": 5, + "ending_column": 6 + }, + "type_specific_fields": { + "parent": { + "type": "contract", + "name": "User", + "source_mapping": { + "start": 189, + "length": 406, + "filename_used": "/home/travis/build/crytic/slither/tests/unused_return.sol", + "filename_relative": "tests/unused_return.sol", + "filename_absolute": "/home/travis/build/crytic/slither/tests/unused_return.sol", + "filename_short": "tests/unused_return.sol", + "lines": [ + 13, + 14, + 15, + 16, + 17, + 18, + 19, + 20, + 21, + 22, + 23, + 24, + 25, + 26, + 27, + 28, + 29, + 30 + ], + "starting_column": 1, + "ending_column": 2 + } + }, + "signature": "test(Target)" + } + } } - } - } - ] - }, - { - "check": "unused-return", - "impact": "Medium", - "confidence": "Medium", - "description": "User.test (tests/unused_return.sol#17-29) ignores return value by external calls \"a.add(0)\" (tests/unused_return.sol#22)\n", - "elements": [ - { - "type": "node", - "name": "a.add(0)", - "source_mapping": { - "start": 353, - "length": 8, - "filename_used": "/home/travis/build/crytic/slither/tests/unused_return.sol", - "filename_relative": "tests/unused_return.sol", - "filename_absolute": "/home/travis/build/crytic/slither/tests/unused_return.sol", - "filename_short": "tests/unused_return.sol", - "lines": [ - 22 - ], - "starting_column": 9, - "ending_column": 17 }, - "function": { + { "type": "function", "name": "test", "source_mapping": { @@ -203,106 +281,46 @@ "starting_column": 5, "ending_column": 6 }, - "contract": { - "type": "contract", - "name": "User", - "source_mapping": { - "start": 189, - "length": 406, - "filename_used": "/home/travis/build/crytic/slither/tests/unused_return.sol", - "filename_relative": "tests/unused_return.sol", - "filename_absolute": "/home/travis/build/crytic/slither/tests/unused_return.sol", - "filename_short": "tests/unused_return.sol", - "lines": [ - 13, - 14, - 15, - 16, - 17, - 18, - 19, - 20, - 21, - 22, - 23, - 24, - 25, - 26, - 27, - 28, - 29, - 30 - ], - "starting_column": 1, - "ending_column": 2 - } - } - } - }, - { - "type": "function", - "name": "test", - "source_mapping": { - "start": 239, - "length": 354, - "filename_used": "/home/travis/build/crytic/slither/tests/unused_return.sol", - "filename_relative": "tests/unused_return.sol", - "filename_absolute": "/home/travis/build/crytic/slither/tests/unused_return.sol", - "filename_short": "tests/unused_return.sol", - "lines": [ - 17, - 18, - 19, - 20, - 21, - 22, - 23, - 24, - 25, - 26, - 27, - 28, - 29 - ], - "starting_column": 5, - "ending_column": 6 - }, - "contract": { - "type": "contract", - "name": "User", - "source_mapping": { - "start": 189, - "length": 406, - "filename_used": "/home/travis/build/crytic/slither/tests/unused_return.sol", - "filename_relative": "tests/unused_return.sol", - "filename_absolute": "/home/travis/build/crytic/slither/tests/unused_return.sol", - "filename_short": "tests/unused_return.sol", - "lines": [ - 13, - 14, - 15, - 16, - 17, - 18, - 19, - 20, - 21, - 22, - 23, - 24, - 25, - 26, - 27, - 28, - 29, - 30 - ], - "starting_column": 1, - "ending_column": 2 + "type_specific_fields": { + "parent": { + "type": "contract", + "name": "User", + "source_mapping": { + "start": 189, + "length": 406, + "filename_used": "/home/travis/build/crytic/slither/tests/unused_return.sol", + "filename_relative": "tests/unused_return.sol", + "filename_absolute": "/home/travis/build/crytic/slither/tests/unused_return.sol", + "filename_short": "tests/unused_return.sol", + "lines": [ + 13, + 14, + 15, + 16, + 17, + 18, + 19, + 20, + 21, + 22, + 23, + 24, + 25, + 26, + 27, + 28, + 29, + 30 + ], + "starting_column": 1, + "ending_column": 2 + } + }, + "signature": "test(Target)" } } - } - ] - } - ] + ] + } + ] + } } \ No newline at end of file diff --git a/tests/expected_json/unused_state.unused-state.json b/tests/expected_json/unused_state.unused-state.json index 416f89a1d..14033ad66 100644 --- a/tests/expected_json/unused_state.unused-state.json +++ b/tests/expected_json/unused_state.unused-state.json @@ -1,286 +1,296 @@ { "success": true, "error": null, - "results": [ - { - "check": "unused-state", - "impact": "Informational", - "confidence": "High", - "description": "A.unused (tests/unused_state.sol#4) is never used in B\n", - "elements": [ - { - "type": "variable", - "name": "unused", - "source_mapping": { - "start": 44, - "length": 14, - "filename_used": "/home/travis/build/crytic/slither/tests/unused_state.sol", - "filename_relative": "tests/unused_state.sol", - "filename_absolute": "/home/travis/build/crytic/slither/tests/unused_state.sol", - "filename_short": "tests/unused_state.sol", - "lines": [ - 4 - ], - "starting_column": 5, - "ending_column": 19 + "results": { + "detectors": [ + { + "check": "unused-state", + "impact": "Informational", + "confidence": "High", + "description": "A.unused (tests/unused_state.sol#4) is never used in B\n", + "elements": [ + { + "type": "variable", + "name": "unused", + "source_mapping": { + "start": 44, + "length": 14, + "filename_used": "/home/travis/build/crytic/slither/tests/unused_state.sol", + "filename_relative": "tests/unused_state.sol", + "filename_absolute": "/home/travis/build/crytic/slither/tests/unused_state.sol", + "filename_short": "tests/unused_state.sol", + "lines": [ + 4 + ], + "starting_column": 5, + "ending_column": 19 + }, + "type_specific_fields": { + "parent": { + "type": "contract", + "name": "A", + "source_mapping": { + "start": 28, + "length": 114, + "filename_used": "/home/travis/build/crytic/slither/tests/unused_state.sol", + "filename_relative": "tests/unused_state.sol", + "filename_absolute": "/home/travis/build/crytic/slither/tests/unused_state.sol", + "filename_short": "tests/unused_state.sol", + "lines": [ + 3, + 4, + 5, + 6, + 7, + 8, + 9 + ], + "starting_column": 1, + "ending_column": 2 + } + } + } }, - "contract": { + { "type": "contract", - "name": "A", + "name": "B", "source_mapping": { - "start": 28, - "length": 114, + "start": 144, + "length": 78, "filename_used": "/home/travis/build/crytic/slither/tests/unused_state.sol", "filename_relative": "tests/unused_state.sol", "filename_absolute": "/home/travis/build/crytic/slither/tests/unused_state.sol", "filename_short": "tests/unused_state.sol", "lines": [ - 3, - 4, - 5, - 6, - 7, - 8, - 9 + 11, + 12, + 13, + 14, + 15, + 16 ], "starting_column": 1, "ending_column": 2 } } - }, - { - "type": "contract", - "name": "B", - "source_mapping": { - "start": 144, - "length": 78, - "filename_used": "/home/travis/build/crytic/slither/tests/unused_state.sol", - "filename_relative": "tests/unused_state.sol", - "filename_absolute": "/home/travis/build/crytic/slither/tests/unused_state.sol", - "filename_short": "tests/unused_state.sol", - "lines": [ - 11, - 12, - 13, - 14, - 15, - 16 - ], - "starting_column": 1, - "ending_column": 2 - } - } - ] - }, - { - "check": "unused-state", - "impact": "Informational", - "confidence": "High", - "description": "A.unused2 (tests/unused_state.sol#5) is never used in B\n", - "elements": [ - { - "type": "variable", - "name": "unused2", - "source_mapping": { - "start": 64, - "length": 15, - "filename_used": "/home/travis/build/crytic/slither/tests/unused_state.sol", - "filename_relative": "tests/unused_state.sol", - "filename_absolute": "/home/travis/build/crytic/slither/tests/unused_state.sol", - "filename_short": "tests/unused_state.sol", - "lines": [ - 5 - ], - "starting_column": 5, - "ending_column": 20 + ] + }, + { + "check": "unused-state", + "impact": "Informational", + "confidence": "High", + "description": "A.unused2 (tests/unused_state.sol#5) is never used in B\n", + "elements": [ + { + "type": "variable", + "name": "unused2", + "source_mapping": { + "start": 64, + "length": 15, + "filename_used": "/home/travis/build/crytic/slither/tests/unused_state.sol", + "filename_relative": "tests/unused_state.sol", + "filename_absolute": "/home/travis/build/crytic/slither/tests/unused_state.sol", + "filename_short": "tests/unused_state.sol", + "lines": [ + 5 + ], + "starting_column": 5, + "ending_column": 20 + }, + "type_specific_fields": { + "parent": { + "type": "contract", + "name": "A", + "source_mapping": { + "start": 28, + "length": 114, + "filename_used": "/home/travis/build/crytic/slither/tests/unused_state.sol", + "filename_relative": "tests/unused_state.sol", + "filename_absolute": "/home/travis/build/crytic/slither/tests/unused_state.sol", + "filename_short": "tests/unused_state.sol", + "lines": [ + 3, + 4, + 5, + 6, + 7, + 8, + 9 + ], + "starting_column": 1, + "ending_column": 2 + } + } + } }, - "contract": { + { "type": "contract", - "name": "A", + "name": "B", "source_mapping": { - "start": 28, - "length": 114, + "start": 144, + "length": 78, "filename_used": "/home/travis/build/crytic/slither/tests/unused_state.sol", "filename_relative": "tests/unused_state.sol", "filename_absolute": "/home/travis/build/crytic/slither/tests/unused_state.sol", "filename_short": "tests/unused_state.sol", "lines": [ - 3, - 4, - 5, - 6, - 7, - 8, - 9 + 11, + 12, + 13, + 14, + 15, + 16 ], "starting_column": 1, "ending_column": 2 } } - }, - { - "type": "contract", - "name": "B", - "source_mapping": { - "start": 144, - "length": 78, - "filename_used": "/home/travis/build/crytic/slither/tests/unused_state.sol", - "filename_relative": "tests/unused_state.sol", - "filename_absolute": "/home/travis/build/crytic/slither/tests/unused_state.sol", - "filename_short": "tests/unused_state.sol", - "lines": [ - 11, - 12, - 13, - 14, - 15, - 16 - ], - "starting_column": 1, - "ending_column": 2 - } - } - ] - }, - { - "check": "unused-state", - "impact": "Informational", - "confidence": "High", - "description": "A.unused3 (tests/unused_state.sol#6) is never used in B\n", - "elements": [ - { - "type": "variable", - "name": "unused3", - "source_mapping": { - "start": 85, - "length": 15, - "filename_used": "/home/travis/build/crytic/slither/tests/unused_state.sol", - "filename_relative": "tests/unused_state.sol", - "filename_absolute": "/home/travis/build/crytic/slither/tests/unused_state.sol", - "filename_short": "tests/unused_state.sol", - "lines": [ - 6 - ], - "starting_column": 5, - "ending_column": 20 + ] + }, + { + "check": "unused-state", + "impact": "Informational", + "confidence": "High", + "description": "A.unused3 (tests/unused_state.sol#6) is never used in B\n", + "elements": [ + { + "type": "variable", + "name": "unused3", + "source_mapping": { + "start": 85, + "length": 15, + "filename_used": "/home/travis/build/crytic/slither/tests/unused_state.sol", + "filename_relative": "tests/unused_state.sol", + "filename_absolute": "/home/travis/build/crytic/slither/tests/unused_state.sol", + "filename_short": "tests/unused_state.sol", + "lines": [ + 6 + ], + "starting_column": 5, + "ending_column": 20 + }, + "type_specific_fields": { + "parent": { + "type": "contract", + "name": "A", + "source_mapping": { + "start": 28, + "length": 114, + "filename_used": "/home/travis/build/crytic/slither/tests/unused_state.sol", + "filename_relative": "tests/unused_state.sol", + "filename_absolute": "/home/travis/build/crytic/slither/tests/unused_state.sol", + "filename_short": "tests/unused_state.sol", + "lines": [ + 3, + 4, + 5, + 6, + 7, + 8, + 9 + ], + "starting_column": 1, + "ending_column": 2 + } + } + } }, - "contract": { + { "type": "contract", - "name": "A", + "name": "B", "source_mapping": { - "start": 28, - "length": 114, + "start": 144, + "length": 78, "filename_used": "/home/travis/build/crytic/slither/tests/unused_state.sol", "filename_relative": "tests/unused_state.sol", "filename_absolute": "/home/travis/build/crytic/slither/tests/unused_state.sol", "filename_short": "tests/unused_state.sol", "lines": [ - 3, - 4, - 5, - 6, - 7, - 8, - 9 + 11, + 12, + 13, + 14, + 15, + 16 ], "starting_column": 1, "ending_column": 2 } } - }, - { - "type": "contract", - "name": "B", - "source_mapping": { - "start": 144, - "length": 78, - "filename_used": "/home/travis/build/crytic/slither/tests/unused_state.sol", - "filename_relative": "tests/unused_state.sol", - "filename_absolute": "/home/travis/build/crytic/slither/tests/unused_state.sol", - "filename_short": "tests/unused_state.sol", - "lines": [ - 11, - 12, - 13, - 14, - 15, - 16 - ], - "starting_column": 1, - "ending_column": 2 - } - } - ] - }, - { - "check": "unused-state", - "impact": "Informational", - "confidence": "High", - "description": "A.unused4 (tests/unused_state.sol#7) is never used in B\n", - "elements": [ - { - "type": "variable", - "name": "unused4", - "source_mapping": { - "start": 106, - "length": 15, - "filename_used": "/home/travis/build/crytic/slither/tests/unused_state.sol", - "filename_relative": "tests/unused_state.sol", - "filename_absolute": "/home/travis/build/crytic/slither/tests/unused_state.sol", - "filename_short": "tests/unused_state.sol", - "lines": [ - 7 - ], - "starting_column": 5, - "ending_column": 20 + ] + }, + { + "check": "unused-state", + "impact": "Informational", + "confidence": "High", + "description": "A.unused4 (tests/unused_state.sol#7) is never used in B\n", + "elements": [ + { + "type": "variable", + "name": "unused4", + "source_mapping": { + "start": 106, + "length": 15, + "filename_used": "/home/travis/build/crytic/slither/tests/unused_state.sol", + "filename_relative": "tests/unused_state.sol", + "filename_absolute": "/home/travis/build/crytic/slither/tests/unused_state.sol", + "filename_short": "tests/unused_state.sol", + "lines": [ + 7 + ], + "starting_column": 5, + "ending_column": 20 + }, + "type_specific_fields": { + "parent": { + "type": "contract", + "name": "A", + "source_mapping": { + "start": 28, + "length": 114, + "filename_used": "/home/travis/build/crytic/slither/tests/unused_state.sol", + "filename_relative": "tests/unused_state.sol", + "filename_absolute": "/home/travis/build/crytic/slither/tests/unused_state.sol", + "filename_short": "tests/unused_state.sol", + "lines": [ + 3, + 4, + 5, + 6, + 7, + 8, + 9 + ], + "starting_column": 1, + "ending_column": 2 + } + } + } }, - "contract": { + { "type": "contract", - "name": "A", + "name": "B", "source_mapping": { - "start": 28, - "length": 114, + "start": 144, + "length": 78, "filename_used": "/home/travis/build/crytic/slither/tests/unused_state.sol", "filename_relative": "tests/unused_state.sol", "filename_absolute": "/home/travis/build/crytic/slither/tests/unused_state.sol", "filename_short": "tests/unused_state.sol", "lines": [ - 3, - 4, - 5, - 6, - 7, - 8, - 9 + 11, + 12, + 13, + 14, + 15, + 16 ], "starting_column": 1, "ending_column": 2 } } - }, - { - "type": "contract", - "name": "B", - "source_mapping": { - "start": 144, - "length": 78, - "filename_used": "/home/travis/build/crytic/slither/tests/unused_state.sol", - "filename_relative": "tests/unused_state.sol", - "filename_absolute": "/home/travis/build/crytic/slither/tests/unused_state.sol", - "filename_short": "tests/unused_state.sol", - "lines": [ - 11, - 12, - 13, - 14, - 15, - 16 - ], - "starting_column": 1, - "ending_column": 2 - } - } - ] - } - ] + ] + } + ] + } } \ No newline at end of file From 6834d4c78767d21efea51e557125066629bc3d23 Mon Sep 17 00:00:00 2001 From: Josselin Date: Mon, 13 May 2019 11:28:03 +0100 Subject: [PATCH 40/55] Improve type propagation for variable acceded through base contract name --- slither/slithir/convert.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/slither/slithir/convert.py b/slither/slithir/convert.py index 31b141a57..a1b15d5b5 100644 --- a/slither/slithir/convert.py +++ b/slither/slithir/convert.py @@ -426,6 +426,12 @@ def propagate_types(ir, node): f = next((f for f in type_t.functions if f.name == ir.variable_right), None) if f: ir.lvalue.set_type(f) + else: + # Allow propgation for variable access through contract's nale + # like Base_contract.my_variable + v = next((v for v in type_t.state_variables if v.name == ir.variable_right), None) + if v: + ir.lvalue.set_type(v.type) elif isinstance(ir, NewArray): ir.lvalue.set_type(ir.array_type) elif isinstance(ir, NewContract): From 6ec7814afbd8b65c04a3f2c0147fa69e3edf309d Mon Sep 17 00:00:00 2001 From: Josselin Date: Mon, 13 May 2019 11:54:53 +0100 Subject: [PATCH 41/55] Improve solc-version detector (fix 189) --- scripts/tests_generate_expected_json_5.sh | 1 + scripts/travis_test_5.sh | 1 + .../detectors/attributes/incorrect_solc.py | 32 +++++--- ...on_incorrect_05.ast.json.solc-version.json | 69 ++++++++++++++++ ...ion_incorrect_05.ast.json.solc-version.txt | 5 ++ tests/solc_version_incorrect_05.ast.json | 82 +++++++++++++++++++ tests/solc_version_incorrect_05.sol | 7 ++ 7 files changed, 187 insertions(+), 10 deletions(-) create mode 100644 tests/expected_json/solc_version_incorrect_05.ast.json.solc-version.json create mode 100644 tests/expected_json/solc_version_incorrect_05.ast.json.solc-version.txt create mode 100644 tests/solc_version_incorrect_05.ast.json create mode 100644 tests/solc_version_incorrect_05.sol diff --git a/scripts/tests_generate_expected_json_5.sh b/scripts/tests_generate_expected_json_5.sh index eb06d8e4e..fb9552437 100755 --- a/scripts/tests_generate_expected_json_5.sh +++ b/scripts/tests_generate_expected_json_5.sh @@ -20,6 +20,7 @@ generate_expected_json(){ sed "s|$CURRENT_PATH|$TRAVIS_PATH|g" "$output_filename_txt" -i } +#generate_expected_json tests/solc_version_incorrect_05.ast.json "solc-version" #generate_expected_json tests/uninitialized-0.5.1.sol "uninitialized-state" #generate_expected_json tests/backdoor.sol "backdoor" #generate_expected_json tests/backdoor.sol "suicidal" diff --git a/scripts/travis_test_5.sh b/scripts/travis_test_5.sh index 5f12d765d..1c9276eac 100755 --- a/scripts/travis_test_5.sh +++ b/scripts/travis_test_5.sh @@ -69,6 +69,7 @@ test_slither(){ } +test_slither tests/solc_version_incorrect_05.ast.json "solc-version" test_slither tests/unchecked_lowlevel-0.5.1.sol "unchecked-lowlevel" test_slither tests/unchecked_send-0.5.1.sol "unchecked-send" test_slither tests/uninitialized-0.5.1.sol "uninitialized-state" diff --git a/slither/detectors/attributes/incorrect_solc.py b/slither/detectors/attributes/incorrect_solc.py index 937f99212..c8fb43109 100644 --- a/slither/detectors/attributes/incorrect_solc.py +++ b/slither/detectors/attributes/incorrect_solc.py @@ -23,31 +23,43 @@ class IncorrectSolc(AbstractDetector): IMPACT = DetectorClassification.INFORMATIONAL CONFIDENCE = DetectorClassification.HIGH - WIKI = 'https://github.com/crytic/slither/wiki/Detector-Documentation#incorrect-version-of-solidity' + WIKI = 'https://github.com/crytic/slither/wiki/Detector-Documentation#incorrect-versions-of-solidity' WIKI_TITLE = 'Incorrect versions of Solidity' WIKI_DESCRIPTION = ''' Solc frequently releases new compiler versions. Using an old version prevents access to new Solidity security checks. We recommend avoiding complex pragma statement.''' - WIKI_RECOMMENDATION = 'Use Solidity 0.4.25 or 0.5.2.' + WIKI_RECOMMENDATION = ''' +Use Solidity 0.4.25 or 0.5.3. Consider using the latest version of Solidity for testing the compilation, and a trusted version for deploying.''' - COMPLEX_PRAGMA = "is too complex" - OLD_VERSION = "allows old versions" - LESS_THAN = "uses lesser than" + COMPLEX_PRAGMA_TXT = "is too complex" + OLD_VERSION_TXT = "allows old versions" + LESS_THAN_TXT = "uses lesser than" + + TOO_RECENT_VERSION_TXT = "necessitates versions too recent to be trusted. Consider deploying with 0.5.3" + BUGGY_VERSION_TXT = "is known to contain severe issue (https://solidity.readthedocs.io/en/v0.5.8/bugs.html)" # Indicates the allowed versions. - ALLOWED_VERSIONS = ["0.4.24", "0.4.25", "0.5.2", "0.5.3"] + ALLOWED_VERSIONS = ["0.4.25", "0.4.26", "0.5.3"] + # Indicates the versions too recent. + TOO_RECENT_VERSIONS = ["0.5.4", "0.5.7", "0.5.8", "0.5.9", "0.5.10"] + # Indicates the versions that should not be used. + BUGGY_VERSIONS = ["0.4.22", "0.5.5", "0.5.6", "^0.4.22", "^0.5.5", "^0.5.6"] def _check_version(self, version): op = version[0] if op and not op in ['>', '>=', '^']: - return self.LESS_THAN + return self.LESS_THAN_TXT version_number = '.'.join(version[2:]) if version_number not in self.ALLOWED_VERSIONS: - return self.OLD_VERSION + if version_number in self.TOO_RECENT_VERSIONS: + return self.TOO_RECENT_VERSION_TXT + return self.OLD_VERSION_TXT return None def _check_pragma(self, version): + if version in self.BUGGY_VERSIONS: + return self.BUGGY_VERSION_TXT versions = PATTERN.findall(version) if len(versions) == 1: version = versions[0] @@ -58,10 +70,10 @@ We recommend avoiding complex pragma statement.''' # Only allow two elements if the second one is # <0.5.0 or <0.6.0 if version_right not in [('<', '', '0', '5', '0'), ('<', '', '0', '6', '0')]: - return self.COMPLEX_PRAGMA + return self.COMPLEX_PRAGMA_TXT return self._check_version(version_left) else: - return self.COMPLEX_PRAGMA + return self.COMPLEX_PRAGMA_TXT def _detect(self): """ Detects pragma statements that allow for outdated solc versions. diff --git a/tests/expected_json/solc_version_incorrect_05.ast.json.solc-version.json b/tests/expected_json/solc_version_incorrect_05.ast.json.solc-version.json new file mode 100644 index 000000000..5e65c602d --- /dev/null +++ b/tests/expected_json/solc_version_incorrect_05.ast.json.solc-version.json @@ -0,0 +1,69 @@ +{ + "success": true, + "error": null, + "results": { + "detectors": [ + { + "check": "solc-version", + "impact": "Informational", + "confidence": "High", + "description": "Pragma version \"^0.5.5\" is known to contain severe issue (https://solidity.readthedocs.io/en/v0.5.8/bugs.html) (None)\n", + "elements": [ + { + "type": "pragma", + "name": "^0.5.5", + "source_mapping": { + "start": 63, + "length": 23, + "filename_used": "solc_version_incorrect_05.sol", + "filename_relative": null, + "filename_absolute": null, + "filename_short": null, + "lines": [], + "starting_column": null, + "ending_column": null + }, + "type_specific_fields": { + "directive": [ + "solidity", + "^", + "0.5", + ".5" + ] + } + } + ] + }, + { + "check": "solc-version", + "impact": "Informational", + "confidence": "High", + "description": "Pragma version \"0.5.7\" necessitates versions too recent to be trusted. Consider deploying with 0.5.3 (None)\n", + "elements": [ + { + "type": "pragma", + "name": "0.5.7", + "source_mapping": { + "start": 87, + "length": 22, + "filename_used": "solc_version_incorrect_05.sol", + "filename_relative": null, + "filename_absolute": null, + "filename_short": null, + "lines": [], + "starting_column": null, + "ending_column": null + }, + "type_specific_fields": { + "directive": [ + "solidity", + "0.5", + ".7" + ] + } + } + ] + } + ] + } +} \ No newline at end of file diff --git a/tests/expected_json/solc_version_incorrect_05.ast.json.solc-version.txt b/tests/expected_json/solc_version_incorrect_05.ast.json.solc-version.txt new file mode 100644 index 000000000..80b3f5dbc --- /dev/null +++ b/tests/expected_json/solc_version_incorrect_05.ast.json.solc-version.txt @@ -0,0 +1,5 @@ +INFO:Detectors: +Pragma version "^0.5.5" is known to contain severe issue (https://solidity.readthedocs.io/en/v0.5.8/bugs.html) (None) +Pragma version "0.5.7" necessitates versions too recent to be trusted. Consider deploying with 0.5.3 (None) +Reference: https://github.com/crytic/slither/wiki/Detector-Documentation#incorrect-version-of-solidity +INFO:Slither:tests/solc_version_incorrect_05.ast.json analyzed (1 contracts), 2 result(s) found diff --git a/tests/solc_version_incorrect_05.ast.json b/tests/solc_version_incorrect_05.ast.json new file mode 100644 index 000000000..4a73845b3 --- /dev/null +++ b/tests/solc_version_incorrect_05.ast.json @@ -0,0 +1,82 @@ +JSON AST: + + +======= solc_version_incorrect_05.sol ======= +{ + "attributes" : + { + "absolutePath" : "solc_version_incorrect_05.sol", + "exportedSymbols" : + { + "Contract" : + [ + 3 + ] + } + }, + "children" : + [ + { + "attributes" : + { + "literals" : + [ + "solidity", + "^", + "0.5", + ".5" + ] + }, + "id" : 1, + "name" : "PragmaDirective", + "src" : "63:23:0" + }, + { + "attributes" : + { + "literals" : + [ + "solidity", + "0.5", + ".7" + ] + }, + "id" : 2, + "name" : "PragmaDirective", + "src" : "87:22:0" + }, + { + "attributes" : + { + "baseContracts" : + [ + null + ], + "contractDependencies" : + [ + null + ], + "contractKind" : "contract", + "documentation" : null, + "fullyImplemented" : true, + "linearizedBaseContracts" : + [ + 3 + ], + "name" : "Contract", + "nodes" : + [ + null + ], + "scope" : 4 + }, + "id" : 3, + "name" : "ContractDefinition", + "src" : "111:21:0" + } + ], + "id" : 4, + "name" : "SourceUnit", + "src" : "63:70:0" +} +======= solc_version_incorrect_05.sol:Contract ======= diff --git a/tests/solc_version_incorrect_05.sol b/tests/solc_version_incorrect_05.sol new file mode 100644 index 000000000..19858f112 --- /dev/null +++ b/tests/solc_version_incorrect_05.sol @@ -0,0 +1,7 @@ +// The version pragma below should get flagged by the detector +pragma solidity ^0.5.5; +pragma solidity 0.5.7; + +contract Contract{ + +} From 2047ca6e886a54f5ceb5f8782483101c17de7761 Mon Sep 17 00:00:00 2001 From: Josselin Date: Mon, 13 May 2019 12:24:25 +0100 Subject: [PATCH 42/55] Minor improvements in slither-similar: - Fix import in utils.similarity.encore - Improve slither-similari help - Use contract.functions_not_inherited rather than contracts.functions + if function.contract == contract --- utils/similarity/__main__.py | 2 +- utils/similarity/encode.py | 51 +++++++++++++++++------------------- 2 files changed, 25 insertions(+), 28 deletions(-) diff --git a/utils/similarity/__main__.py b/utils/similarity/__main__.py index dc4d9da6a..239b68b62 100755 --- a/utils/similarity/__main__.py +++ b/utils/similarity/__main__.py @@ -19,7 +19,7 @@ logger = logging.getLogger("Slither-simil") modes = ["info", "test", "train", "plot"] def parse_args(): - parser = argparse.ArgumentParser(description='Code similarity detection tool') + parser = argparse.ArgumentParser(description='Code similarity detection tool. For usage, see https://github.com/crytic/slither/wiki/Code-Similarity-detector') parser.add_argument('mode', help="|".join(modes)) diff --git a/utils/similarity/encode.py b/utils/similarity/encode.py index 6c9f4700a..a9334a253 100644 --- a/utils/similarity/encode.py +++ b/utils/similarity/encode.py @@ -1,19 +1,19 @@ +import logging import os -import sys from slither import Slither -from slither.slithir.operations import * -from slither.slithir.variables import * -from slither.core.declarations import * -from slither.solc_parsing.declarations.function import * -from slither.core.solidity_types import * - -from slither.solc_parsing.variables.state_variable import * -from slither.solc_parsing.variables.local_variable import * -from slither.solc_parsing.variables.local_variable_init_from_tuple import * - +from slither.core.declarations import Structure, Enum, SolidityVariableComposed, SolidityVariable +from slither.core.solidity_types import ElementaryType, ArrayType, MappingType, UserDefinedType +from slither.slithir.operations import Assignment, Index, Member, Length, Balance, Binary, \ + Unary, Condition, NewArray, NewStructure, NewContract, NewElementaryType, \ + SolidityCall, Push, Delete, EventCall, LibraryCall, InternalDynamicCall, \ + HighLevelCall, LowLevelCall, TypeConversion, Return, Transfer, Send, Unpack, InitArray, InternalCall +from slither.slithir.variables import TemporaryVariable, TupleVariable, Constant, ReferenceVariable +from slither.solc_parsing.declarations.function import FunctionSolc +from slither.solc_parsing.variables.local_variable import LocalVariableSolc +from slither.solc_parsing.variables.local_variable_init_from_tuple import LocalVariableInitFromTupleSolc +from slither.solc_parsing.variables.state_variable import StateVariableSolc from .cache import load_cache -from crytic_compile.platform.solc import InvalidCompilation simil_logger = logging.getLogger("Slither-simil") compiler_logger = logging.getLogger("CryticCompile") @@ -194,25 +194,22 @@ def encode_contract(cfilename, **kwargs): for contract in slither.contracts: # Iterate over all the functions - for function in contract.functions: - - # Dont explore inherited functions - if function.contract == contract: + for function in contract.functions_not_inherited: - if function.nodes == []: - continue + if function.nodes == []: + continue - x = (cfilename,contract.name,function.name) + x = (cfilename,contract.name,function.name) - r[x] = [] + r[x] = [] - # Iterate over the nodes of the function - for node in function.nodes: - # Print the Solidity expression of the nodes - # And the SlithIR operations - if node.expression: - for ir in node.irs: - r[x].append(encode_ir(ir)) + # Iterate over the nodes of the function + for node in function.nodes: + # Print the Solidity expression of the nodes + # And the SlithIR operations + if node.expression: + for ir in node.irs: + r[x].append(encode_ir(ir)) return r From 140ea6fd0b39dd4bd41f8983b0e405c02cd6a655 Mon Sep 17 00:00:00 2001 From: Josselin Date: Mon, 13 May 2019 12:26:51 +0100 Subject: [PATCH 43/55] Remove Solidity dependencies --- utils/similarity/encode.py | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/utils/similarity/encode.py b/utils/similarity/encode.py index a9334a253..0418a82e7 100644 --- a/utils/similarity/encode.py +++ b/utils/similarity/encode.py @@ -2,17 +2,16 @@ import logging import os from slither import Slither -from slither.core.declarations import Structure, Enum, SolidityVariableComposed, SolidityVariable +from slither.core.declarations import Structure, Enum, SolidityVariableComposed, SolidityVariable, Function from slither.core.solidity_types import ElementaryType, ArrayType, MappingType, UserDefinedType +from slither.core.variables.local_variable import LocalVariable +from slither.core.variables.local_variable_init_from_tuple import LocalVariableInitFromTuple +from slither.core.variables.state_variable import StateVariable from slither.slithir.operations import Assignment, Index, Member, Length, Balance, Binary, \ Unary, Condition, NewArray, NewStructure, NewContract, NewElementaryType, \ SolidityCall, Push, Delete, EventCall, LibraryCall, InternalDynamicCall, \ HighLevelCall, LowLevelCall, TypeConversion, Return, Transfer, Send, Unpack, InitArray, InternalCall from slither.slithir.variables import TemporaryVariable, TupleVariable, Constant, ReferenceVariable -from slither.solc_parsing.declarations.function import FunctionSolc -from slither.solc_parsing.variables.local_variable import LocalVariableSolc -from slither.solc_parsing.variables.local_variable_init_from_tuple import LocalVariableInitFromTupleSolc -from slither.solc_parsing.variables.state_variable import StateVariableSolc from .cache import load_cache simil_logger = logging.getLogger("Slither-simil") @@ -152,7 +151,7 @@ def encode_ir(ir): return 'unpack' if isinstance(ir, InitArray): # TODO: improve return 'init_array' - if isinstance(ir, FunctionSolc): # TODO: investigate this + if isinstance(ir, Function): # TODO: investigate this return 'function_solc' # variables @@ -166,11 +165,11 @@ def encode_ir(ir): return 'temporary_variable' if isinstance(ir, ReferenceVariable): return 'reference({})'.format(ntype(ir._type)) - if isinstance(ir, LocalVariableSolc): + if isinstance(ir, LocalVariable): return 'local_solc_variable({})'.format(ir._location) - if isinstance(ir, StateVariableSolc): + if isinstance(ir, StateVariable): return 'state_solc_variable({})'.format(ntype(ir._type)) - if isinstance(ir, LocalVariableInitFromTupleSolc): + if isinstance(ir, LocalVariableInitFromTuple): return 'local_variable_init_tuple' if isinstance(ir, TupleVariable): return 'tuple_variable' From 9d27edc5d239f39d064f0f26964a91f1b191402c Mon Sep 17 00:00:00 2001 From: Josselin Date: Mon, 13 May 2019 14:52:52 +0100 Subject: [PATCH 44/55] Update etherscan test --- scripts/travis_test_etherscan.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/travis_test_etherscan.sh b/scripts/travis_test_etherscan.sh index c96eca12e..43c8a1e4a 100755 --- a/scripts/travis_test_etherscan.sh +++ b/scripts/travis_test_etherscan.sh @@ -10,7 +10,7 @@ chmod +x solc-0.4.25 slither 0x7F37f78cBD74481E593F9C737776F7113d76B315 --solc "./solc-0.4.25" -if [ $? -ne 5 ] +if [ $? -ne 6 ] then echo "Etherscan test failed" exit -1 From a9466230a801ed83b2ca2f22ee1fdc0400de8641 Mon Sep 17 00:00:00 2001 From: ggrieco-tob Date: Mon, 13 May 2019 11:20:44 -0300 Subject: [PATCH 45/55] final fixes --- utils/similarity/encode.py | 4 ++-- utils/similarity/test.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/utils/similarity/encode.py b/utils/similarity/encode.py index 0418a82e7..3ea47ca7c 100644 --- a/utils/similarity/encode.py +++ b/utils/similarity/encode.py @@ -32,7 +32,7 @@ def parse_target(target): else: simil_logger.error("Invalid target. It should be 'function' or 'Contract.function'") -def load_and_encode(infile, model, filter=None, nsamples=None, **kwargs): +def load_and_encode(infile, vmodel, ext=None, nsamples=None, **kwargs): r = dict() if infile.endswith(".npz"): r = load_cache(infile, nsamples=nsamples) @@ -42,7 +42,7 @@ def load_and_encode(infile, model, filter=None, nsamples=None, **kwargs): for x,ir in encode_contract(contract, **kwargs).items(): if ir != []: y = " ".join(ir) - r[x] = model.get_sentence_vector(y) + r[x] = vmodel.get_sentence_vector(y) return r diff --git a/utils/similarity/test.py b/utils/similarity/test.py index 08542dd0d..15a39cc13 100755 --- a/utils/similarity/test.py +++ b/utils/similarity/test.py @@ -33,7 +33,7 @@ def test(args): y = " ".join(irs[(filename,contract,fname)]) fvector = model.get_sentence_vector(y) - cache = load_and_encode(infile, **vars(args)) + cache = load_and_encode(infile, model, **vars(args)) #save_cache("cache.npz", cache) r = dict() From 7e2ed2bf99dfdae162b2af383abf48984a14e225 Mon Sep 17 00:00:00 2001 From: Josselin Date: Mon, 13 May 2019 17:30:35 +0100 Subject: [PATCH 46/55] Fix incorrect wiki link --- README.md | 2 +- .../detectors/operations/unchecked_low_level_return_values.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index abb736196..43f853120 100644 --- a/README.md +++ b/README.md @@ -55,7 +55,7 @@ Num | Detector | What it Detects | Impact | Confidence 14 | `constant-function` | [Constant functions changing the state](https://github.com/crytic/slither/wiki/Detector-Documentation#constant-functions-changing-the-state) | Medium | Medium 15 | `reentrancy-no-eth` | [Reentrancy vulnerabilities (no theft of ethers)](https://github.com/crytic/slither/wiki/Detector-Documentation#reentrancy-vulnerabilities-1) | Medium | Medium 16 | `tx-origin` | [Dangerous usage of `tx.origin`](https://github.com/crytic/slither/wiki/Detector-Documentation#dangerous-usage-of-txorigin) | Medium | Medium -17 | `unchecked-lowlevel` | [Unchecked low-level calls](https://github.com/crytic/slither/wiki/Detector-Documentation#unchecked-low-level) | Medium | Medium +17 | `unchecked-lowlevel` | [Unchecked low-level calls](https://github.com/crytic/slither/wiki/Detector-Documentation#unchecked-low-level-calls) | Medium | Medium 18 | `unchecked-send` | [Unchecked send](https://github.com/crytic/slither/wiki/Detector-Documentation#unchecked-send) | Medium | Medium 19 | `uninitialized-local` | [Uninitialized local variables](https://github.com/crytic/slither/wiki/Detector-Documentation#uninitialized-local-variables) | Medium | Medium 20 | `unused-return` | [Unused return values](https://github.com/crytic/slither/wiki/Detector-Documentation#unused-return) | Medium | Medium diff --git a/slither/detectors/operations/unchecked_low_level_return_values.py b/slither/detectors/operations/unchecked_low_level_return_values.py index 6f85600a7..74a049112 100644 --- a/slither/detectors/operations/unchecked_low_level_return_values.py +++ b/slither/detectors/operations/unchecked_low_level_return_values.py @@ -15,7 +15,7 @@ class UncheckedLowLevel(UnusedReturnValues): IMPACT = DetectorClassification.MEDIUM CONFIDENCE = DetectorClassification.MEDIUM - WIKI = 'https://github.com/crytic/slither/wiki/Detector-Documentation#unchecked-low-level' + WIKI = 'https://github.com/crytic/slither/wiki/Detector-Documentation#unchecked-low-level-calls' WIKI_TITLE = 'Unchecked low-level calls' WIKI_DESCRIPTION = 'The return value of a low-level call is not checked.' From cf20da7bd5d699c2084486a683515276360f74e0 Mon Sep 17 00:00:00 2001 From: rajeevgopalakrishna Date: Tue, 14 May 2019 09:46:36 +0530 Subject: [PATCH 47/55] Removed get_source_event/var_declaration from contract and function. Use source_mapping of variables/events directly. --- slither/core/declarations/contract.py | 20 -------------------- slither/core/declarations/function.py | 9 --------- 2 files changed, 29 deletions(-) diff --git a/slither/core/declarations/contract.py b/slither/core/declarations/contract.py index cbfe723f7..667a0134f 100644 --- a/slither/core/declarations/contract.py +++ b/slither/core/declarations/contract.py @@ -367,26 +367,6 @@ class Contract(ChildSlither, SourceMapping): ''' return [f for f in self.functions if f.is_writing(variable)] - def get_source_var_declaration(self, var): - """ Return the source mapping where the variable is declared - - Args: - var (str): variable name - Returns: - (dict): sourceMapping - """ - return next((x.source_mapping for x in self.variables if x.name == var)) - - def get_source_event_declaration(self, event): - """ Return the source mapping where the event is declared - - Args: - event (str): event name - Returns: - (dict): sourceMapping - """ - return next((x.source_mapping for x in self.events if x.name == event)) - def get_function_from_signature(self, function_signature): """ Return a function from a signature diff --git a/slither/core/declarations/function.py b/slither/core/declarations/function.py index fdee9f3aa..577c77b1a 100644 --- a/slither/core/declarations/function.py +++ b/slither/core/declarations/function.py @@ -393,15 +393,6 @@ class Function(ChildContract, SourceMapping): return list(self._slithir_variables) - def get_source_var_declaration(self, var): - """ Return the source mapping where the variable is declared - Args: - var (str): variable name - Returns: - (dict): sourceMapping - """ - return next((x.source_mapping for x in self.variables if x.name == var)) - # endregion ################################################################################### ################################################################################### From 1cbdd0f33a1cfe3ed1b7050e9951e72fdbc886e4 Mon Sep 17 00:00:00 2001 From: rajeevgopalakrishna Date: Tue, 14 May 2019 12:22:46 +0530 Subject: [PATCH 48/55] Changes parameters_src and returns_src to SourceMapping objects instead of raw source text. --- slither/solc_parsing/declarations/function.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/slither/solc_parsing/declarations/function.py b/slither/solc_parsing/declarations/function.py index 0e020b1da..7619dea08 100644 --- a/slither/solc_parsing/declarations/function.py +++ b/slither/solc_parsing/declarations/function.py @@ -27,6 +27,7 @@ from slither.utils.utils import unroll from slither.visitors.expression.export_values import ExportValues from slither.visitors.expression.has_conditional import HasConditional from slither.solc_parsing.exceptions import ParsingError +from slither.core.source_mapping.source_mapping import SourceMapping logger = logging.getLogger("FunctionSolc") @@ -835,7 +836,8 @@ class FunctionSolc(Function): def _parse_params(self, params): assert params[self.get_key()] == 'ParameterList' - self.parameters_src = params['src'] + self.parameters_src = SourceMapping() + self.parameters_src.set_offset(params['src'], self.contract.slither) if self.is_compact_ast: params = params['parameters'] @@ -862,7 +864,8 @@ class FunctionSolc(Function): assert returns[self.get_key()] == 'ParameterList' - self.returns_src = returns['src'] + self.returns_src = SourceMapping() + self.returns_src.set_offset(returns['src'], self.contract.slither) if self.is_compact_ast: returns = returns['parameters'] From 8ec1f92d90984c3258257cc3bb03fb90eddcaa36 Mon Sep 17 00:00:00 2001 From: Josselin Date: Tue, 14 May 2019 09:02:36 +0100 Subject: [PATCH 49/55] Improve human summary printer --- slither/printers/summary/human_summary.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/slither/printers/summary/human_summary.py b/slither/printers/summary/human_summary.py index 625a0aca9..2e126f8a3 100644 --- a/slither/printers/summary/human_summary.py +++ b/slither/printers/summary/human_summary.py @@ -72,13 +72,23 @@ class PrinterHumanSummary(AbstractPrinter): checks_high = self.slither.detectors_high issues_informational = [c.detect() for c in checks_informational] + issues_informational = [c for c in issues_informational if c] issues_informational = [item for sublist in issues_informational for item in sublist] + issues_low = [c.detect() for c in checks_low] issues_low = [c for c in issues_low if c] + issues_low = [item for sublist in issues_low for item in sublist] + issues_medium = (c.detect() for c in checks_medium) issues_medium = [c for c in issues_medium if c] + issues_medium = [item for sublist in issues_medium for item in sublist] + issues_high = [c.detect() for c in checks_high] issues_high = [c for c in issues_high if c] + issues_high = [item for sublist in issues_high for item in sublist] + + + return (len(issues_informational), len(issues_low), len(issues_medium), From 85045f77b02ca85cb2c0130ca7111db38f275e38 Mon Sep 17 00:00:00 2001 From: Josselin Date: Tue, 14 May 2019 09:28:06 +0100 Subject: [PATCH 50/55] Improve errors handling --- slither/all_exceptions.py | 2 +- slither/solc_parsing/exceptions.py | 4 +++- .../solc_parsing/expressions/expression_parsing.py | 14 +++----------- 3 files changed, 7 insertions(+), 13 deletions(-) diff --git a/slither/all_exceptions.py b/slither/all_exceptions.py index 39412971d..397ac1508 100644 --- a/slither/all_exceptions.py +++ b/slither/all_exceptions.py @@ -2,6 +2,6 @@ This module import all slither exceptions """ from slither.slithir.exceptions import SlithIRError -from slither.solc_parsing.exceptions import ParsingError, ParsingContractNotFound, ParsingNameReuse +from slither.solc_parsing.exceptions import ParsingError, ParsingContractNotFound, ParsingNameReuse, VariableNotFound from slither.core.exceptions import SlitherCoreError from slither.exceptions import SlitherException \ No newline at end of file diff --git a/slither/solc_parsing/exceptions.py b/slither/solc_parsing/exceptions.py index f4f0e388f..dcf576509 100644 --- a/slither/solc_parsing/exceptions.py +++ b/slither/solc_parsing/exceptions.py @@ -4,4 +4,6 @@ class ParsingError(SlitherException): pass class ParsingNameReuse(SlitherException): pass -class ParsingContractNotFound(SlitherException): pass \ No newline at end of file +class ParsingContractNotFound(SlitherException): pass + +class VariableNotFound(SlitherException): pass diff --git a/slither/solc_parsing/expressions/expression_parsing.py b/slither/solc_parsing/expressions/expression_parsing.py index 2d037ebdb..2dbb01bdf 100644 --- a/slither/solc_parsing/expressions/expression_parsing.py +++ b/slither/solc_parsing/expressions/expression_parsing.py @@ -35,19 +35,11 @@ from slither.core.solidity_types import (ArrayType, ElementaryType, FunctionType, MappingType) from slither.solc_parsing.solidity_types.type_parsing import (UnknownType, parse_type) -from slither.solc_parsing.exceptions import ParsingError -logger = logging.getLogger("ExpressionParsing") - +from slither.solc_parsing.exceptions import ParsingError, VariableNotFound -################################################################################### -################################################################################### -# region Exception -################################################################################### -################################################################################### +logger = logging.getLogger("ExpressionParsing") -class VariableNotFound(Exception): pass -# endregion ################################################################################### ################################################################################### # region Helpers @@ -157,7 +149,7 @@ def find_variable(var_name, caller_context, referenced_declaration=None): if function.referenced_declaration == referenced_declaration: return function - raise VariableNotFound('Variable not found: {}'.format(var_name)) + raise VariableNotFound('Variable not found: {} (context {})'.format(var_name, caller_context)) # endregion ################################################################################### From 774fcb5d27a1e89eae94c843396e86bb76ed05d5 Mon Sep 17 00:00:00 2001 From: Josselin Date: Tue, 14 May 2019 10:18:26 +0100 Subject: [PATCH 51/55] Add support for type(X) operation (creationCode, runtimeCode, name) --- .../core/declarations/solidity_variables.py | 16 +++++-- slither/core/solidity_types/__init__.py | 1 + .../core/solidity_types/type_information.py | 23 ++++++++++ slither/slithir/convert.py | 44 ++++++++++++++++++- 4 files changed, 80 insertions(+), 4 deletions(-) create mode 100644 slither/core/solidity_types/type_information.py diff --git a/slither/core/declarations/solidity_variables.py b/slither/core/declarations/solidity_variables.py index df179dd40..da85e9b12 100644 --- a/slither/core/declarations/solidity_variables.py +++ b/slither/core/declarations/solidity_variables.py @@ -1,6 +1,6 @@ # https://solidity.readthedocs.io/en/v0.4.24/units-and-global-variables.html from slither.core.context.context import Context -from slither.core.solidity_types import ElementaryType +from slither.core.solidity_types import ElementaryType, TypeInformation SOLIDITY_VARIABLES = {"now":'uint256', "this":'address', @@ -57,7 +57,8 @@ SOLIDITY_FUNCTIONS = {"gasleft()":['uint256'], "abi.encodeWithSelector()":["bytes"], "abi.encodeWithSignature()":["bytes"], # abi.decode returns an a list arbitrary types - "abi.decode()":[]} + "abi.decode()":[], + "type(address)":[]} def solidity_function_signature(name): """ @@ -125,10 +126,15 @@ class SolidityVariableComposed(SolidityVariable): class SolidityFunction: + # Non standard handling of type(address). This function returns an undefined object + # The type is dynamic + # https://solidity.readthedocs.io/en/latest/units-and-global-variables.html#type-information + # As a result, we set return_type during the Ir conversion def __init__(self, name): assert name in SOLIDITY_FUNCTIONS self._name = name + self._return_type = [ElementaryType(x) for x in SOLIDITY_FUNCTIONS[self.name]] @property def name(self): @@ -140,7 +146,11 @@ class SolidityFunction: @property def return_type(self): - return [ElementaryType(x) for x in SOLIDITY_FUNCTIONS[self.name]] + return self._return_type + + @return_type.setter + def return_type(self, r): + self._return_type = r def __str__(self): return self._name diff --git a/slither/core/solidity_types/__init__.py b/slither/core/solidity_types/__init__.py index b7ec244bf..24288488a 100644 --- a/slither/core/solidity_types/__init__.py +++ b/slither/core/solidity_types/__init__.py @@ -3,3 +3,4 @@ from .elementary_type import ElementaryType from .function_type import FunctionType from .mapping_type import MappingType from .user_defined_type import UserDefinedType +from .type_information import TypeInformation \ No newline at end of file diff --git a/slither/core/solidity_types/type_information.py b/slither/core/solidity_types/type_information.py new file mode 100644 index 000000000..ee6e71ee8 --- /dev/null +++ b/slither/core/solidity_types/type_information.py @@ -0,0 +1,23 @@ +from slither.core.solidity_types.type import Type + +# Use to model the Type(X) function, which returns an undefined type +# https://solidity.readthedocs.io/en/latest/units-and-global-variables.html#type-information +class TypeInformation(Type): + def __init__(self, c): + from slither.core.declarations.contract import Contract + + assert isinstance(c, (Contract)) + super(TypeInformation, self).__init__() + self._type = c + + @property + def type(self): + return self._type + + def __str__(self): + return f'type({self.type.name})' + + def __eq__(self, other): + if not isinstance(other, TypeInformation): + return False + return self.type == other.type \ No newline at end of file diff --git a/slither/slithir/convert.py b/slither/slithir/convert.py index a1b15d5b5..13c51d193 100644 --- a/slither/slithir/convert.py +++ b/slither/slithir/convert.py @@ -6,7 +6,7 @@ from slither.core.declarations import (Contract, Enum, Event, Function, from slither.core.expressions import Identifier, Literal from slither.core.solidity_types import (ArrayType, ElementaryType, FunctionType, MappingType, - UserDefinedType) + UserDefinedType, TypeInformation) from slither.core.solidity_types.elementary_type import Int as ElementaryTypeInt from slither.core.variables.variable import Variable from slither.core.variables.state_variable import StateVariable @@ -297,6 +297,44 @@ def propagate_type_and_convert_call(result, node): idx = idx +1 return result +def _convert_type_contract(ir, slither): + assert isinstance(ir.variable_left.type, TypeInformation) + contract = ir.variable_left.type.type + + if ir.variable_right == 'creationCode': + if slither.crytic_compile: + bytecode = slither.crytic_compile.bytecode_init(contract.name) + else: + logger.info( + 'The codebase uses type(x).creationCode, but crytic-compile was not used. As a result, the bytecode cannot be found') + bytecode = "MISSING_BYTECODE" + assignment = Assignment(ir.lvalue, + Constant(str(bytecode)), + ElementaryType('bytes')) + assignment.lvalue.set_type(ElementaryType('bytes')) + return assignment + if ir.variable_right == 'runtimeCode': + if slither.crytic_compile: + bytecode = slither.crytic_compile.bytecode_runtime(contract.name) + else: + logger.info( + 'The codebase uses type(x).runtimeCode, but crytic-compile was not used. As a result, the bytecode cannot be found') + bytecode = "MISSING_BYTECODE" + assignment = Assignment(ir.lvalue, + Constant(str(bytecode)), + ElementaryType('bytes')) + assignment.lvalue.set_type(ElementaryType('bytes')) + return assignment + if ir.variable_right == 'name': + assignment = Assignment(ir.lvalue, + Constant(contract.name), + ElementaryType('string')) + assignment.lvalue.set_type(ElementaryType('string')) + return assignment + + raise SlithIRError(f'type({contract.name}).{ir.variable_right} is unknown') + + def propagate_types(ir, node): # propagate the type using_for = node.function.contract.using_for @@ -398,6 +436,8 @@ def propagate_types(ir, node): ElementaryType('bytes4')) assignment.lvalue.set_type(ElementaryType('bytes4')) return assignment + if isinstance(ir.variable_left, TemporaryVariable) and isinstance(ir.variable_left.type, TypeInformation): + return _convert_type_contract(ir, node.function.slither) left = ir.variable_left t = None if isinstance(left, (Variable, SolidityVariable)): @@ -447,6 +487,8 @@ def propagate_types(ir, node): elif isinstance(ir, Send): ir.lvalue.set_type(ElementaryType('bool')) elif isinstance(ir, SolidityCall): + if ir.function.name == 'type(address)': + ir.function.return_type = [TypeInformation(ir.arguments[0])] return_type = ir.function.return_type if len(return_type) == 1: ir.lvalue.set_type(return_type[0]) From a8a399b809cc5cb08abda6d2881b518458687eca Mon Sep 17 00:00:00 2001 From: Josselin Date: Tue, 14 May 2019 14:23:55 +0100 Subject: [PATCH 52/55] Fix regex in source unit parsing (space bug) --- slither/solc_parsing/slitherSolc.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/slither/solc_parsing/slitherSolc.py b/slither/solc_parsing/slitherSolc.py index eebb99935..6d11e2cc8 100644 --- a/slither/solc_parsing/slitherSolc.py +++ b/slither/solc_parsing/slitherSolc.py @@ -136,7 +136,7 @@ class SlitherSolc(Slither): # match any char for filename # filename can contain space, /, -, .. - name = re.findall('=* (.+) =*', filename) + name = re.findall('=+ (.+) =+', filename) if name: assert len(name) == 1 name = name[0] @@ -154,7 +154,7 @@ class SlitherSolc(Slither): # This works only for crytic compile. # which used --combined-json ast, rather than --ast-json # As a result -1 is not used as index - if not self.crytic_compile is None: + if self.crytic_compile is not None: sourceUnit = len(self.source_code) self._source_units[sourceUnit] = name From 29fb9371cde8be9c9153fcf7f2471b4b17fb4863 Mon Sep 17 00:00:00 2001 From: Josselin Date: Tue, 14 May 2019 17:33:06 +0100 Subject: [PATCH 53/55] Update to crytic-compile 0.1.1 --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 4721aea29..00e1a48e5 100644 --- a/setup.py +++ b/setup.py @@ -8,7 +8,7 @@ setup( version='0.6.3', packages=find_packages(), python_requires='>=3.6', - install_requires=['prettytable>=0.7.2', 'pysha3>=1.0.2', 'crytic-compile>=0.1.0'], + install_requires=['prettytable>=0.7.2', 'pysha3>=1.0.2', 'crytic-compile>=0.1.1'], license='AGPL-3.0', long_description=open('README.md').read(), entry_points={ From 7cadf980b83ecbb31456c3502c1a8508ce811bf9 Mon Sep 17 00:00:00 2001 From: Josselin Date: Tue, 14 May 2019 17:33:54 +0100 Subject: [PATCH 54/55] v0.6.4 --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 00e1a48e5..d6642a502 100644 --- a/setup.py +++ b/setup.py @@ -5,7 +5,7 @@ setup( description='Slither is a Solidity static analysis framework written in Python 3.', url='https://github.com/crytic/slither', author='Trail of Bits', - version='0.6.3', + version='0.6.4', packages=find_packages(), python_requires='>=3.6', install_requires=['prettytable>=0.7.2', 'pysha3>=1.0.2', 'crytic-compile>=0.1.1'], From 6a473c7e87f510f016dfadb1f5ba7f5b05940db8 Mon Sep 17 00:00:00 2001 From: Josselin Date: Wed, 15 May 2019 10:15:30 +0100 Subject: [PATCH 55/55] Minor --- slither/detectors/abstract_detector.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/slither/detectors/abstract_detector.py b/slither/detectors/abstract_detector.py index ad22ae092..39651c12a 100644 --- a/slither/detectors/abstract_detector.py +++ b/slither/detectors/abstract_detector.py @@ -160,8 +160,8 @@ class AbstractDetector(metaclass=abc.ABCMeta): def _create_parent_element(element): from slither.core.children.child_contract import ChildContract from slither.core.children.child_function import ChildFunction - from slither.core.declarations import Function - if isinstance(element, Function): + from slither.core.children.child_inheritance import ChildInheritance + if isinstance(element, ChildInheritance): if element.contract_declarer: contract = {'elements': []} AbstractDetector.add_contract_to_json(element.contract_declarer, contract)