From 36afdca50e609052eb66819289bf67000bc570f3 Mon Sep 17 00:00:00 2001 From: rajeevgopalakrishna Date: Tue, 14 May 2019 13:17:11 +0530 Subject: [PATCH] Changes use of parameters_src and returns_src to source_mapping objects instead of raw source text. --- utils/slither_format/format_constant_function.py | 2 +- utils/slither_format/format_external_function.py | 2 +- utils/slither_format/format_naming_convention.py | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/utils/slither_format/format_constant_function.py b/utils/slither_format/format_constant_function.py index 13bc725a0..d31f2b47c 100644 --- a/utils/slither_format/format_constant_function.py +++ b/utils/slither_format/format_constant_function.py @@ -13,7 +13,7 @@ class FormatConstantFunction: if not Found: for function in contract.functions: if contract.name == element['contract']['name'] and function.name == element['name']: - FormatConstantFunction.create_patch(slither, patches, element['source_mapping']['filename_absolute'], ["view","pure","constant"], "", int(function.parameters_src.split(':')[0]), int(function.returns_src.split(':')[0])) + FormatConstantFunction.create_patch(slither, patches, element['source_mapping']['filename_absolute'], ["view","pure","constant"], "", int(function.parameters_src.source_mapping['start']), int(function.returns_src.source_mapping['start'])) Found = True @staticmethod diff --git a/utils/slither_format/format_external_function.py b/utils/slither_format/format_external_function.py index 389b0d06b..d9c826e9e 100644 --- a/utils/slither_format/format_external_function.py +++ b/utils/slither_format/format_external_function.py @@ -14,7 +14,7 @@ class FormatExternalFunction: # to external because external function parameters are allocated in calldata region which is # non-modifiable. See https://solidity.readthedocs.io/en/develop/types.html#data-location if not FormatExternalFunction.function_parameters_written(function): - FormatExternalFunction.create_patch(slither, patches, element['source_mapping']['filename_absolute'], "public", "external", int(function.parameters_src.split(':')[0]), int(function.returns_src.split(':')[0])) + FormatExternalFunction.create_patch(slither, patches, element['source_mapping']['filename_absolute'], "public", "external", int(function.parameters_src.source_mapping['start']), int(function.returns_src.source_mapping['start'])) Found = True break diff --git a/utils/slither_format/format_naming_convention.py b/utils/slither_format/format_naming_convention.py index 72b975497..7b868cad7 100644 --- a/utils/slither_format/format_naming_convention.py +++ b/utils/slither_format/format_naming_convention.py @@ -168,13 +168,13 @@ class FormatNamingConvention: for m in function.modifiers: if (m.name == name): in_file_str = slither.source_code[in_file] - old_str_of_interest = in_file_str[int(function.parameters_src.split(':')[0]):int(function.returns_src.split(':')[0])] + old_str_of_interest = in_file_str[int(function.parameters_src.source_mapping['start']):int(function.returns_src.source_mapping['start'])] (new_str_of_interest, num_repl) = re.subn(name, name[0].lower()+name[1:],old_str_of_interest,1) if num_repl != 0: patch = { "detector" : "naming-convention (modifier uses)", - "start" : int(function.parameters_src.split(':')[0]), - "end" : int(function.returns_src.split(':')[0]), + "start" : int(function.parameters_src.source_mapping['start']), + "end" : int(function.returns_src.source_mapping['start']), "old_string" : old_str_of_interest, "new_string" : new_str_of_interest }